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: add maxAutomaticTokenAssociations tests #2390

Merged
merged 5 commits into from
Jul 15, 2024

Conversation

ivaylonikolov7
Copy link
Contributor

@ivaylonikolov7 ivaylonikolov7 commented Jul 7, 2024

Description:

Adds integration tests for maxAutomaticTokenAssociations according to HIP-904 test plan.

This PR modifies TokenAssociateIntegrationTest.js by adding additional tests according to this test plan:

LIMITED AUTO ASSOCIATIONS [0-5000] (some sdks don’t have tests for these flows)

  1. Given 2 fungible tokens, a sender account with a balance of the 2 fungible tokens, and a receiver account with 1 auto associations, when token1 is transferred from the sender to the receiver account, then the receiver account contains the sent balance of the token and when token2 is transferred from the sender to the receiver account, then the transaction fails with NO_REMAINING_AUTOMATIC_ASSOCIATIONS
  2. Same test as above but with NFTs
  3. Given a fungible token, a sender account with a balance of the fungible token, a receiver account with no auto associations, and the fungible token is manually associated with the receiver account, when the token is transferred from the sender to the receiver account, then the receiver account contains the sent balance of the token
  4. Given an NFT, a sender account with 1 minted NFT, a receiver account with no auto associations, and the NFT is manually associated with the receiver account, when the NFT is transferred from the sender to the receiver account, then the receiver account contains the NFT (this is same as above but with NFT)

UNLIMITED AUTO ASSOCIATIONS -1

  1. Given 2 fungible tokens, a sender account with a balance of the 2 fungible tokens, and a receiver account with 1 auto associations, when token1 is transferred from the sender to the receiver account, then the receiver account contains the sent balance of the token and when token2 is transferred from the sender to the receiver account, then receiver account contains the sent balance of the token
  2. Same test as above but with NFTs
  3. Given a fungible token, a holder account with a balance of the fungible token, a spender account which has an allowance of the fungible token, and a receiver account with unlimited auto associations, when the token is transferred from the spender to the receiver account, then the receiver account contains the sent balance of the token and the transferred amount is debited from the holder account
  4. Given an NFT, a holder account with 1 minted NFT, a spender account which has an allowance of the NFT, and a receiver account with unlimited auto associations, when the NFT is transferred from the spender to the receiver account, then the receiver account contains the NFT and the NFT is debited from the holder account (this is same as above but with NFT)
  5. Given a fungible token with decimals, a sender account with a balance of the fungible token, and a receiver account with unlimited auto associations, when the token is transferred from the sender to the receiver account, then the receiver account contains the sent balance of the token
  6. Given a a receiver account with auto associations set to < -1, the INVALID_MAX_AUTO_ASSOCIATIONS error should be raised for AccountCreate and AccountUpdate transactions

Related issue(s):

#2332 #2333

Fixes #

#2332 #2333

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

@ivaylonikolov7 ivaylonikolov7 changed the title test: add max auto associate test test: add maxAutomaticTokenAssociations tests Jul 7, 2024
test/integration/TokenAssociateIntegrationTest.js Outdated Show resolved Hide resolved
test/integration/TokenAssociateIntegrationTest.js Outdated Show resolved Hide resolved
test/integration/TokenAssociateIntegrationTest.js Outdated Show resolved Hide resolved
test/integration/TokenAssociateIntegrationTest.js Outdated Show resolved Hide resolved
@gsstoykov
Copy link
Contributor

gsstoykov commented Jul 9, 2024

BTW, just for the future:

  • We usually put the related issues in the Fixes section
  • When you have tested a certain feature you should mark the Tested checkbox in the PR.
  • The Related issues section usually contains existing repository issues. So you can move your comment from there to Notes to reviewer

@ivaylonikolov7 ivaylonikolov7 force-pushed the feat/add-token-association-tests branch from ac6a1f1 to 196b7bc Compare July 9, 2024 09:46
test/integration/TokenAssociateIntegrationTest.js Outdated Show resolved Hide resolved
test/integration/TokenAssociateIntegrationTest.js Outdated Show resolved Hide resolved
test/integration/TokenAssociateIntegrationTest.js Outdated Show resolved Hide resolved
test/integration/TokenAssociateIntegrationTest.js Outdated Show resolved Hide resolved
test/integration/TokenAssociateIntegrationTest.js Outdated Show resolved Hide resolved
test/integration/TokenAssociateIntegrationTest.js Outdated Show resolved Hide resolved
test/integration/TokenAssociateIntegrationTest.js Outdated Show resolved Hide resolved
@svetoslav-nikol0v svetoslav-nikol0v removed the request for review from rwalworth July 9, 2024 11:24
@ivaylonikolov7 ivaylonikolov7 force-pushed the feat/add-token-association-tests branch from c850046 to 09d9586 Compare July 9, 2024 13:56
@ivaylonikolov7 ivaylonikolov7 force-pushed the feat/add-token-association-tests branch from 09d9586 to b5ca9e4 Compare July 9, 2024 14:02
Copy link

sonarqubecloud bot commented Jul 9, 2024

Copy link
Contributor

@svetoslav-nikol0v svetoslav-nikol0v left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@0xivanov 0xivanov left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants