use of com.hedera.services.ledger.properties.AccountProperty in project hedera-services by hashgraph.
the class HederaTokenStoreTest method setup.
@BeforeEach
void setup() {
token = mock(MerkleToken.class);
given(token.expiry()).willReturn(expiry);
given(token.symbol()).willReturn(symbol);
given(token.hasAutoRenewAccount()).willReturn(true);
given(token.adminKey()).willReturn(Optional.of(TOKEN_ADMIN_KT.asJKeyUnchecked()));
given(token.name()).willReturn(name);
given(token.hasAdminKey()).willReturn(true);
given(token.hasFeeScheduleKey()).willReturn(true);
given(token.treasury()).willReturn(EntityId.fromGrpcAccountId(treasury));
given(token.tokenType()).willReturn(TokenType.FUNGIBLE_COMMON);
given(token.decimals()).willReturn(2);
nonfungibleToken = mock(MerkleToken.class);
given(nonfungibleToken.hasAdminKey()).willReturn(true);
given(nonfungibleToken.tokenType()).willReturn(TokenType.NON_FUNGIBLE_UNIQUE);
ids = mock(EntityIdSource.class);
given(ids.newTokenId(sponsor)).willReturn(created);
hederaLedger = mock(HederaLedger.class);
nftsLedger = (TransactionalLedger<NftId, NftProperty, MerkleUniqueToken>) mock(TransactionalLedger.class);
given(nftsLedger.get(aNft, NftProperty.OWNER)).willReturn(EntityId.fromGrpcAccountId(sponsor));
given(nftsLedger.get(tNft, NftProperty.OWNER)).willReturn(EntityId.fromGrpcAccountId(primaryTreasury));
given(nftsLedger.exists(aNft)).willReturn(true);
given(nftsLedger.exists(tNft)).willReturn(true);
accountsLedger = (TransactionalLedger<AccountID, AccountProperty, MerkleAccount>) mock(TransactionalLedger.class);
given(accountsLedger.exists(treasury)).willReturn(true);
given(accountsLedger.exists(anotherFeeCollector)).willReturn(true);
given(accountsLedger.exists(autoRenewAccount)).willReturn(true);
given(accountsLedger.exists(newAutoRenewAccount)).willReturn(true);
given(accountsLedger.exists(primaryTreasury)).willReturn(true);
given(accountsLedger.exists(sponsor)).willReturn(true);
given(accountsLedger.exists(counterparty)).willReturn(true);
given(accountsLedger.get(treasury, IS_DELETED)).willReturn(false);
given(accountsLedger.get(autoRenewAccount, IS_DELETED)).willReturn(false);
given(accountsLedger.get(newAutoRenewAccount, IS_DELETED)).willReturn(false);
given(accountsLedger.get(sponsor, IS_DELETED)).willReturn(false);
given(accountsLedger.get(counterparty, IS_DELETED)).willReturn(false);
given(accountsLedger.get(primaryTreasury, IS_DELETED)).willReturn(false);
backingTokens = mock(BackingTokens.class);
given(backingTokens.contains(misc)).willReturn(true);
given(backingTokens.contains(nonfungible)).willReturn(true);
given(backingTokens.getRef(created)).willReturn(token);
given(backingTokens.getImmutableRef(created)).willReturn(token);
given(backingTokens.getRef(misc)).willReturn(token);
given(backingTokens.getImmutableRef(misc)).willReturn(token);
given(backingTokens.getRef(nonfungible)).willReturn(nonfungibleToken);
given(backingTokens.getImmutableRef(tNft.tokenId())).willReturn(nonfungibleToken);
given(backingTokens.getImmutableRef(tNft.tokenId()).treasury()).willReturn(EntityId.fromGrpcAccountId(primaryTreasury));
given(backingTokens.idSet()).willReturn(Set.of(created));
tokenRelsLedger = mock(TransactionalLedger.class);
given(tokenRelsLedger.exists(sponsorMisc)).willReturn(true);
given(tokenRelsLedger.exists(treasuryNft)).willReturn(true);
given(tokenRelsLedger.exists(sponsorNft)).willReturn(true);
given(tokenRelsLedger.exists(counterpartyNft)).willReturn(true);
given(tokenRelsLedger.get(sponsorMisc, TOKEN_BALANCE)).willReturn(sponsorBalance);
given(tokenRelsLedger.get(sponsorMisc, IS_FROZEN)).willReturn(false);
given(tokenRelsLedger.get(sponsorMisc, IS_KYC_GRANTED)).willReturn(true);
given(tokenRelsLedger.exists(treasuryMisc)).willReturn(true);
given(tokenRelsLedger.exists(anotherFeeCollectorMisc)).willReturn(true);
given(tokenRelsLedger.get(treasuryMisc, TOKEN_BALANCE)).willReturn(treasuryBalance);
given(tokenRelsLedger.get(treasuryMisc, IS_FROZEN)).willReturn(false);
given(tokenRelsLedger.get(treasuryMisc, IS_KYC_GRANTED)).willReturn(true);
given(tokenRelsLedger.get(treasuryNft, TOKEN_BALANCE)).willReturn(123L);
given(tokenRelsLedger.get(treasuryNft, IS_FROZEN)).willReturn(false);
given(tokenRelsLedger.get(treasuryNft, IS_KYC_GRANTED)).willReturn(true);
given(tokenRelsLedger.get(sponsorNft, TOKEN_BALANCE)).willReturn(123L);
given(tokenRelsLedger.get(sponsorNft, IS_FROZEN)).willReturn(false);
given(tokenRelsLedger.get(sponsorNft, IS_KYC_GRANTED)).willReturn(true);
given(tokenRelsLedger.get(counterpartyNft, TOKEN_BALANCE)).willReturn(123L);
given(tokenRelsLedger.get(counterpartyNft, IS_FROZEN)).willReturn(false);
given(tokenRelsLedger.get(counterpartyNft, IS_KYC_GRANTED)).willReturn(true);
given(tokenRelsLedger.get(newTreasuryNft, TOKEN_BALANCE)).willReturn(1L);
properties = mock(GlobalDynamicProperties.class);
given(properties.maxTokensPerAccount()).willReturn(MAX_TOKENS_PER_ACCOUNT);
given(properties.maxTokenSymbolUtf8Bytes()).willReturn(MAX_TOKEN_SYMBOL_UTF8_BYTES);
given(properties.maxTokenNameUtf8Bytes()).willReturn(MAX_TOKEN_NAME_UTF8_BYTES);
given(properties.maxCustomFeesAllowed()).willReturn(maxCustomFees);
sideEffectsTracker = new SideEffectsTracker();
subject = new HederaTokenStore(ids, TEST_VALIDATOR, sideEffectsTracker, properties, tokenRelsLedger, nftsLedger, backingTokens);
subject.setAccountsLedger(accountsLedger);
subject.setHederaLedger(hederaLedger);
subject.knownTreasuries.put(treasury, new HashSet<>() {
{
add(misc);
}
});
}
Aggregations