Search in sources :

Example 1 with BackingTokenRels

use of com.hedera.services.ledger.backing.BackingTokenRels in project hedera-services by hashgraph.

the class BackingTokenRelsTest method setup.

@BeforeEach
private void setup() {
    rels = new MerkleMap<>();
    rels.put(aKey, aValue);
    rels.put(bKey, bValue);
    subject = new BackingTokenRels(() -> rels);
}
Also used : BackingTokenRels(com.hedera.services.ledger.backing.BackingTokenRels) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with BackingTokenRels

use of com.hedera.services.ledger.backing.BackingTokenRels in project hedera-services by hashgraph.

the class LedgerBalanceChangesTest method setUp.

@BeforeEach
void setUp() throws ConstructableRegistryException {
    MockitoAnnotations.initMocks(this);
    accountsLedger = new TransactionalLedger<>(AccountProperty.class, MerkleAccount::new, backingAccounts, new ChangeSummaryManager<>());
    accountsLedger.setCommitInterceptor(accountsCommitInterceptor);
    tokenRelsLedger = new TransactionalLedger<>(TokenRelProperty.class, MerkleTokenRelStatus::new, backingRels, new ChangeSummaryManager<>());
    nftsLedger = new TransactionalLedger<>(NftProperty.class, MerkleUniqueToken::new, backingNfts, new ChangeSummaryManager<>());
    nftsLedger.setCommitInterceptor(uniqueTokensCommitInterceptor);
    tokenRelsLedger.setKeyToString(BackingTokenRels::readableTokenRel);
    tokenRelsLedger.setCommitInterceptor(tokenRelsCommitInterceptor);
    backingTokens.put(tokenKey.toGrpcTokenId(), fungibleTokenWithTreasury(aModel));
    backingTokens.put(anotherTokenKey.toGrpcTokenId(), fungibleTokenWithTreasury(aModel));
    backingTokens.put(yetAnotherTokenKey.toGrpcTokenId(), fungibleTokenWithTreasury(aModel));
    backingTokens.put(aNftKey.toGrpcTokenId(), nonFungibleTokenWithTreasury(aModel));
    backingTokens.put(bNftKey.toGrpcTokenId(), nonFungibleTokenWithTreasury(bModel));
    final var sideEffectsTracker = new SideEffectsTracker();
    tokenStore = new HederaTokenStore(ids, validator, sideEffectsTracker, dynamicProperties, tokenRelsLedger, nftsLedger, backingTokens);
    transferLogic = new TransferLogic(accountsLedger, nftsLedger, tokenRelsLedger, tokenStore, sideEffectsTracker, dynamicProperties, validator, autoCreationLogic, historian);
    tokenStore.rebuildViews();
    subject = new HederaLedger(tokenStore, ids, creator, validator, sideEffectsTracker, historian, dynamicProperties, accountsLedger, transferLogic, autoCreationLogic);
    subject.setMutableEntityAccess(mutableEntityAccess);
    subject.setTokenRelsLedger(tokenRelsLedger);
}
Also used : HederaTokenStore(com.hedera.services.store.tokens.HederaTokenStore) ChangeSummaryManager(com.hedera.services.ledger.properties.ChangeSummaryManager) SideEffectsTracker(com.hedera.services.context.SideEffectsTracker) NftProperty(com.hedera.services.ledger.properties.NftProperty) BackingTokenRels(com.hedera.services.ledger.backing.BackingTokenRels) HashMapBackingTokenRels(com.hedera.services.ledger.backing.HashMapBackingTokenRels) AccountProperty(com.hedera.services.ledger.properties.AccountProperty) TokenRelProperty(com.hedera.services.ledger.properties.TokenRelProperty) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with BackingTokenRels

use of com.hedera.services.ledger.backing.BackingTokenRels in project hedera-services by hashgraph.

the class HederaLedgerLiveTest method setup.

@BeforeEach
void setup() {
    commonSetup();
    accountsLedger = new TransactionalLedger<>(AccountProperty.class, MerkleAccount::new, new HashMapBackingAccounts(), new ChangeSummaryManager<>());
    accountsLedger.setCommitInterceptor(accountsCommitInterceptor);
    nftsLedger = new TransactionalLedger<>(NftProperty.class, MerkleUniqueToken::new, new HashMapBackingNfts(), new ChangeSummaryManager<>());
    nftsLedger.setCommitInterceptor(uniqueTokensCommitInterceptor);
    tokenRelsLedger = new TransactionalLedger<>(TokenRelProperty.class, MerkleTokenRelStatus::new, new HashMapBackingTokenRels(), new ChangeSummaryManager<>());
    tokenRelsLedger.setKeyToString(BackingTokenRels::readableTokenRel);
    tokenRelsLedger.setCommitInterceptor(tokenRelsCommitInterceptor);
    tokenStore = new HederaTokenStore(ids, TestContextValidator.TEST_VALIDATOR, liveSideEffects, new MockGlobalDynamicProps(), tokenRelsLedger, nftsLedger, new HashMapBackingTokens());
    subject = new HederaLedger(tokenStore, ids, creator, validator, liveSideEffects, historian, dynamicProps, accountsLedger, transferLogic, autoCreationLogic);
    subject.setMutableEntityAccess(mock(MutableEntityAccess.class));
}
Also used : HashMapBackingTokenRels(com.hedera.services.ledger.backing.HashMapBackingTokenRels) NftProperty(com.hedera.services.ledger.properties.NftProperty) BackingTokenRels(com.hedera.services.ledger.backing.BackingTokenRels) HashMapBackingTokenRels(com.hedera.services.ledger.backing.HashMapBackingTokenRels) AccountProperty(com.hedera.services.ledger.properties.AccountProperty) TokenRelProperty(com.hedera.services.ledger.properties.TokenRelProperty) HashMapBackingNfts(com.hedera.services.ledger.backing.HashMapBackingNfts) HederaTokenStore(com.hedera.services.store.tokens.HederaTokenStore) ChangeSummaryManager(com.hedera.services.ledger.properties.ChangeSummaryManager) HashMapBackingTokens(com.hedera.services.ledger.backing.HashMapBackingTokens) MockGlobalDynamicProps(com.hedera.services.config.MockGlobalDynamicProps) HashMapBackingAccounts(com.hedera.services.ledger.backing.HashMapBackingAccounts) MutableEntityAccess(com.hedera.services.store.contracts.MutableEntityAccess) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with BackingTokenRels

use of com.hedera.services.ledger.backing.BackingTokenRels in project hedera-services by hashgraph.

the class BackingTokenRelsTest method setupMocked.

private void setupMocked() {
    rels = mock(MerkleMap.class);
    given(rels.keySet()).willReturn(Collections.emptySet());
    given(rels.entrySet()).willReturn(Collections.emptySet());
    subject = new BackingTokenRels(() -> rels);
}
Also used : MerkleMap(com.swirlds.merkle.map.MerkleMap) BackingTokenRels(com.hedera.services.ledger.backing.BackingTokenRels)

Aggregations

BackingTokenRels (com.hedera.services.ledger.backing.BackingTokenRels)4 BeforeEach (org.junit.jupiter.api.BeforeEach)3 HashMapBackingTokenRels (com.hedera.services.ledger.backing.HashMapBackingTokenRels)2 AccountProperty (com.hedera.services.ledger.properties.AccountProperty)2 ChangeSummaryManager (com.hedera.services.ledger.properties.ChangeSummaryManager)2 NftProperty (com.hedera.services.ledger.properties.NftProperty)2 TokenRelProperty (com.hedera.services.ledger.properties.TokenRelProperty)2 HederaTokenStore (com.hedera.services.store.tokens.HederaTokenStore)2 MockGlobalDynamicProps (com.hedera.services.config.MockGlobalDynamicProps)1 SideEffectsTracker (com.hedera.services.context.SideEffectsTracker)1 HashMapBackingAccounts (com.hedera.services.ledger.backing.HashMapBackingAccounts)1 HashMapBackingNfts (com.hedera.services.ledger.backing.HashMapBackingNfts)1 HashMapBackingTokens (com.hedera.services.ledger.backing.HashMapBackingTokens)1 MutableEntityAccess (com.hedera.services.store.contracts.MutableEntityAccess)1 MerkleMap (com.swirlds.merkle.map.MerkleMap)1