Search in sources :

Example 6 with TokenRelationship

use of com.hedera.services.store.models.TokenRelationship in project hedera-services by hashgraph.

the class MintLogicTest method followsUniqueHappyPath.

@Test
void followsUniqueHappyPath() {
    // setup:
    final long curTotal = 99L;
    final long acceptableTotal = 100L;
    treasuryRel = new TokenRelationship(token, treasury);
    givenValidUniqueTxnCtx();
    given(accessor.getTxn()).willReturn(tokenMintTxn);
    given(txnCtx.accessor()).willReturn(accessor);
    given(token.getTreasury()).willReturn(treasury);
    given(store.loadToken(id)).willReturn(token);
    given(token.getId()).willReturn(id);
    given(store.loadTokenRelationship(token, treasury)).willReturn(treasuryRel);
    given(token.getType()).willReturn(TokenType.NON_FUNGIBLE_UNIQUE);
    given(store.currentMintedNfts()).willReturn(curTotal);
    given(validator.isPermissibleTotalNfts(acceptableTotal)).willReturn(true);
    // when:
    subject.mint(token.getId(), txnCtx.accessor().getTxn().getTokenMint().getMetadataCount(), txnCtx.accessor().getTxn().getTokenMint().getAmount(), txnCtx.accessor().getTxn().getTokenMint().getMetadataList(), Instant.now());
    // then:
    verify(token).mint(any(OwnershipTracker.class), eq(treasuryRel), any(List.class), any(RichInstant.class));
    verify(store).commitToken(token);
    verify(store).commitTokenRelationships(List.of(treasuryRel));
    verify(store).commitTrackers(any(OwnershipTracker.class));
    verify(accountStore).commitAccount(any(Account.class));
}
Also used : Account(com.hedera.services.store.models.Account) OwnershipTracker(com.hedera.services.store.models.OwnershipTracker) List(java.util.List) RichInstant(com.hedera.services.state.submerkle.RichInstant) TokenRelationship(com.hedera.services.store.models.TokenRelationship) Test(org.junit.jupiter.api.Test)

Aggregations

TokenRelationship (com.hedera.services.store.models.TokenRelationship)6 Test (org.junit.jupiter.api.Test)5 Account (com.hedera.services.store.models.Account)4 OwnershipTracker (com.hedera.services.store.models.OwnershipTracker)2 Token (com.hedera.services.store.models.Token)2 RichInstant (com.hedera.services.state.submerkle.RichInstant)1 Id (com.hedera.services.store.models.Id)1 NftId (com.hedera.services.store.models.NftId)1 UniqueToken (com.hedera.services.store.models.UniqueToken)1 EntityNumPair.fromNftId (com.hedera.services.utils.EntityNumPair.fromNftId)1 List (java.util.List)1