Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: upgrade agent-js v2 #5274

Merged
merged 20 commits into from
Aug 29, 2024
Merged

build: upgrade agent-js v2 #5274

merged 20 commits into from
Aug 29, 2024

Conversation

peterpeterparker
Copy link
Member

@peterpeterparker peterpeterparker commented Aug 5, 2024

Motivation

Upgrade all required dependencies to support agent-js v2.

Changes

Tests

  • Manually; demo link - https://qsgjb-riaaa-aaaaa-aaaga-cai.mstr-ingress.devenv.dfinity.network/
  • Because of the broken tests added mocking of the createAgent function from the @dfinity/utils. This is done to avoid agent-js to make a real network requests. In version 2.0, agent-js starts syncing time with the replica immediately after creation, which breaks some tests since real fetch requests are not allowed.

Error sample:

   ❯ src/tests/lib/worker-api/canisters.worker-api.spec.ts > canisters-worker-api > queryCanisterDetails > should call IC Management Canister with canister id
     → Your test produced console logs, which is not allowed.
If you need console output, mock and expect it in your test.
This failure only happens after your test finishes so if your test had other failures, you can still see them and just ignore this.
If this is only for debugging, call allowLoggingInOneTestForDebugging() from $tests/utils/console.test-utils in your test.
stderr | src/tests/lib/worker-api/canisters.worker-api.spec.ts > canisters-worker-api > queryCanisterDetails > should call IC Management Canister with canister id
It looks like the agent is trying to make a request that should have been mocked at Error:
    at Object.transformRequest (/Users/mstr/projects/nns-dapp-tree-a/frontend/src/tests/mocks/auth.store.mock.ts:16:5)
    at HttpAgent.createReadStateRequest (/Users/mstr/projects/nns-dapp-tree-a/frontend/node_modules/@dfinity/agent/src/agent/http/index.ts:954:11)
    at HttpAgent.readState (/Users/mstr/projects/nns-dapp-tree-a/frontend/node_modules/@dfinity/agent/src/agent/http/index.ts:962:31)
    at /Users/mstr/projects/nns-dapp-tree-a/frontend/node_modules/@dfinity/agent/src/canisterStatus/index.ts:152:12
    at async Promise.all (index 0)
    at Module.request (/Users/mstr/projects/nns-dapp-tree-a/frontend/node_modules/@dfinity/agent/src/canisterStatus/index.ts:260:3)
    at HttpAgent.syncTime (/Users/mstr/projects/nns-dapp-tree-a/frontend/node_modules/@dfinity/agent/src/agent/http/index.ts:1029:15)
    at async Promise.all (index 0)
    at Function.create (/Users/mstr/projects/nns-dapp-tree-a/frontend/node_modules/@dfinity/agent/src/agent/http/index.ts:372:5)
    at Module.tt (/Users/mstr/projects/nns-dapp-tree-a/frontend/node_modules/@dfinity/utils/dist/esm/index.js:4:2612)
  Expected to find result for path time, but instead found nothing.
  Error: Not implemented
      at Object.transformRequest (/Users/mstr/projects/nns-dapp-tree-a/frontend/src/tests/mocks/auth.store.mock.ts:18:9)
      at HttpAgent.createReadStateRequest (/Users/mstr/projects/nns-dapp-tree-a/frontend/node_modules/@dfinity/agent/src/agent/http/index.ts:954:11)
      at HttpAgent.readState (/Users/mstr/projects/nns-dapp-tree-a/frontend/node_modules/@dfinity/agent/src/agent/http/index.ts:962:31)
      at /Users/mstr/projects/nns-dapp-tree-a/frontend/node_modules/@dfinity/agent/src/canisterStatus/index.ts:152:12
      at async Promise.all (index 0)
      at Module.request (/Users/mstr/projects/nns-dapp-tree-a/frontend/node_modules/@dfinity/agent/src/canisterStatus/index.ts:260:3)
      at HttpAgent.syncTime (/Users/mstr/projects/nns-dapp-tree-a/frontend/node_modules/@dfinity/agent/src/agent/http/index.ts:1029:15)
      at async Promise.all (index 0)
      at Function.create (/Users/mstr/projects/nns-dapp-tree-a/frontend/node_modules/@dfinity/agent/src/agent/http/index.ts:372:5)
      at Module.tt (/Users/mstr/projects/nns-dapp-tree-a/frontend/node_modules/@dfinity/utils/dist/esm/index.js:4:2612)

Todos

  • Add entry to changelog (if necessary).

Copy link
Contributor

@mstrasinskis mstrasinskis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@peterpeterparker peterpeterparker marked this pull request as ready for review August 26, 2024 14:25
@peterpeterparker peterpeterparker requested a review from a team as a code owner August 26, 2024 14:25
@mstrasinskis
Copy link
Contributor

@dskloetd, could you please review the pr, since you haven't committed to it?

@dskloetd
Copy link
Contributor

Can you update the PR description to describe the current state of the PR?

@mstrasinskis
Copy link
Contributor

Can you update the PR description to describe the current state of the PR?

@dskloetd, upgraded.

Copy link
Contributor

@dskloetd dskloetd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@peterpeterparker
Copy link
Member Author

Thanks guyz!

@mstrasinskis mstrasinskis marked this pull request as draft August 29, 2024 05:28
@mstrasinskis mstrasinskis marked this pull request as ready for review August 29, 2024 07:12
@mstrasinskis mstrasinskis added this pull request to the merge queue Aug 29, 2024
Merged via the queue into main with commit cc9fb7e Aug 29, 2024
30 checks passed
@mstrasinskis mstrasinskis deleted the build/agent-v2 branch August 29, 2024 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants