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

test: meta transaction FT transfer #8564

Merged
merged 3 commits into from
Feb 14, 2023

Conversation

jakmeier
Copy link
Contributor

This is the example used for NEP-366, an FT transfer paid by the
relayer but the relayer gets a reward in FT.

Adds fungible_token.wasm as a test contract, which is the
example implementation of NEP-141 in the near-sdk-rs repository.

We deploy this WASM, initialize the state to make an FT transfer
possible and then execute a meta transaction as intended.

This makes gas checks in meta transaction tests even more annoying
but otherwise the existing test framework mostly just worked.

This is the example used for NEP-366,  an FT transfer paid by the
relayer but the relayer gets a reward.

Adds `fungible_token.wasm` as a test contract, which is the
example implementation of NEP-141 in the near-sdk-rs  repository.
@jakmeier jakmeier requested a review from a team as a code owner February 13, 2023 18:12
@jakmeier
Copy link
Contributor Author

This was a bit trickier than I thought, but I think it's worth adding this scenario to our test suite.

On a side note, I keep sending these tests in batches, because I personally prefer reviewing several small PRs than one huge PR. But I can also group the remaining tests together in this PR if you don't want to be spammed by review requests, just let me know.

test-utils/testlib/src/runtime_utils.rs Show resolved Hide resolved
test-utils/testlib/src/runtime_utils.rs Show resolved Hide resolved

// let transfer_event: serde_json::Value =
// serde_json::from_str(&fn_call_logs[1]).expect("log events should be JSON");
// assert_eq!(transfer_event, ft_transfer_event(&sender, &receiver, 1000));
Copy link
Contributor

Choose a reason for hiding this comment

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

can you also check that david got the tokens ? (and that the token balance of alice & bob are correct)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, I added a small helper assert_ft_balance and then

assert_ft_balance(&node, &ft_contract, &receiver, 1000);
assert_ft_balance(&node, &ft_contract, &sender, 10_000 - 1000 - 10);
assert_ft_balance(&node, &ft_contract, &relayer, 1_000_000 - 10_000 + 10);

@near-bulldozer near-bulldozer bot merged commit c7aec59 into near:master Feb 14, 2023
@jakmeier jakmeier deleted the meta-tx-integrations-tests-3 branch February 14, 2023 10:36
nikurt pushed a commit to nikurt/nearcore that referenced this pull request Feb 15, 2023
This is the example used for NEP-366, an FT transfer paid by the
relayer but the relayer gets a reward in FT.

Adds `fungible_token.wasm` as a test contract, which is the
example implementation of NEP-141 in the near-sdk-rs repository.

We deploy this WASM, initialize the state to make an FT transfer
possible and then execute a meta transaction as intended.

This makes gas checks in meta transaction tests even more annoying
but otherwise the existing test framework mostly just worked.
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.

2 participants