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

Add tests for SDK #54

Merged
merged 24 commits into from
Oct 30, 2024
Merged

Add tests for SDK #54

merged 24 commits into from
Oct 30, 2024

Conversation

gsteenkamp89
Copy link
Collaborator

@gsteenkamp89 gsteenkamp89 commented Oct 25, 2024

closes ACX-2648

  • uses anvil (prool) and vitest and msw
  • forks 2 chains to closely
  • runs in CI

E2E tests

  • getQuote & executeQuote flow

NOTE:
Our use of a singleton does make unit tests slightly tricky (for the client initialization at least). Many properties and methods on our AcrossClient are private, thus not available for testing purposes.

QUESTION:
@dohaki @pxrl
Currently we are using MSW to mock api responses for quote, fees and chain info. In retrospect, this might not be necessary since our api is pretty open and inexpensive. We can turn off mocking with an env var, should we do this?

Copy link

changeset-bot bot commented Oct 25, 2024

⚠️ No Changeset found

Latest commit: 862138c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Oct 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
toolkit-example ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 30, 2024 10:41am

Copy link

linear bot commented Oct 28, 2024

@pxrl
Copy link
Contributor

pxrl commented Oct 30, 2024

NOTE: Our use of a singleton does make unit tests slightly tricky (for the client initialization at least). Many properties and methods on our AcrossClient are private, thus not available for testing purposes.

Is it worth changing these to protected so that they can be exposed via a another class that extends AcrossClient for test purposes? I've used that trick a bit in the relayer and sdk repos, at least.

QUESTION: @dohaki @pxrl Currently we are using MSW to mock api responses for quote, fees and chain info. In retrospect, this might not be necessary since our api is pretty open and inexpensive. We can turn off mocking with an env var, should we do this?

Given that this is classed as an e2e test then I can see value in querying the actual API. It's nice to verify that the implementation works in reality and not just in whatever we mocked 👍

Copy link
Collaborator

@dohaki dohaki left a comment

Choose a reason for hiding this comment

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

Awesome work! Just left a few questions.

packages/sdk/package.json Outdated Show resolved Hide resolved
packages/sdk/test/common/anvil.ts Outdated Show resolved Hide resolved
.github/workflows/build-lint-test.yml Outdated Show resolved Hide resolved
packages/sdk/.example.env Show resolved Hide resolved
packages/sdk/test/common/anvil.ts Outdated Show resolved Hide resolved
packages/sdk/test/common/constants.ts Show resolved Hide resolved
packages/sdk/test/common/setup.ts Outdated Show resolved Hide resolved
packages/sdk/test/e2e/executeQuote.test.ts Outdated Show resolved Hide resolved
@gsteenkamp89
Copy link
Collaborator Author

NOTE: Our use of a singleton does make unit tests slightly tricky (for the client initialization at least). Many properties and methods on our AcrossClient are private, thus not available for testing purposes.

Is it worth changing these to protected so that they can be exposed via a another class that extends AcrossClient for test purposes? I've used that trick a bit in the relayer and sdk repos, at least.

QUESTION: @dohaki @pxrl Currently we are using MSW to mock api responses for quote, fees and chain info. In retrospect, this might not be necessary since our api is pretty open and inexpensive. We can turn off mocking with an env var, should we do this?

Given that this is classed as an e2e test then I can see value in querying the actual API. It's nice to verify that the implementation works in reality and not just in whatever we mocked 👍

Okay I've disabled the mocks in CI, 👍

@gsteenkamp89 gsteenkamp89 merged commit a728b6b into master Oct 30, 2024
3 checks passed
@gsteenkamp89 gsteenkamp89 deleted the feat/e2e branch October 30, 2024 10:42
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