Skip to content

Commit

Permalink
add additional test
Browse files Browse the repository at this point in the history
Signed-off-by: georgi-l95 <glazarov95@gmail.com>

apply spotless

Signed-off-by: georgi-l95 <glazarov95@gmail.com>
  • Loading branch information
georgi-l95 committed Nov 8, 2023
1 parent e6dc241 commit 12996b8
Showing 1 changed file with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
import com.hederahashgraph.api.proto.java.Key;
import com.hederahashgraph.api.proto.java.KeyList;
import com.hederahashgraph.api.proto.java.ThresholdKey;
import com.hederahashgraph.api.proto.java.Timestamp;
import com.hederahashgraph.api.proto.java.TokenID;
import com.hederahashgraph.api.proto.java.TokenSupplyType;
import com.hederahashgraph.api.proto.java.TokenTransferList;
Expand Down Expand Up @@ -191,6 +192,7 @@ public List<HapiSpec> getSpecsInSuite() {
noStakePeriodStartIfNotStakingToNode(),
/* -- HTS auto creates -- */
canAutoCreateWithFungibleTokenTransfersToAlias(),
canAutoCreateWithNftTransferToEvmAddress(),
multipleTokenTransfersSucceed(),
canAutoCreateWithNftTransfersToAlias(),
autoCreateWithNftFallBackFeeFails(),
Expand Down Expand Up @@ -454,6 +456,50 @@ private HapiSpec canAutoCreateWithNftTransfersToAlias() {
}

@HapiTest
private HapiSpec canAutoCreateWithNftTransferToEvmAddress() {
final var civilianBal = 10 * ONE_HBAR;
final var nftTransfer = "multiNftTransfer";
final AtomicReference<Timestamp> parentConsTime = new AtomicReference<>();

return defaultHapiSpec("canAutoCreateWithNftTransferToEvmAddress")
.given(
newKeyNamed(MULTI_KEY),
newKeyNamed(VALID_ALIAS).shape(SECP_256K1_SHAPE),
cryptoCreate(TOKEN_TREASURY).balance(ONE_HUNDRED_HBARS).maxAutomaticTokenAssociations(2),
tokenCreate(NFT_INFINITE_SUPPLY_TOKEN)
.tokenType(TokenType.NON_FUNGIBLE_UNIQUE)
.adminKey(MULTI_KEY)
.supplyKey(MULTI_KEY)
.supplyType(TokenSupplyType.INFINITE)
.initialSupply(0)
.treasury(TOKEN_TREASURY)
.via(NFT_CREATE),
mintToken(NFT_INFINITE_SUPPLY_TOKEN, List.of(ByteString.copyFromUtf8("a"))),
cryptoCreate(CIVILIAN).balance(civilianBal))
.when(
tokenAssociate(CIVILIAN, NFT_INFINITE_SUPPLY_TOKEN),
cryptoTransfer(
movingUnique(NFT_INFINITE_SUPPLY_TOKEN, 1L).between(TOKEN_TREASURY, CIVILIAN)),
getAccountInfo(CIVILIAN)
.hasToken(relationshipWith(NFT_INFINITE_SUPPLY_TOKEN))
.has(accountWith().balance(civilianBal)),
cryptoTransfer(movingUnique(NFT_INFINITE_SUPPLY_TOKEN, 1)
.between(CIVILIAN, VALID_ALIAS))
.via(nftTransfer)
.payingWith(CIVILIAN)
.signedBy(CIVILIAN, VALID_ALIAS))
.then(
getTxnRecord(nftTransfer)
.exposingTo(record -> parentConsTime.set(record.getConsensusTimestamp()))
.andAllChildRecords()
.hasNonStakingChildRecordCount(1)
.logged(),
sourcing(() -> childRecordsCheck(
nftTransfer,
SUCCESS,
recordWith().status(SUCCESS).consensusTimeImpliedByNonce(parentConsTime.get(), -1))));
}

private HapiSpec multipleTokenTransfersSucceed() {
final var initialTokenSupply = 1000;
final var multiTokenXfer = "multiTokenXfer";
Expand Down

0 comments on commit 12996b8

Please sign in to comment.