hashgraph / hedera-services

Crypto, token, consensus, file, and smart contract services for the Hedera public ledger
Apache License 2.0
315 stars 138 forks source link

HIP-904: Additional e2e tests scenarios #15596

Open stoyanov-st opened 2 months ago

stoyanov-st commented 2 months ago
### Tasks
- [ ] https://github.com/hashgraph/hedera-services/issues/16240
- [ ] https://github.com/hashgraph/hedera-services/issues/16241
- [ ] https://github.com/hashgraph/hedera-services/issues/16242
- [ ] https://github.com/hashgraph/hedera-services/issues/16243
- [ ] https://github.com/hashgraph/hedera-services/issues/16244
- [ ] https://github.com/hashgraph/hedera-services/issues/16245
- [ ] https://github.com/hashgraph/hedera-services/issues/16246
- [ ] https://github.com/hashgraph/hedera-services/issues/16248
- [ ] https://github.com/hashgraph/hedera-services/issues/16249
- [ ] https://github.com/hashgraph/hedera-services/issues/16250
- [ ] https://github.com/hashgraph/hedera-services/issues/16251
- [ ] https://github.com/hashgraph/hedera-services/issues/16252
- [ ] https://github.com/hashgraph/hedera-services/issues/16253
- [ ] https://github.com/hashgraph/hedera-services/issues/16254
- [ ] https://github.com/hashgraph/hedera-services/issues/16255
- [ ] https://github.com/hashgraph/hedera-services/issues/16256
- [ ] https://github.com/hashgraph/hedera-services/issues/16257
- [ ] https://github.com/hashgraph/hedera-services/issues/16258
- [ ] https://github.com/hashgraph/hedera-services/issues/16259
- [ ] https://github.com/hashgraph/hedera-services/issues/16261
### Tasks
- [ ] https://github.com/hashgraph/hedera-services/issues/16262
- [ ] https://github.com/hashgraph/hedera-services/issues/16263
- [ ] https://github.com/hashgraph/hedera-services/issues/16264
- [ ] https://github.com/hashgraph/hedera-services/issues/16265
- [ ] https://github.com/hashgraph/hedera-services/issues/16266
- [ ] https://github.com/hashgraph/hedera-services/issues/16267
- [ ] https://github.com/hashgraph/hedera-services/issues/16268
- [ ] https://github.com/hashgraph/hedera-services/issues/16269
- [ ] https://github.com/hashgraph/hedera-services/issues/16270
- [ ] https://github.com/hashgraph/hedera-services/issues/16272
- [ ] https://github.com/hashgraph/hedera-services/issues/16273
- [ ] https://github.com/hashgraph/hedera-services/issues/16274
- [ ] https://github.com/hashgraph/hedera-services/issues/16275
- [ ] https://github.com/hashgraph/hedera-services/issues/16276
- [ ] https://github.com/hashgraph/hedera-services/issues/16277
- [ ] https://github.com/hashgraph/hedera-services/issues/16278
- [ ] https://github.com/hashgraph/hedera-services/issues/16279
- [ ] https://github.com/hashgraph/hedera-services/issues/16280
- [ ] https://github.com/hashgraph/hedera-services/issues/16281
- [ ] https://github.com/hashgraph/hedera-services/issues/16282
- [ ] https://github.com/hashgraph/hedera-services/issues/16283
- [ ] https://github.com/hashgraph/hedera-services/issues/16284
- [ ] https://github.com/hashgraph/hedera-services/issues/16285
- [ ] https://github.com/hashgraph/hedera-services/issues/16286
- [ ] https://github.com/hashgraph/hedera-services/issues/16287
- [ ] https://github.com/hashgraph/hedera-services/issues/16288
- [ ] https://github.com/hashgraph/hedera-services/issues/16289
- [ ] https://github.com/hashgraph/hedera-services/issues/16290
- [ ] https://github.com/hashgraph/hedera-services/issues/16291
- [ ] https://github.com/hashgraph/hedera-services/issues/16292
- [ ] https://github.com/hashgraph/hedera-services/issues/16293
- [ ] https://github.com/hashgraph/hedera-services/issues/16294
- [ ] https://github.com/hashgraph/hedera-services/issues/16295
- [ ] https://github.com/hashgraph/hedera-services/issues/16296
- [ ] https://github.com/hashgraph/hedera-services/issues/16345
- [ ] https://github.com/hashgraph/hedera-services/issues/16346
- [ ] https://github.com/hashgraph/hedera-services/issues/16347
- [ ] https://github.com/hashgraph/hedera-services/issues/16349
stoyanov-st commented 1 week ago

Test Cases for Airdrop to Contract

Receiver IS Associated

Number Test Description Test Details Expected Result
AIRDROP_TO_CONTRACT_01 EOA Airdrops a token to a Contract who is associated to the token The token should be transferred to the contract without creating a pending airdrop. No association fee or rent should be paid. The contract’s automatic_association field should be incremented.
AIRDROP_TO_CONTRACT_02 EOA airdrops multiple tokens to a contract that is associated to all of them The tokens should be transferred to the contract account. No association fees should be paid.
AIRDROP_TO_CONTRACT_03 Airdrop multiple tokens to a contract that is associated to SOME of them when the contract has free auto association slots.
Case 1: associated only to FT
Case 2: associated only to NFT
All tokens should be transferred to the contract account. The contract should get associated to the not associated tokens. The sender should pay the association fees for the new associations.
AIRDROP_TO_CONTRACT_04 Given a contract with NO free association slots and a balance of 1 FT A. When the sender airdrops 1 FT A + 1 FT B, then the contract should have 1 FT A transferred to their balance and 1 pending airdrop for 1 FT B. The contract should receive the tokens it is associated to and a pending airdrop for the tokens it is not associated to. The sender should pre-pay for the association of the not associated tokens.
AIRDROP_TO_CONTRACT_05 Sender airdrops a token with a custom fee to be paid by the receiver to the fee collector account for the token fee when the fee collector account is a contract. The token should be transferred to the receiver (the contract) and no custom fee should be paid.
AIRDROP_TO_CONTRACT_06 Sender airdrops a token with a custom fee to be paid by the receiver to the fee collector account of another token fee when all fee collector accounts are exempt. The fee collector account (receiver) is a contract. The token should be transferred to the receiver and no custom fee should be paid.
AIRDROP_TO_CONTRACT_07 Sender airdrops a token with a custom fee to be paid by the receiver to the token treasury account, when this account is a contract. The token should be transferred to the receiver and no custom fee should be paid.

Receiver NOT Associated

Number Test Description Test Details Expected Result
AIRDROP_TO_CONTRACT_09 EOA account airdrops a single token to a contract with free association slots
for FT and NFT
The contract gets associated to the token and receives them. The sender pays the association fee.
AIRDROP_TO_CONTRACT_10 EOA account airdrops a single token to a contract, deployed via CREATE2 on a hollow account address alias (the contract won’t have any free auto association slots)
for FT and NFT
TokenAirdropTransaction should succeed with PendingAirdrop.
AIRDROP_TO_CONTRACT_11 EOA account airdrops a single token to a contract with maxAutoAssociations = 0
for FT and NFT
TokenAirdropTransaction should succeed with PendingAirdrop.
AIRDROP_TO_CONTRACT_13 EOA account airdrops a single token to a contract with NO free association slots (maxAutoAssociations = 1 and 1 auto association is already used)
for FT and NFT
TokenAirdropTransaction should succeed with PendingAirdrop.
AIRDROP_TO_CONTRACT_14 EOA account airdrops multiple tokens to a contract with free auto association slots All tokens should be transferred to the contract. The sender should pay for the association fees.
AIRDROP_TO_CONTRACT_15 EOA account airdrops multiple tokens to a contract with NO free auto association slots TokenAirdropTransaction should succeed with PendingAirdrop.
AIRDROP_TO_CONTRACT_20 Multiple EOA accounts airdrop tokens to multiple contracts (up to 10):
- Multiple senders to a single contract
- Multiple senders to multiple contracts
THE CONTRACTS NEED TO HAVE FREE AUTO ASSOCIATION SLOTS!
The transaction payer should pay for each association. If 2 senders send the same token to 1 receiver, only 1 association fee should be paid.
AIRDROP_TO_CONTRACT_21 EOA airdrops up to 10 tokens:
- to the same contract
- to multiple contracts
THE CONTRACTS NEED TO HAVE FREE AUTO ASSOCIATION SLOTS!
TokenAirdropTransaction is successful and the transaction payer should pay 1 token association for each different receiver.

Receiver NOT Associated

Number Test Description Test Details Expected Result
AIRDROP_TO_CONTRACT_28 Airdrop a token to a contract that is not associated to the token and HAS free autoAssociation slots. TokenAirdropTransaction is successful and the tokens should be successfully associated and transferred to the contract. The sender should pay association fee + trx fee + any custom fees (if any). receiver’s automatic_association field should be incremented.

Negative cases

Receiver IS Associated

Number Test Description Test Details Expected Result
AIRDROP_TO_CONTRACT_30 Airdrop a token to a contract that is associated to the token and is frozen for it TokenAirdropTransaction should fail with error message: ACCOUNT_FROZEN_FOR_TOKEN
AIRDROP_TO_CONTRACT_31 Given a contract has a pending airdrop when the sender signs a cryptoTransfer to the contract for the airdropped token then the airdrop should remain in pending and the cryptoTransfer should fail with error message TOKEN_NOT_ASSOCIATED_TO_ACCOUNT Alice is the treasury account for FT A. 1. Alice sings a tokenAirdropTransaction for 1 FT A to Contract A. 2. Alice signs a cryptoTransfer for 1 FT A to Contract A. 1. Successful tokenAirdropTransaction. Alice should pay 1 association fee and airdrop transaction fee. Contract A = 1 pending airdrop for 1 FT A. 2. CryptoTransfer transaction should fail with error message TOKEN_NOT_ASSOCIATED_TO_ACCOUNT. Contract A = 1 pending airdrop for 1 FT A.

Receiver NOT Associated

Number Test Description Test Details Expected Result
AIRDROP_TO_CONTRACT_32 CryptoTransfer to a contract not associated to the token and with no auto association slots left should result in a failing cryptoTransfer and no airdrops should be created. The cryptoTransfer should fail with an error message: TOKEN_NOT_ASSOCIATED_TO_ACCOUNT
AIRDROP_TO_CONTRACT_33 CryptoTransfer to a contract with no Admin key
AIRDROP_TO_CONTRACT_34 1. TokenAirdropTransaction to a hollow account with maxAutoAssociations ≠ -1 2. CREATE2 a contract on an address with a hollow account with maxAutoAssociations ≠ -1 1. Pending airdrop. 2. Contract is deployed.
stoyanov-st commented 1 week ago

Airdrop Test Cases

Receiver IS associated

Number Test Description Test Details Expected Result
AIRDROP_FROM_CONTRACT_01 Contract Airdrops a token to a receiver who is associated to the token and has receiverSigRequired=false The token should be transferred to the receiver without creating a pending airdrop. No association fee or rent should be paid. Receiver’s automatic_association field should be incremented.
AIRDROP_FROM_CONTRACT_02 Contract airdrops a token with a custom fee (that should be paid by the sender) to a receiver who is associated to the token and has receiverSigRequired=false. When the sender has enough balance to pay the custom fee. The token should be transferred to the receiver without creating a pending airdrop. No association fee or rent should be paid. Sender should pay the custom fees. Receiver’s automatic_association field should be incremented.
AIRDROP_FROM_CONTRACT_03 Contract airdrops multiple tokens to a receiver who is associated to all of them The tokens should be transferred to the receiver account. No association fees should be paid.
AIRDROP_FROM_CONTRACT_04 Contract account airdrops a single token to an ED25519 account with free association slots for FT and NFT The receiver gets associated to the token and receives them. The contract pays the association fee.
AIRDROP_FROM_CONTRACT_05 Contract account airdrops a single token to an ECDSA account with free association slots for FT and NFT The receiver gets associated to the token and receives them. The contract pays the association fee.
AIRDROP_FROM_CONTRACT_06 Contract account airdrops a single token to an account alias with free association slots for FT and NFT The receiver gets associated to the token and receives them. The contract pays the association fee.
AIRDROP_FROM_CONTRACT_07 Contract airdrops multiple tokens when the receiver has maxAutoAssociations = -1 All tokens should be transferred to the receiver. The sender should pay for the association fees.
AIRDROP_FROM_CONTRACT_08 Contract airdrops multiple tokens when the receiver contract has maxAutoAssociations = -1 All tokens should be transferred to the receiver. The sender should pay for the association fees.
AIRDROP_FROM_CONTRACT_09 Contract airdrops multiple tokens when the receiver has NO free auto association slots The receiver should have a pending airdrop with all tokens. The sender should pre-pay for each of the association fees.
AIRDROP_FROM_CONTRACT_11 Contract airdrops a FT/Non Fungible token to an address with no account on it should result in a hollow account with a pending airdrop A hollow account should be created and the token should be transferred to the hollow account. The sender should pre-pay for the association fee.
AIRDROP_FROM_CONTRACT_12 Contract airdrops a token to an account, then the receiver claims the airdrop, then the sender airdrops the same token again should result in a cryptoTransfer. Alice is the treasury account for FT A. Contract A has a balance of 10 FT A. 1. Contract A signs a tokenAirdropTransaction for 5 FT A to Bob. 2. Bob signs a tokenClaimAirdrop transaction. 3. Contract A signs a tokenAirdropTransaction for 3 FT A to Bob. 1. Successful tokenAirdropTransaction. Contract A should pay 1 association fee and airdrop transaction fee. Bob = 1 pending airdrop for 5 FT A. 2. Successful tokenClaimAirdrop transaction. Bob = 5 FT A balance Bob should pay claim airdrop transaction fee Contract A = 5 FT A balance 3. Successful tokenAirdrop transaction. Bob = 8 FT A balance Contract A = 2 FT A balance
AIRDROP_FROM_CONTRACT_13 Given a Contract sender has a balance of 1 FT A and signs multiple tokenAirdropTransactions for 1 FT A to the same receiver then this should result in a single pending airdrop with the amount added up. For each tokenAirdropTransaction the sender should pay an association fee.
AIRDROP_FROM_CONTRACT_14 Contract airdrops a token to a receiver and while in pending manually associate the receiver to the token then the Contract airdrops the same token again. 1. CONTRACT A signs a tokenAirdropTransaction for 1 FT A to Bob, 2. Bob manually associates to FT A, 3. CONTRACT A signs a tokenAirdropTransaction for 1 FT A to Bob 1. Successful tokenAirdropTransaction. CONTRACT A should pay 1 association fee and airdrop transaction fee. Bob = 1 pending airdrop for 1 FT A. 2. Successful association. Bob pays 1 association fee 3. Successful transaction. Bob = 1 pending airdrop Bob = 1 FT A balance 3. Q: what is the expected result?
AIRDROP_FROM_CONTRACT_15 Multiple Contracts airdrop tokens to multiple EOAs The transaction payer should pay for each association. If 2 senders send the same token to 1 receiver, only 1 association fee should be paid.
AIRDROP_FROM_CONTRACT_16 Contract airdrops up to 10 tokens to the same receiver or multiple receivers TokenAirdropTransaction is successful, and the transaction payer should pay 1 token association for each different receiver.
AIRDROP_FROM_CONTRACT_17 Contract with allowance and not balance airdrops a token (Case 1: FT, Case 2: NFT) Alice is the token treasury account for FT A and gives Contract A allowance for 10 FT A. Contract A has 0 balance and 10 allowance for FT A. Contract A signs a tokenAirdropTransaction for 5 FT A to Carol. TokenAirdropTransaction is successful. Contract A pays 1 association fee. Contract A = 0 FT A balance and 5 FT A allowance. Carol = 1 pending airdrop for 5 FT A.
AIRDROP_FROM_CONTRACT_18 Contract with enough allowance and enough balance airdrops a token Alice is the token treasury account for FT A and gives Contract A allowance for 5 FT A. Contract A = 5 balance of FT A and 5 allowance for FT A. Contract A signs a tokenAirdropTransaction for 5 FT A to Carol. TokenAirdropTransaction is successful. Contract A pays 1 association fee. Contract A = 5 FT A balance and 5 FT A allowance. Carol = 1 pending airdrop for 5 FT A.
AIRDROP_FROM_CONTRACT_19 Contract with enough allowance + balance airdrops a token Alice is the treasury for FT A. Contract A has 2 FT A balance and 3 FT A allowance. 1. Contract A signs a tokenAirdropTransaction to Carol for 5 FT A. 1. Successful tokenAirdropTransaction. Carol should have 1 pending airdrop for 5 FT A. Q: is this a successful transaction? This should behave in the same way as for CryptoTransfer.
AIRDROP_FROM_CONTRACT_20 Both Contract owner and Contract spender airdrop the same token to the same receiver Contract A has 5 FT A balance. Contract A gives Contract B allowance for 5 FT A. Contract B has 0 FT A balance and 5 FT A allowance. 1. Contract A signs a tokenAirdropTransaction for 5 FT A to Carol. 2. Contract B signs a tokenAirdropTransaction for 5 FT A to Carol. 1. Successful tokenAirdropTransaction. Contract A pays 1 association fee. Carol has 1 pending airdrop for 5 FT A. 2. Successful tokenAirdropTransaction. Contract B pays 1 association fee. Carol has 2 pending airdrops for 5 FT A each.
AIRDROP_FROM_CONTRACT_21 Contract Spender airdrops a token for which he has only allowance, while the airdrop is in the pending state the allowance for the spender is removed Alice has a balance of 5 FT and gives Contract A allowance for 5 FT A. 1. Contract A signs a tokenAirdropTransaction for 5 FT A to Carol. 2. Alice removes Contract A’s allowance for FT A. 1. Successful tokenAirdropTransaction. Contract A should pay 1 association fee and airdrop transaction fee. Carol = 1 pending airdrop for 5 FT A. 2. Allowance removed. Carol = 1 pending airdrop for 5 FT A.
AIRDROP_FROM_CONTRACT_22 Contract Self-Destruction while pending

Negative Tests

Test Description Expected Result Expected Error Messages
AIRDROP_FROM_CONTRACT_23 Contract airdrops a token with a custom fee (to be paid by the sender) to an EOA receiver who is associated to the token and has receiverSigRequired=false, but the sender has insufficient balance to pay the custom fee. TokenAirdropTransaction should fail with error message
AIRDROP_FROM_CONTRACT_24 Contract airdrops multiple duplicated NFT tokens to an account that is associated with the tokens Transaction should fail with error message PENDING_NFT_AIRDROP_ALREADY_EXISTS
AIRDROP_FROM_CONTRACT_25 Given a Contract sender airdrops maxLong of a token when the sender airdrops the same token again to the same receiver TokenAirdropTransaction should fail with error message
AIRDROP_FROM_CONTRACT_26 Contract airdrops a token to itself TBD
AIRDROP_FROM_CONTRACT_27 Contract account airdrops a token and while pending attempts to delete/self-destruct the account. TBD

Allowance Tests

Test Description Expected Result Expected Error Messages
AIRDROP_FROM_CONTRACT_28 A sender signs a tokenAirdropTransaction when they do not have enough allowance for the token. TokenAirdropTransaction should fail with error message
AIRDROP_FROM_CONTRACT_29 Sender has allowance from the receiver and no balance and sends an airdrop to the receiver. Successful tokenAirdropTransaction for both the sender and receiver.
AIRDROP_FROM_CONTRACT_30 Exceed max airdrops in pending state The next airdrop should fail with error message
AIRDROP_FROM_CONTRACT_31 Spender has allowance greater than owner balance and attempts to airdrop more tokens than the owner balance TokenAirdropTransaction should fail with error message INSUFFICIENT_TOKEN_BALANCE
AIRDROP_FROM_CONTRACT_32 Sender attempts to airdrop an NFT that is not approved Transaction should fail with error message SPENDER_DOES_NOT_HAVE_ALLOWANCE