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);
}
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();
}
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));
}
Aggregations