Skip to content

Commit

Permalink
test: fix test order
Browse files Browse the repository at this point in the history
Signed-off-by: Stanimir Stoyanov <stanimir.stoyanov@limechain.tech>
  • Loading branch information
stoyanov-st committed Oct 22, 2024
1 parent 016e890 commit a6a3a82
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.esaulpaugh.headlong.abi.Address;
import com.hedera.services.bdd.junit.HapiTest;
import com.hedera.services.bdd.junit.HapiTestLifecycle;
import com.hedera.services.bdd.junit.OrderedInIsolation;
import com.hedera.services.bdd.junit.support.TestLifecycle;
import com.hedera.services.bdd.spec.HapiSpec;
import com.hedera.services.bdd.spec.SpecOperation;
Expand All @@ -54,11 +55,13 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.DynamicTest;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Tag;

@Tag(SMART_CONTRACT)
@HapiTestLifecycle
class TokenClaimAirdropSystemContract {
@OrderedInIsolation
class TokenClaimAirdropSystemContractTest {

@Contract(contract = "ClaimAirdrop", creationGas = 1_000_000L)
static SpecContract claimAirdrop;
Expand All @@ -81,6 +84,7 @@ public static void setUp(final @NonNull TestLifecycle lifecycle) {
token.treasury().transferUnitsTo(sender, 1000, token));
}

@Order(0)
@HapiTest
@DisplayName("Can claim 1 fungible airdrop")
public Stream<DynamicTest> claimAirdrop() {
Expand All @@ -101,6 +105,7 @@ public Stream<DynamicTest> claimAirdrop() {
receiver.getBalance().andAssert(balance -> balance.hasTokenBalance(token.name(), 10)));
}

@Order(1)
@HapiTest
@DisplayName("Can claim 1 nft airdrop")
public Stream<DynamicTest> claimNftAirdrop(@NonFungibleToken(numPreMints = 1) final SpecNonFungibleToken nft) {
Expand All @@ -123,6 +128,7 @@ public Stream<DynamicTest> claimNftAirdrop(@NonFungibleToken(numPreMints = 1) fi
receiver.getBalance().andAssert(balance -> balance.hasTokenBalance(nft.name(), 1)));
}

@Order(2)
@HapiTest
@DisplayName("Can claim 10 fungible airdrops")
public Stream<DynamicTest> claim10Airdrops(
Expand Down Expand Up @@ -161,6 +167,7 @@ public Stream<DynamicTest> claim10Airdrops(
}));
}

@Order(3)
@HapiTest
@DisplayName("Can claim 3 fungible airdrops")
public Stream<DynamicTest> claim3Airdrops(
Expand All @@ -185,6 +192,7 @@ public Stream<DynamicTest> claim3Airdrops(
}));
}

@Order(4)
@HapiTest
@DisplayName("Fails to claim 11 pending airdrops")
public Stream<DynamicTest> failToClaim11Airdrops(
Expand Down Expand Up @@ -226,6 +234,7 @@ public Stream<DynamicTest> failToClaim11Airdrops(
}));
}

@Order(5)
@HapiTest
@DisplayName("Fails to claim pending airdrop with invalid token")
public Stream<DynamicTest> failToClaim1AirdropWithInvalidToken() {
Expand All @@ -236,6 +245,7 @@ public Stream<DynamicTest> failToClaim1AirdropWithInvalidToken() {
.andAssert(txn -> txn.hasKnownStatus(CONTRACT_REVERT_EXECUTED)));
}

@Order(6)
@HapiTest
@DisplayName("Fails to claim pending airdrop with invalid sender")
public Stream<DynamicTest> failToClaim1AirdropWithInvalidSender() {
Expand All @@ -246,8 +256,9 @@ public Stream<DynamicTest> failToClaim1AirdropWithInvalidSender() {
.andAssert(txn -> txn.hasKnownStatus(CONTRACT_REVERT_EXECUTED)));
}

@Order(7)
@HapiTest
@DisplayName("Fails to claim airdrop without having any pending airdrops")
@DisplayName("Fails to claim airdrop having no pending airdrops")
public Stream<DynamicTest> failToClaimAirdropWhenThereAreNoPending() {
return hapiTest(claimAirdrop
.call("claim", sender, receiver, token)
Expand All @@ -256,6 +267,7 @@ public Stream<DynamicTest> failToClaimAirdropWhenThereAreNoPending() {
.andAssert(txn -> txn.hasKnownStatus(CONTRACT_REVERT_EXECUTED)));
}

@Order(8)
@HapiTest
@DisplayName("Fails to claim pending airdrop with invalid receiver")
public Stream<DynamicTest> failToClaim1AirdropWithInvalidReceiver() {
Expand All @@ -266,16 +278,18 @@ public Stream<DynamicTest> failToClaim1AirdropWithInvalidReceiver() {
.andAssert(txn -> txn.hasKnownStatus(CONTRACT_REVERT_EXECUTED)));
}

@Order(9)
@HapiTest
@DisplayName("Fails to claim nft airdrop with invalid nft")
public Stream<DynamicTest> failToCancel1AirdropWithInvalidNft() {
public Stream<DynamicTest> failToClaim1AirdropWithInvalidNft() {
return hapiTest(claimAirdrop
.call("claimNFTAirdrop", sender, receiver, receiver, 1L)
.payingWith(sender)
.via("claimAirdrop")
.andAssert(txn -> txn.hasKnownStatus(CONTRACT_REVERT_EXECUTED)));
}

@Order(10)
@HapiTest
@DisplayName("Fails to claim nft airdrop with invalid nft serial")
public Stream<DynamicTest> failToClaim1AirdropWithInvalidSerial(@NonFungibleToken final SpecNonFungibleToken nft) {
Expand All @@ -288,6 +302,7 @@ public Stream<DynamicTest> failToClaim1AirdropWithInvalidSerial(@NonFungibleToke
.andAssert(txn -> txn.hasKnownStatus(CONTRACT_REVERT_EXECUTED)));
}

@Order(11)
@HapiTest
private void prepareAirdrops(
@NonNull List<SpecFungibleToken> tokens, @NonNull List<SpecNonFungibleToken> nfts, @NonNull HapiSpec spec) {
Expand Down

0 comments on commit a6a3a82

Please sign in to comment.