Search in sources :

Example 6 with MerkleTokenRelStatus

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

the class SignedStateBalancesExporterTest method setUp.

@BeforeEach
void setUp() throws ConstructableRegistryException {
    ConstructableRegistry.registerConstructable(new ClassConstructorPair(MerkleAccount.class, MerkleAccount::new));
    thisNodeAccount = MerkleAccountFactory.newAccount().balance(thisNodeBalance).get();
    anotherNodeAccount = MerkleAccountFactory.newAccount().balance(anotherNodeBalance).get();
    firstNonNodeAccount = MerkleAccountFactory.newAccount().balance(firstNonNodeAccountBalance).get();
    secondNonNodeAccount = MerkleAccountFactory.newAccount().balance(secondNonNodeAccountBalance).tokens(theToken, theDeletedToken, theMissingToken).get();
    deletedAccount = MerkleAccountFactory.newAccount().deleted(true).get();
    accounts.put(fromAccountId(thisNode), thisNodeAccount);
    accounts.put(fromAccountId(anotherNode), anotherNodeAccount);
    accounts.put(fromAccountId(firstNonNode), firstNonNodeAccount);
    accounts.put(fromAccountId(secondNonNode), secondNonNodeAccount);
    accounts.put(fromAccountId(deleted), deletedAccount);
    token = mock(MerkleToken.class);
    given(token.isDeleted()).willReturn(false);
    deletedToken = mock(MerkleToken.class);
    given(deletedToken.isDeleted()).willReturn(true);
    tokens.put(fromTokenId(theToken), token);
    tokens.put(fromTokenId(theDeletedToken), deletedToken);
    tokenRels.put(fromAccountTokenRel(secondNonNode, theToken), new MerkleTokenRelStatus(secondNonNodeTokenBalance, false, true, false));
    tokenRels.put(fromAccountTokenRel(secondNonNode, theDeletedToken), new MerkleTokenRelStatus(secondNonNodeDeletedTokenBalance, false, true, false));
    assurance = mock(DirectoryAssurance.class);
    properties = mock(PropertySource.class);
    given(properties.getLongProperty("ledger.totalTinyBarFloat")).willReturn(ledgerFloat);
    var firstNodeAddress = mock(Address.class);
    given(firstNodeAddress.getMemo()).willReturn("0.0.3");
    var secondNodeAddress = mock(Address.class);
    given(secondNodeAddress.getMemo()).willReturn("0.0.4");
    var book = mock(AddressBook.class);
    given(book.getSize()).willReturn(2);
    given(book.getAddress(0)).willReturn(firstNodeAddress);
    given(book.getAddress(1)).willReturn(secondNodeAddress);
    state = mock(ServicesState.class);
    given(state.getAccountFromNodeId(nodeId)).willReturn(thisNode);
    given(state.tokens()).willReturn(tokens);
    given(state.accounts()).willReturn(accounts);
    given(state.tokenAssociations()).willReturn(tokenRels);
    given(state.addressBook()).willReturn(book);
    signer = mock(UnaryOperator.class);
    given(signer.apply(fileHash)).willReturn(sig);
    systemExits = mock(SystemExits.class);
    subject = new SignedStateBalancesExporter(systemExits, properties, signer, dynamicProperties);
    sigFileWriter = mock(SigFileWriter.class);
    hashReader = mock(FileHashReader.class);
    subject.sigFileWriter = sigFileWriter;
    subject.hashReader = hashReader;
}
Also used : MerkleToken(com.hedera.services.state.merkle.MerkleToken) MerkleAccount(com.hedera.services.state.merkle.MerkleAccount) PropertySource(com.hedera.services.context.properties.PropertySource) MerkleTokenRelStatus(com.hedera.services.state.merkle.MerkleTokenRelStatus) ServicesState(com.hedera.services.ServicesState) SystemExits(com.hedera.services.utils.SystemExits) UnaryOperator(java.util.function.UnaryOperator) ClassConstructorPair(com.swirlds.common.constructable.ClassConstructorPair) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 7 with MerkleTokenRelStatus

use of com.hedera.services.state.merkle.MerkleTokenRelStatus 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 MerkleTokenRelStatus

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

the class TypedTokenStoreTest method setupTokenRel.

private void setupTokenRel() {
    miscTokenMerkleRel = new MerkleTokenRelStatus(balance, frozen, kycGranted, automaticAssociation);
    miscTokenRel.initBalance(balance);
    miscTokenRel.setFrozen(frozen);
    miscTokenRel.setKycGranted(kycGranted);
    miscTokenRel.setAutomaticAssociation(automaticAssociation);
    miscTokenRel.markAsPersisted();
}
Also used : MerkleTokenRelStatus(com.hedera.services.state.merkle.MerkleTokenRelStatus)

Example 9 with MerkleTokenRelStatus

use of com.hedera.services.state.merkle.MerkleTokenRelStatus 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 MerkleTokenRelStatus

use of com.hedera.services.state.merkle.MerkleTokenRelStatus 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

MerkleTokenRelStatus (com.hedera.services.state.merkle.MerkleTokenRelStatus)13 MerkleToken (com.hedera.services.state.merkle.MerkleToken)7 MerkleAccount (com.hedera.services.state.merkle.MerkleAccount)6 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 BeforeEach (org.junit.jupiter.api.BeforeEach)4 MutableStateChildren (com.hedera.services.context.MutableStateChildren)3 AliasManager (com.hedera.services.ledger.accounts.AliasManager)3 StateView (com.hedera.services.context.primitives.StateView)2 StackedContractAliases (com.hedera.services.ledger.accounts.StackedContractAliases)2 ScheduleStore (com.hedera.services.store.schedule.ScheduleStore)2 TokenStore (com.hedera.services.store.tokens.TokenStore)2 EntityNum (com.hedera.services.utils.EntityNum)2 MerkleMap (com.swirlds.merkle.map.MerkleMap)2 Test (org.junit.jupiter.api.Test)2 ServicesState (com.hedera.services.ServicesState)1