Search in sources :

Example 1 with OptionValidator

use of com.hedera.services.txns.validation.OptionValidator in project hedera-services by hashgraph.

the class GetTxnRecordAnswerTest method setup.

@BeforeEach
private void setup() {
    recordCache = mock(RecordCache.class);
    accounts = mock(MerkleMap.class);
    nodeProps = mock(NodeLocalProperties.class);
    final MutableStateChildren children = new MutableStateChildren();
    children.setAccounts(accounts);
    view = new StateView(null, null, children, null);
    optionValidator = mock(OptionValidator.class);
    answerFunctions = mock(AnswerFunctions.class);
    subject = new GetTxnRecordAnswer(recordCache, optionValidator, answerFunctions);
}
Also used : MutableStateChildren(com.hedera.services.context.MutableStateChildren) OptionValidator(com.hedera.services.txns.validation.OptionValidator) MerkleMap(com.swirlds.merkle.map.MerkleMap) StateView(com.hedera.services.context.primitives.StateView) NodeLocalProperties(com.hedera.services.context.properties.NodeLocalProperties) RecordCache(com.hedera.services.records.RecordCache) AnswerFunctions(com.hedera.services.queries.answering.AnswerFunctions) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with OptionValidator

use of com.hedera.services.txns.validation.OptionValidator in project hedera-services by hashgraph.

the class GetAccountBalanceAnswerTest method setup.

@BeforeEach
private void setup() {
    deleted = mock(MerkleToken.class);
    given(deleted.isDeleted()).willReturn(true);
    given(deleted.decimals()).willReturn(123);
    notDeleted = mock(MerkleToken.class);
    given(notDeleted.isDeleted()).willReturn(false);
    given(notDeleted.decimals()).willReturn(1).willReturn(2);
    tokenRels = new MerkleMap<>();
    tokenRels.put(fromAccountTokenRel(target, aToken), new MerkleTokenRelStatus(aBalance, true, true, true));
    tokenRels.put(fromAccountTokenRel(target, bToken), new MerkleTokenRelStatus(bBalance, false, false, false));
    tokenRels.put(fromAccountTokenRel(target, cToken), new MerkleTokenRelStatus(cBalance, false, false, true));
    tokenRels.put(fromAccountTokenRel(target, dToken), new MerkleTokenRelStatus(dBalance, false, false, true));
    accounts = mock(MerkleMap.class);
    nodeProps = mock(NodeLocalProperties.class);
    given(accounts.get(fromAccountId(asAccount(accountIdLit)))).willReturn(accountV);
    given(accounts.get(fromContractId(asContract(contractIdLit)))).willReturn(contractV);
    tokenStore = mock(TokenStore.class);
    given(tokenStore.exists(aToken)).willReturn(true);
    given(tokenStore.exists(bToken)).willReturn(true);
    given(tokenStore.exists(cToken)).willReturn(true);
    given(tokenStore.exists(dToken)).willReturn(false);
    given(tokenStore.get(aToken)).willReturn(notDeleted);
    given(tokenStore.get(bToken)).willReturn(notDeleted);
    given(tokenStore.get(cToken)).willReturn(deleted);
    scheduleStore = mock(ScheduleStore.class);
    final MutableStateChildren children = new MutableStateChildren();
    children.setAccounts(accounts);
    children.setTokenAssociations(tokenRels);
    view = new StateView(tokenStore, scheduleStore, children, null);
    optionValidator = mock(OptionValidator.class);
    aliasManager = mock(AliasManager.class);
    subject = new GetAccountBalanceAnswer(aliasManager, optionValidator);
}
Also used : MerkleTokenRelStatus(com.hedera.services.state.merkle.MerkleTokenRelStatus) AliasManager(com.hedera.services.ledger.accounts.AliasManager) MutableStateChildren(com.hedera.services.context.MutableStateChildren) OptionValidator(com.hedera.services.txns.validation.OptionValidator) MerkleToken(com.hedera.services.state.merkle.MerkleToken) MerkleMap(com.swirlds.merkle.map.MerkleMap) StateView(com.hedera.services.context.primitives.StateView) NodeLocalProperties(com.hedera.services.context.properties.NodeLocalProperties) TokenStore(com.hedera.services.store.tokens.TokenStore) ScheduleStore(com.hedera.services.store.schedule.ScheduleStore) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with OptionValidator

use of com.hedera.services.txns.validation.OptionValidator in project hedera-services by hashgraph.

the class GetMerkleTopicInfoAnswerTest method setup.

@BeforeEach
private void setup() throws Exception {
    adminKey = COMPLEX_KEY_ACCOUNT_KT.asKey();
    submitKey = MISC_ACCOUNT_KT.asKey();
    topics = mock(MerkleMap.class);
    merkleTopic = TopicFactory.newTopic().adminKey(adminKey).submitKey(submitKey).memo(memo).expiry(expiry).deleted(false).autoRenewDuration(duration).autoRenewId(asAccount(id)).get();
    merkleTopic.setRunningHash(hash);
    merkleTopic.setSequenceNumber(seqNo);
    given(topics.get(key)).willReturn(merkleTopic);
    nodeProps = mock(NodeLocalProperties.class);
    final MutableStateChildren children = new MutableStateChildren();
    children.setTopics(topics);
    networkInfo = mock(NetworkInfo.class);
    given(networkInfo.ledgerId()).willReturn(ledgerId);
    view = new StateView(null, null, children, networkInfo);
    optionValidator = mock(OptionValidator.class);
    subject = new GetTopicInfoAnswer(optionValidator);
}
Also used : MutableStateChildren(com.hedera.services.context.MutableStateChildren) OptionValidator(com.hedera.services.txns.validation.OptionValidator) NetworkInfo(com.hedera.services.config.NetworkInfo) MerkleMap(com.swirlds.merkle.map.MerkleMap) StateView(com.hedera.services.context.primitives.StateView) NodeLocalProperties(com.hedera.services.context.properties.NodeLocalProperties) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with OptionValidator

use of com.hedera.services.txns.validation.OptionValidator in project hedera-services by hashgraph.

the class GetAccountRecordsAnswerTest method setup.

@BeforeEach
private void setup() throws Exception {
    payerAccount = MerkleAccountFactory.newAccount().accountKeys(COMPLEX_KEY_ACCOUNT_KT).proxy(asAccount("1.2.3")).senderThreshold(1_234L).receiverThreshold(4_321L).receiverSigRequired(true).balance(555L).autoRenewPeriod(1_000_000L).expirationTime(9_999_999L).get();
    payerAccount.records().offer(recordOne());
    payerAccount.records().offer(recordTwo());
    accounts = mock(MerkleMap.class);
    given(accounts.get(EntityNum.fromAccountId(asAccount(target)))).willReturn(payerAccount);
    final MutableStateChildren children = new MutableStateChildren();
    children.setAccounts(accounts);
    view = new StateView(null, null, children, null);
    optionValidator = mock(OptionValidator.class);
    subject = new GetAccountRecordsAnswer(new AnswerFunctions(dynamicProperties), optionValidator);
}
Also used : MutableStateChildren(com.hedera.services.context.MutableStateChildren) OptionValidator(com.hedera.services.txns.validation.OptionValidator) MerkleMap(com.swirlds.merkle.map.MerkleMap) StateView(com.hedera.services.context.primitives.StateView) AnswerFunctions(com.hedera.services.queries.answering.AnswerFunctions) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

MutableStateChildren (com.hedera.services.context.MutableStateChildren)4 StateView (com.hedera.services.context.primitives.StateView)4 OptionValidator (com.hedera.services.txns.validation.OptionValidator)4 MerkleMap (com.swirlds.merkle.map.MerkleMap)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4 NodeLocalProperties (com.hedera.services.context.properties.NodeLocalProperties)3 AnswerFunctions (com.hedera.services.queries.answering.AnswerFunctions)2 NetworkInfo (com.hedera.services.config.NetworkInfo)1 AliasManager (com.hedera.services.ledger.accounts.AliasManager)1 RecordCache (com.hedera.services.records.RecordCache)1 MerkleToken (com.hedera.services.state.merkle.MerkleToken)1 MerkleTokenRelStatus (com.hedera.services.state.merkle.MerkleTokenRelStatus)1 ScheduleStore (com.hedera.services.store.schedule.ScheduleStore)1 TokenStore (com.hedera.services.store.tokens.TokenStore)1