Skip to content

Commit

Permalink
test: Token Claim Airdrop with receiverSigReq test (#15279)
Browse files Browse the repository at this point in the history
Signed-off-by: ibankov <[email protected]>
  • Loading branch information
ibankov authored and rbarkerSL committed Sep 5, 2024
1 parent b03f5e6 commit 1dd9779
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1603,14 +1603,10 @@ final Stream<DynamicTest> transferInvalidFungibleToken() {
return hapiTest(
cryptoCreate(ALICE).balance(ONE_HUNDRED_HBARS),
cryptoCreate(BOB).balance(ONE_HUNDRED_HBARS),
withOpContext((spec, opLog) -> {
spec.registry()
.saveTokenId(
FUNGIBLE_TOKEN_A,
TokenID.newBuilder()
.setTokenNum(5555555L)
.build());
}),
withOpContext((spec, opLog) -> spec.registry()
.saveTokenId(
FUNGIBLE_TOKEN_A,
TokenID.newBuilder().setTokenNum(5555555L).build())),
tokenAirdrop(moving(50L, FUNGIBLE_TOKEN_A).between(ALICE, BOB))
.signedByPayerAnd(ALICE)
.hasKnownStatus(INVALID_TOKEN_ID));
Expand All @@ -1635,14 +1631,10 @@ final Stream<DynamicTest> transferInvalidNFT() {
.name(NON_FUNGIBLE_TOKEN_A)
.supplyKey(nftKey),
tokenAssociate(ALICE, NON_FUNGIBLE_TOKEN_A),
withOpContext((spec, opLog) -> {
spec.registry()
.saveTokenId(
NON_FUNGIBLE_TOKEN_A,
TokenID.newBuilder()
.setTokenNum(5555555L)
.build());
}),
withOpContext((spec, opLog) -> spec.registry()
.saveTokenId(
NON_FUNGIBLE_TOKEN_A,
TokenID.newBuilder().setTokenNum(5555555L).build())),
tokenAirdrop(TokenMovement.movingUnique(NON_FUNGIBLE_TOKEN_A, 1L)
.between(ALICE, BOB))
.signedByPayerAnd(ALICE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,34 @@ final Stream<DynamicTest> claimTokenAirdropSenderAccountPays() {
getAccountBalance(RECEIVER).hasTokenBalance(FUNGIBLE_TOKEN, 1)));
}

@HapiTest
@DisplayName("both associated and not associated FTs and receiver sig required")
final Stream<DynamicTest> withTwoTokensAndReceiverSigReq() {
final String ALICE = "ALICE";
final String BOB = "BOB";
return hapiTest(flattened(
cryptoCreate(ALICE).balance(ONE_HUNDRED_HBARS),
cryptoCreate(BOB)
.balance(ONE_HUNDRED_HBARS)
.maxAutomaticTokenAssociations(0)
.receiverSigRequired(true),
createFT(FUNGIBLE_TOKEN_1, ALICE, 1000L),
createFT(FUNGIBLE_TOKEN_2, ALICE, 1000L),
tokenAssociate(BOB, FUNGIBLE_TOKEN_1),
tokenAirdrop(
moving(10, FUNGIBLE_TOKEN_1).between(ALICE, BOB),
moving(10, FUNGIBLE_TOKEN_2).between(ALICE, BOB))
.payingWith(ALICE),
getAccountBalance(BOB).hasTokenBalance(FUNGIBLE_TOKEN_1, 0),
getAccountBalance(BOB).hasTokenBalance(FUNGIBLE_TOKEN_2, 0),
tokenClaimAirdrop(
pendingAirdrop(ALICE, BOB, FUNGIBLE_TOKEN_1),
pendingAirdrop(ALICE, BOB, FUNGIBLE_TOKEN_2))
.payingWith(BOB),
getAccountBalance(BOB).hasTokenBalance(FUNGIBLE_TOKEN_1, 10),
getAccountBalance(BOB).hasTokenBalance(FUNGIBLE_TOKEN_2, 10)));
}

@HapiTest
@DisplayName("multiple FT airdrops to same receiver")
final Stream<DynamicTest> multipleFtAirdropsSameReceiver() {
Expand Down

0 comments on commit 1dd9779

Please sign in to comment.