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

[WIP] Unit tests for virtual cards backend #288

Closed
wants to merge 20 commits into from

Conversation

pbkompasz
Copy link
Contributor

Resolves #271

Copy link
Contributor

github-actions bot commented Aug 25, 2024

Unused devDependencies (3)

Filename devDependencies
package.json vite-plugin-node-polyfills
express
@types/express

Unlisted dependencies (3)

Filename unlisted
functions/get-order.spec.ts cloudflare
functions/list-gift-cards.spec.ts cloudflare
chance

Unresolved imports (1)

Filename unresolved
functions/list-gift-cards.spec.ts ./vitest-helpers

@ubiquity-os-deployer
Copy link

ubiquity-os-deployer bot commented Aug 25, 2024

@pbkompasz
Copy link
Contributor Author

@Keyrxng
I am writing test cases to claim gift cards, but I encountered a roadblock. This script (vitest/web3.ts) contains the creation of an Anvil child process, generating demo permits, and transferring tokens to the gift card treasury address. When I try to call permitTransferFrom to transfer the tokens, I get an InvalidSigner error.
Shouldn't I be able to claim the tokens with Anvil account [0]?

@Keyrxng
Copy link
Contributor

Keyrxng commented Sep 4, 2024

@EresDev would know better for this particular task, but yeah I assume so looking at the script but various other factors might have changed so I'm unsure personally.

@EresDev
Copy link
Contributor

EresDev commented Sep 5, 2024

When I try to call permitTransferFrom to transfer the tokens, I get an InvalidSigner error.

Maybe because this is missing networkId in permit parameters?

const tx = await permit2Contract.permitTransferFrom(

Plus, I also think it needs token approval and a few other steps. Something similar to what happens in yarn test:fund command.

Is it worth having all this anvil setup in backend unit tests? It is already present in e2e tests. Did you consider just mocking the blockchain? I think it is worth considering mocking the blockchain. In fact, we don't even change the state of blockchian in the backend, and it can make things much simpler.

@0x4007 0x4007 closed this Sep 26, 2024
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.

4 participants