Search in sources :

Example 6 with MerkleToken

use of com.hedera.services.state.merkle.MerkleToken in project hedera-services by hashgraph.

the class TokenPropertyTest method settersWorks.

@Test
void settersWorks() {
    // given:
    final MerkleToken target = new MerkleToken();
    // and:
    final var totalSupplySetter = TOTAL_SUPPLY.setter();
    final var decimalsSetter = DECIMALS.setter();
    final var adminKeySetter = ADMIN_KEY.setter();
    final var freezeKeySetter = FREEZE_KEY.setter();
    final var kycKeySetter = KYC_KEY.setter();
    final var pauseKeySetter = PAUSE_KEY.setter();
    final var supplyKeySetter = SUPPLY_KEY.setter();
    final var feeScheduleKeySetter = FEE_SCHEDULE_KEY.setter();
    final var wipeKeySetter = WIPE_KEY.setter();
    final var deletedSetter = IS_DELETED.setter();
    final var pausedSetter = IS_PAUSED.setter();
    final var symbolSetter = SYMBOL.setter();
    final var nameSetter = NAME.setter();
    final var treasurySetter = TREASURY.setter();
    final var accountsFrozenByDefaultSetter = ACC_FROZEN_BY_DEFAULT.setter();
    final var expirySetter = EXPIRY.setter();
    final var autoRenewPeriodSetter = AUTO_RENEW_PERIOD.setter();
    final var autoRenewAccountSetter = AUTO_RENEW_ACCOUNT.setter();
    final var memoSetter = MEMO.setter();
    final var lastUsedSerialNumberSetter = LAST_USED_SERIAL_NUMBER.setter();
    final var tokenTypeSetter = TOKEN_TYPE.setter();
    final var supplyTypeSetter = SUPPLY_TYPE.setter();
    final var maxSupplySetter = MAX_SUPPLY.setter();
    final var feeScheduleSetter = FEE_SCHEDULE.setter();
    // when:
    totalSupplySetter.accept(target, totalSupply);
    decimalsSetter.accept(target, decimals);
    adminKeySetter.accept(target, adminKey);
    freezeKeySetter.accept(target, freezeKey);
    kycKeySetter.accept(target, kycKey);
    pauseKeySetter.accept(target, pauseKey);
    supplyKeySetter.accept(target, supplyKey);
    feeScheduleKeySetter.accept(target, feeScheduleKey);
    wipeKeySetter.accept(target, wipeKey);
    deletedSetter.accept(target, deleted);
    pausedSetter.accept(target, paused);
    symbolSetter.accept(target, symbol);
    nameSetter.accept(target, name);
    treasurySetter.accept(target, treasury);
    accountsFrozenByDefaultSetter.accept(target, accountsFrozenByDefault);
    expirySetter.accept(target, expiry);
    autoRenewPeriodSetter.accept(target, autoRenewPeriod);
    autoRenewAccountSetter.accept(target, autoRenewAccount);
    memoSetter.accept(target, memo);
    lastUsedSerialNumberSetter.accept(target, lastUsedSerialNumber);
    tokenTypeSetter.accept(target, tokenType);
    supplyTypeSetter.accept(target, supplyType);
    maxSupplySetter.accept(target, maxSupply);
    feeScheduleSetter.accept(target, feeSchedule);
    // expect:
    assertEquals(totalSupply, target.totalSupply());
    assertEquals(decimals, target.decimals());
    assertEquals(adminKey, target.getAdminKey());
    assertEquals(freezeKey, target.getFreezeKey());
    assertEquals(kycKey, target.getKycKey());
    assertEquals(pauseKey, target.getPauseKey());
    assertEquals(supplyKey, target.getSupplyKey());
    assertEquals(feeScheduleKey, target.getFeeScheduleKey());
    assertEquals(wipeKey, target.getWipeKey());
    assertEquals(deleted, target.isDeleted());
    assertEquals(paused, target.isPaused());
    assertEquals(symbol, target.symbol());
    assertEquals(name, target.name());
    assertEquals(treasury, target.treasury());
    assertEquals(accountsFrozenByDefault, target.accountsAreFrozenByDefault());
    assertEquals(expiry, target.expiry());
    assertEquals(autoRenewPeriod, target.autoRenewPeriod());
    assertEquals(autoRenewAccount, target.autoRenewAccount());
    assertEquals(tokenType, target.tokenType());
    assertEquals(supplyType, target.supplyType());
    assertEquals(maxSupply, target.maxSupply());
    assertEquals(feeSchedule, target.customFeeSchedule());
}
Also used : MerkleToken(com.hedera.services.state.merkle.MerkleToken) Test(org.junit.jupiter.api.Test)

Example 7 with MerkleToken

use of com.hedera.services.state.merkle.MerkleToken in project hedera-services by hashgraph.

the class WorldLedgersTest method wrapsAsExpectedWithCommitInterceptors.

@Test
void wrapsAsExpectedWithCommitInterceptors() {
    final var liveTokenRels = new TransactionalLedger<>(TokenRelProperty.class, MerkleTokenRelStatus::new, new HashMapBackingTokenRels(), new ChangeSummaryManager<>());
    final var liveAccounts = new TransactionalLedger<>(AccountProperty.class, MerkleAccount::new, new HashMapBackingAccounts(), new ChangeSummaryManager<>());
    final var liveNfts = new TransactionalLedger<>(NftProperty.class, MerkleUniqueToken::new, new HashMapBackingNfts(), new ChangeSummaryManager<>());
    final var liveTokens = new TransactionalLedger<>(TokenProperty.class, MerkleToken::new, new HashMapBackingTokens(), new ChangeSummaryManager<>());
    final var liveAliases = new AliasManager();
    final var source = new WorldLedgers(liveAliases, liveTokenRels, liveAccounts, liveNfts, liveTokens);
    assertTrue(source.areMutable());
    final var nullTokenRels = new WorldLedgers(liveAliases, null, liveAccounts, liveNfts, liveTokens);
    final var nullAccounts = new WorldLedgers(liveAliases, liveTokenRels, null, liveNfts, liveTokens);
    final var nullNfts = new WorldLedgers(liveAliases, liveTokenRels, liveAccounts, null, liveTokens);
    final var nullTokens = new WorldLedgers(liveAliases, liveTokenRels, liveAccounts, liveNfts, null);
    assertFalse(nullTokenRels.areMutable());
    assertFalse(nullAccounts.areMutable());
    assertFalse(nullNfts.areMutable());
    assertFalse(nullTokens.areMutable());
    final var wrappedUnusable = nullAccounts.wrapped(sideEffectsTracker);
    assertSame(((StackedContractAliases) wrappedUnusable.aliases()).wrappedAliases(), nullAccounts.aliases());
    assertFalse(wrappedUnusable.areMutable());
    final var wrappedSource = source.wrapped(sideEffectsTracker);
    assertSame(liveTokenRels, wrappedSource.tokenRels().getEntitiesLedger());
    assertSame(liveAccounts, wrappedSource.accounts().getEntitiesLedger());
    assertSame(liveNfts, wrappedSource.nfts().getEntitiesLedger());
    assertSame(liveTokens, wrappedSource.tokens().getEntitiesLedger());
    final var stackedAliases = (StackedContractAliases) wrappedSource.aliases();
    assertSame(liveAliases, stackedAliases.wrappedAliases());
}
Also used : HashMapBackingTokenRels(com.hedera.services.ledger.backing.HashMapBackingTokenRels) MerkleToken(com.hedera.services.state.merkle.MerkleToken) MerkleAccount(com.hedera.services.state.merkle.MerkleAccount) TransactionalLedger(com.hedera.services.ledger.TransactionalLedger) MerkleTokenRelStatus(com.hedera.services.state.merkle.MerkleTokenRelStatus) HashMapBackingNfts(com.hedera.services.ledger.backing.HashMapBackingNfts) AliasManager(com.hedera.services.ledger.accounts.AliasManager) StackedContractAliases(com.hedera.services.ledger.accounts.StackedContractAliases) HashMapBackingTokens(com.hedera.services.ledger.backing.HashMapBackingTokens) MerkleUniqueToken(com.hedera.services.state.merkle.MerkleUniqueToken) HashMapBackingAccounts(com.hedera.services.ledger.backing.HashMapBackingAccounts) Test(org.junit.jupiter.api.Test)

Example 8 with MerkleToken

use of com.hedera.services.state.merkle.MerkleToken in project hedera-services by hashgraph.

the class TypedTokenStoreTest method setupToken.

private void setupToken() {
    merkleToken = new MerkleToken(expiry, tokenSupply, 0, symbol, name, freezeDefault, true, new EntityId(0, 0, treasuryAccountNum));
    merkleToken.setAutoRenewAccount(new EntityId(0, 0, autoRenewAccountNum));
    merkleToken.setSupplyKey(supplyKey);
    merkleToken.setKycKey(kycKey);
    merkleToken.setFreezeKey(freezeKey);
    merkleToken.setPauseKey(pauseKey);
    merkleToken.setPaused(false);
    token.setTreasury(treasuryAccount);
    token.setAutoRenewAccount(autoRenewAccount);
    token.setTotalSupply(tokenSupply);
    token.setKycKey(kycKey);
    token.setSupplyKey(supplyKey);
    token.setFreezeKey(freezeKey);
    token.setPauseKey(pauseKey);
    token.setFrozenByDefault(freezeDefault);
    token.setIsDeleted(false);
    token.setPaused(false);
    token.setExpiry(expiry);
}
Also used : EntityId(com.hedera.services.state.submerkle.EntityId) MerkleToken(com.hedera.services.state.merkle.MerkleToken)

Example 9 with MerkleToken

use of com.hedera.services.state.merkle.MerkleToken in project hedera-services by hashgraph.

the class AbstractLedgerWorldUpdaterTest method setupLedgers.

private void setupLedgers() {
    final var tokenRelsLedger = new TransactionalLedger<>(TokenRelProperty.class, MerkleTokenRelStatus::new, new HashMapBackingTokenRels(), new ChangeSummaryManager<>());
    final var accountsLedger = new TransactionalLedger<>(AccountProperty.class, MerkleAccount::new, new HashMapBackingAccounts(), new ChangeSummaryManager<>());
    final var tokensLedger = new TransactionalLedger<>(TokenProperty.class, MerkleToken::new, new HashMapBackingTokens(), new ChangeSummaryManager<>());
    final var nftsLedger = new TransactionalLedger<>(NftProperty.class, MerkleUniqueToken::new, new HashMapBackingNfts(), new ChangeSummaryManager<>());
    tokenRelsLedger.begin();
    accountsLedger.begin();
    nftsLedger.begin();
    tokensLedger.begin();
    ledgers = new WorldLedgers(aliases, tokenRelsLedger, accountsLedger, nftsLedger, tokensLedger);
}
Also used : MerkleTokenRelStatus(com.hedera.services.state.merkle.MerkleTokenRelStatus) HashMapBackingNfts(com.hedera.services.ledger.backing.HashMapBackingNfts) HashMapBackingTokenRels(com.hedera.services.ledger.backing.HashMapBackingTokenRels) MerkleToken(com.hedera.services.state.merkle.MerkleToken) MerkleAccount(com.hedera.services.state.merkle.MerkleAccount) HashMapBackingTokens(com.hedera.services.ledger.backing.HashMapBackingTokens) MerkleUniqueToken(com.hedera.services.state.merkle.MerkleUniqueToken) HashMapBackingAccounts(com.hedera.services.ledger.backing.HashMapBackingAccounts) TransactionalLedger(com.hedera.services.ledger.TransactionalLedger)

Example 10 with MerkleToken

use of com.hedera.services.state.merkle.MerkleToken in project hedera-services by hashgraph.

the class AbstractStackedLedgerUpdaterTest method setupLedgers.

private void setupLedgers() {
    final var tokenRelsLedger = new TransactionalLedger<>(TokenRelProperty.class, MerkleTokenRelStatus::new, new HashMapBackingTokenRels(), new ChangeSummaryManager<>());
    final var accountsLedger = new TransactionalLedger<>(AccountProperty.class, MerkleAccount::new, new HashMapBackingAccounts(), new ChangeSummaryManager<>());
    final var nftsLedger = new TransactionalLedger<>(NftProperty.class, MerkleUniqueToken::new, new HashMapBackingNfts(), new ChangeSummaryManager<>());
    final var tokensLedger = new TransactionalLedger<>(TokenProperty.class, MerkleToken::new, new HashMapBackingTokens(), new ChangeSummaryManager<>());
    tokenRelsLedger.begin();
    accountsLedger.begin();
    nftsLedger.begin();
    ledgers = new WorldLedgers(aliases, tokenRelsLedger, accountsLedger, nftsLedger, tokensLedger);
}
Also used : MerkleTokenRelStatus(com.hedera.services.state.merkle.MerkleTokenRelStatus) HashMapBackingNfts(com.hedera.services.ledger.backing.HashMapBackingNfts) HashMapBackingTokenRels(com.hedera.services.ledger.backing.HashMapBackingTokenRels) MerkleToken(com.hedera.services.state.merkle.MerkleToken) MerkleAccount(com.hedera.services.state.merkle.MerkleAccount) HashMapBackingTokens(com.hedera.services.ledger.backing.HashMapBackingTokens) MerkleUniqueToken(com.hedera.services.state.merkle.MerkleUniqueToken) HashMapBackingAccounts(com.hedera.services.ledger.backing.HashMapBackingAccounts) TransactionalLedger(com.hedera.services.ledger.TransactionalLedger)

Aggregations

MerkleToken (com.hedera.services.state.merkle.MerkleToken)16 Test (org.junit.jupiter.api.Test)9 EntityId (com.hedera.services.state.submerkle.EntityId)8 MerkleAccount (com.hedera.services.state.merkle.MerkleAccount)6 MerkleTokenRelStatus (com.hedera.services.state.merkle.MerkleTokenRelStatus)5 MerkleUniqueToken (com.hedera.services.state.merkle.MerkleUniqueToken)5 TransactionalLedger (com.hedera.services.ledger.TransactionalLedger)4 HashMapBackingAccounts (com.hedera.services.ledger.backing.HashMapBackingAccounts)4 HashMapBackingNfts (com.hedera.services.ledger.backing.HashMapBackingNfts)4 HashMapBackingTokenRels (com.hedera.services.ledger.backing.HashMapBackingTokenRels)4 HashMapBackingTokens (com.hedera.services.ledger.backing.HashMapBackingTokens)4 EntityNum (com.hedera.services.utils.EntityNum)3 AliasManager (com.hedera.services.ledger.accounts.AliasManager)2 StackedContractAliases (com.hedera.services.ledger.accounts.StackedContractAliases)2 NftId (com.hedera.services.store.models.NftId)2 AccountID (com.hederahashgraph.api.proto.java.AccountID)2 MerkleMap (com.swirlds.merkle.map.MerkleMap)2 ByteString (com.google.protobuf.ByteString)1 NetworkInfo (com.hedera.services.config.NetworkInfo)1 MutableStateChildren (com.hedera.services.context.MutableStateChildren)1