Search in sources :

Example 1 with HederaTokenStore

use of com.hedera.services.store.tokens.HederaTokenStore 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 2 with HederaTokenStore

use of com.hedera.services.store.tokens.HederaTokenStore in project hedera-services by hashgraph.

the class LedgerBalanceChangesTest method rejectsMissingToken.

@Test
void rejectsMissingToken() {
    // setup:
    backingTokens = new HashMapBackingTokens();
    backingTokens.put(anotherTokenKey.toGrpcTokenId(), fungibleTokenWithTreasury(aModel));
    backingTokens.put(yetAnotherTokenKey.toGrpcTokenId(), fungibleTokenWithTreasury(aModel));
    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);
    subject = new HederaLedger(tokenStore, ids, creator, validator, sideEffectsTracker, historian, dynamicProperties, accountsLedger, transferLogic, autoCreationLogic);
    subject.setTokenRelsLedger(tokenRelsLedger);
    subject.setMutableEntityAccess(mutableEntityAccess);
    tokenStore.rebuildViews();
    givenInitialBalancesAndOwnership();
    // when:
    subject.begin();
    // and:
    assertFailsWith(() -> subject.doZeroSum(fixtureChanges()), ResponseCodeEnum.INVALID_TOKEN_ID);
    subject.commit();
    // then:
    assertInitialBalanceUnchanged();
}
Also used : HederaTokenStore(com.hedera.services.store.tokens.HederaTokenStore) SideEffectsTracker(com.hedera.services.context.SideEffectsTracker) HashMapBackingTokens(com.hedera.services.ledger.backing.HashMapBackingTokens) Test(org.junit.jupiter.api.Test)

Example 3 with HederaTokenStore

use of com.hedera.services.store.tokens.HederaTokenStore 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)

Aggregations

HederaTokenStore (com.hedera.services.store.tokens.HederaTokenStore)3 SideEffectsTracker (com.hedera.services.context.SideEffectsTracker)2 BackingTokenRels (com.hedera.services.ledger.backing.BackingTokenRels)2 HashMapBackingTokenRels (com.hedera.services.ledger.backing.HashMapBackingTokenRels)2 HashMapBackingTokens (com.hedera.services.ledger.backing.HashMapBackingTokens)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 BeforeEach (org.junit.jupiter.api.BeforeEach)2 MockGlobalDynamicProps (com.hedera.services.config.MockGlobalDynamicProps)1 HashMapBackingAccounts (com.hedera.services.ledger.backing.HashMapBackingAccounts)1 HashMapBackingNfts (com.hedera.services.ledger.backing.HashMapBackingNfts)1 MutableEntityAccess (com.hedera.services.store.contracts.MutableEntityAccess)1 Test (org.junit.jupiter.api.Test)1