use of com.hedera.services.context.MutableStateChildren 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);
}
use of com.hedera.services.context.MutableStateChildren 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);
}
use of com.hedera.services.context.MutableStateChildren in project hedera-services by hashgraph.
the class GetAccountInfoAnswerTest method setup.
@BeforeEach
private void setup() throws Throwable {
tokenRels = new MerkleMap<>();
tokenRels.put(fromAccountTokenRel(payerId, firstToken), new MerkleTokenRelStatus(firstBalance, true, true, true));
tokenRels.put(fromAccountTokenRel(payerId, secondToken), new MerkleTokenRelStatus(secondBalance, false, false, true));
tokenRels.put(fromAccountTokenRel(payerId, thirdToken), new MerkleTokenRelStatus(thirdBalance, true, true, false));
tokenRels.put(fromAccountTokenRel(payerId, fourthToken), new MerkleTokenRelStatus(fourthBalance, false, false, true));
tokenRels.put(fromAccountTokenRel(payerId, missingToken), new MerkleTokenRelStatus(missingBalance, false, false, false));
var tokens = new MerkleAccountTokens();
tokens.associateAll(Set.of(firstToken, secondToken, thirdToken, fourthToken, missingToken));
var tokenAllowanceKey = FcTokenAllowanceId.from(EntityNum.fromLong(1000L), EntityNum.fromLong(2000L));
var tokenAllowanceValue = FcTokenAllowance.from(false, List.of(1L, 2L));
TreeMap<EntityNum, Long> cryptoAllowances = new TreeMap();
TreeMap<FcTokenAllowanceId, Long> fungibleTokenAllowances = new TreeMap();
TreeMap<FcTokenAllowanceId, FcTokenAllowance> nftAllowances = new TreeMap();
cryptoAllowances.put(EntityNum.fromLong(1L), 10L);
fungibleTokenAllowances.put(tokenAllowanceKey, 20L);
nftAllowances.put(tokenAllowanceKey, tokenAllowanceValue);
payerAccount = MerkleAccountFactory.newAccount().accountKeys(COMPLEX_KEY_ACCOUNT_KT).memo(memo).proxy(asAccount("1.2.3")).senderThreshold(1_234L).receiverThreshold(4_321L).receiverSigRequired(true).balance(555L).autoRenewPeriod(1_000_000L).expirationTime(9_999_999L).cryptoAllowances(cryptoAllowances).fungibleTokenAllowances(fungibleTokenAllowances).nftAllowances(nftAllowances).get();
payerAccount.setTokens(tokens);
final MutableStateChildren children = new MutableStateChildren();
children.setAccounts(accounts);
children.setTokenAssociations(tokenRels);
view = new StateView(tokenStore, scheduleStore, children, networkInfo);
subject = new GetAccountInfoAnswer(optionValidator, aliasManager);
}
use of com.hedera.services.context.MutableStateChildren 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);
}
use of com.hedera.services.context.MutableStateChildren in project hedera-services by hashgraph.
the class AnswerFunctionsTest method setupAccountsView.
private void setupAccountsView() {
final var children = new MutableStateChildren();
children.setAccounts(accounts);
view = new StateView(null, null, children, null);
}
Aggregations