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

Add test to confirm preceding child record for HTS transfer #9735

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading