Search in sources :

Example 6 with MutableStateChildren

use of com.hedera.services.context.MutableStateChildren in project hedera-services by hashgraph.

the class GetMerkleTopicInfoResourceUsageTest method setup.

@BeforeEach
void setup() {
    topics = mock(MerkleMap.class);
    final var children = new MutableStateChildren();
    children.setTopics(topics);
    view = new StateView(null, null, children, null);
    subject = new GetTopicInfoResourceUsage();
}
Also used : MutableStateChildren(com.hedera.services.context.MutableStateChildren) MerkleMap(com.swirlds.merkle.map.MerkleMap) StateView(com.hedera.services.context.primitives.StateView) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 7 with MutableStateChildren

use of com.hedera.services.context.MutableStateChildren in project hedera-services by hashgraph.

the class TopicResourceUsageTestBase method setup.

void setup() throws Throwable {
    topics = mock(MerkleMap.class);
    nodeProps = mock(NodeLocalProperties.class);
    final MutableStateChildren children = new MutableStateChildren();
    children.setTopics(topics);
    view = new StateView(null, null, children, null);
}
Also used : MutableStateChildren(com.hedera.services.context.MutableStateChildren) MerkleMap(com.swirlds.merkle.map.MerkleMap) StateView(com.hedera.services.context.primitives.StateView) NodeLocalProperties(com.hedera.services.context.properties.NodeLocalProperties)

Example 8 with MutableStateChildren

use of com.hedera.services.context.MutableStateChildren in project hedera-services by hashgraph.

the class GetAccountRecordsResourceUsageTest method setup.

@BeforeEach
private void setup() {
    aValue = MerkleAccountFactory.newAccount().get();
    aValue.records().offer(recordOne());
    aValue.records().offer(recordTwo());
    final MutableStateChildren children = new MutableStateChildren();
    children.setAccounts(accounts);
    view = new StateView(null, null, children, null);
    subject = new GetAccountRecordsResourceUsage(new AnswerFunctions(dynamicProperties), usageEstimator);
}
Also used : MutableStateChildren(com.hedera.services.context.MutableStateChildren) StateView(com.hedera.services.context.primitives.StateView) AnswerFunctions(com.hedera.services.queries.answering.AnswerFunctions) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 9 with MutableStateChildren

use of com.hedera.services.context.MutableStateChildren in project hedera-services by hashgraph.

the class GetTxnRecordResourceUsageTest method setup.

@BeforeEach
private void setup() {
    desiredRecord = mock(TransactionRecord.class);
    usageEstimator = mock(CryptoFeeBuilder.class);
    recordCache = mock(RecordCache.class);
    final var children = new MutableStateChildren();
    view = new StateView(null, null, children, null);
    answerFunctions = mock(AnswerFunctions.class);
    given(answerFunctions.txnRecord(recordCache, satisfiableAnswerOnly)).willReturn(Optional.of(desiredRecord));
    given(answerFunctions.txnRecord(recordCache, satisfiableAnswerOnlyWithDups)).willReturn(Optional.of(desiredRecord));
    given(answerFunctions.txnRecord(recordCache, satisfiableCostAnswer)).willReturn(Optional.of(desiredRecord));
    given(answerFunctions.txnRecord(recordCache, unsatisfiable)).willReturn(Optional.empty());
    given(recordCache.getDuplicateRecords(targetTxnId)).willReturn(List.of(desiredRecord));
    subject = new GetTxnRecordResourceUsage(recordCache, answerFunctions, usageEstimator);
}
Also used : MutableStateChildren(com.hedera.services.context.MutableStateChildren) StateView(com.hedera.services.context.primitives.StateView) RecordCache(com.hedera.services.records.RecordCache) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) CryptoFeeBuilder(com.hederahashgraph.fee.CryptoFeeBuilder) AnswerFunctions(com.hedera.services.queries.answering.AnswerFunctions) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 10 with MutableStateChildren

use of com.hedera.services.context.MutableStateChildren in project hedera-services by hashgraph.

the class StateViewTest method setup.

@BeforeEach
@SuppressWarnings("unchecked")
private void setup() throws Throwable {
    metadata = new HFileMeta(false, TxnHandlingScenario.MISC_FILE_WACL_KT.asJKey(), expiry, fileMemo);
    immutableMetadata = new HFileMeta(false, StateView.EMPTY_WACL, expiry);
    expectedImmutable = FileGetInfoResponse.FileInfo.newBuilder().setLedgerId(ledgerId).setDeleted(false).setExpirationTime(Timestamp.newBuilder().setSeconds(expiry)).setFileID(target).setSize(data.length).build();
    expected = expectedImmutable.toBuilder().setKeys(TxnHandlingScenario.MISC_FILE_WACL_KT.asKey().getKeyList()).setMemo(fileMemo).build();
    tokenAccount = MerkleAccountFactory.newAccount().isSmartContract(false).tokens(tokenId).get();
    tokenAccount.setNftsOwned(10);
    tokenAccount.setMaxAutomaticAssociations(123);
    tokenAccount.setAlias(TxnHandlingScenario.TOKEN_ADMIN_KT.asKey().getEd25519());
    contract = MerkleAccountFactory.newAccount().alias(create2Address).memo("Stay cold...").numKvPairs(wellKnownNumKvPairs).isSmartContract(true).accountKeys(COMPLEX_KEY_ACCOUNT_KT).proxy(asAccount("0.0.3")).senderThreshold(1_234L).receiverThreshold(4_321L).receiverSigRequired(true).balance(555L).autoRenewPeriod(1_000_000L).deleted(true).expirationTime(9_999_999L).get();
    contracts = (MerkleMap<EntityNum, MerkleAccount>) mock(MerkleMap.class);
    topics = (MerkleMap<EntityNum, MerkleTopic>) mock(MerkleMap.class);
    tokenRels = new MerkleMap<>();
    tokenRels.put(EntityNumPair.fromLongs(tokenAccountId.getAccountNum(), tokenId.getTokenNum()), new MerkleTokenRelStatus(123L, false, true, true));
    tokenStore = mock(TokenStore.class);
    token = new MerkleToken(Long.MAX_VALUE, 100, 1, "UnfrozenToken", "UnfrozenTokenName", true, true, new EntityId(0, 0, 3));
    token.setMemo(tokenMemo);
    token.setAdminKey(TxnHandlingScenario.TOKEN_ADMIN_KT.asJKey());
    token.setFreezeKey(TxnHandlingScenario.TOKEN_FREEZE_KT.asJKey());
    token.setKycKey(TxnHandlingScenario.TOKEN_KYC_KT.asJKey());
    token.setSupplyKey(COMPLEX_KEY_ACCOUNT_KT.asJKey());
    token.setWipeKey(MISC_ACCOUNT_KT.asJKey());
    token.setFeeScheduleKey(MISC_ACCOUNT_KT.asJKey());
    token.setPauseKey(TxnHandlingScenario.TOKEN_PAUSE_KT.asJKey());
    token.setAutoRenewAccount(EntityId.fromGrpcAccountId(autoRenew));
    token.setExpiry(expiry);
    token.setAutoRenewPeriod(autoRenewPeriod);
    token.setDeleted(true);
    token.setPaused(true);
    token.setTokenType(TokenType.FUNGIBLE_COMMON);
    token.setSupplyType(TokenSupplyType.FINITE);
    token.setFeeScheduleFrom(grpcCustomFees);
    scheduleStore = mock(ScheduleStore.class);
    final var scheduleMemo = "For what but eye and ear";
    parentScheduleCreate = scheduleCreateTxnWith(SCHEDULE_ADMIN_KT.asKey(), scheduleMemo, payerAccountId, creatorAccountID, MiscUtils.asTimestamp(now.toJava()));
    schedule = MerkleSchedule.from(parentScheduleCreate.toByteArray(), expiry);
    schedule.witnessValidSignature("01234567890123456789012345678901".getBytes());
    schedule.witnessValidSignature("_123456789_123456789_123456789_1".getBytes());
    schedule.witnessValidSignature("_o23456789_o23456789_o23456789_o".getBytes());
    contents = mock(Map.class);
    attrs = mock(Map.class);
    bytecode = mock(Map.class);
    specialFiles = mock(MerkleSpecialFiles.class);
    mockTokenRelsFn = (BiFunction<StateView, EntityNum, List<TokenRelationship>>) mock(BiFunction.class);
    StateView.tokenRelsFn = mockTokenRelsFn;
    final var uniqueTokens = new MerkleMap<EntityNumPair, MerkleUniqueToken>();
    uniqueTokens.put(targetNftKey, targetNft);
    uniqueTokens.put(treasuryNftKey, treasuryNft);
    storage = (VirtualMap<VirtualBlobKey, VirtualBlobValue>) mock(VirtualMap.class);
    contractStorage = (VirtualMap<ContractKey, ContractValue>) mock(VirtualMap.class);
    children = new MutableStateChildren();
    children.setUniqueTokens(uniqueTokens);
    children.setAccounts(contracts);
    children.setTokenAssociations(tokenRels);
    children.setSpecialFiles(specialFiles);
    networkInfo = mock(NetworkInfo.class);
    subject = new StateView(tokenStore, scheduleStore, children, networkInfo);
    subject.fileAttrs = attrs;
    subject.fileContents = contents;
    subject.contractBytecode = bytecode;
}
Also used : NetworkInfo(com.hedera.services.config.NetworkInfo) MerkleToken(com.hedera.services.state.merkle.MerkleToken) MerkleAccount(com.hedera.services.state.merkle.MerkleAccount) MerkleTopic(com.hedera.services.state.merkle.MerkleTopic) EntityNum(com.hedera.services.utils.EntityNum) MerkleTokenRelStatus(com.hedera.services.state.merkle.MerkleTokenRelStatus) EntityId(com.hedera.services.state.submerkle.EntityId) MerkleSpecialFiles(com.hedera.services.state.merkle.MerkleSpecialFiles) ContractValue(com.hedera.services.state.virtual.ContractValue) MutableStateChildren(com.hedera.services.context.MutableStateChildren) ContractKey(com.hedera.services.state.virtual.ContractKey) HFileMeta(com.hedera.services.files.HFileMeta) MerkleMap(com.swirlds.merkle.map.MerkleMap) VirtualBlobValue(com.hedera.services.state.virtual.VirtualBlobValue) KeyList(com.hederahashgraph.api.proto.java.KeyList) List(java.util.List) TokenStore(com.hedera.services.store.tokens.TokenStore) ScheduleStore(com.hedera.services.store.schedule.ScheduleStore) Map(java.util.Map) VirtualMap(com.swirlds.virtualmap.VirtualMap) MerkleMap(com.swirlds.merkle.map.MerkleMap) VirtualBlobKey(com.hedera.services.state.virtual.VirtualBlobKey) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

MutableStateChildren (com.hedera.services.context.MutableStateChildren)11 StateView (com.hedera.services.context.primitives.StateView)10 BeforeEach (org.junit.jupiter.api.BeforeEach)9 MerkleMap (com.swirlds.merkle.map.MerkleMap)7 NodeLocalProperties (com.hedera.services.context.properties.NodeLocalProperties)4 AnswerFunctions (com.hedera.services.queries.answering.AnswerFunctions)4 OptionValidator (com.hedera.services.txns.validation.OptionValidator)4 MerkleTokenRelStatus (com.hedera.services.state.merkle.MerkleTokenRelStatus)3 NetworkInfo (com.hedera.services.config.NetworkInfo)2 RecordCache (com.hedera.services.records.RecordCache)2 MerkleToken (com.hedera.services.state.merkle.MerkleToken)2 ScheduleStore (com.hedera.services.store.schedule.ScheduleStore)2 TokenStore (com.hedera.services.store.tokens.TokenStore)2 EntityNum (com.hedera.services.utils.EntityNum)2 HFileMeta (com.hedera.services.files.HFileMeta)1 AliasManager (com.hedera.services.ledger.accounts.AliasManager)1 MerkleAccount (com.hedera.services.state.merkle.MerkleAccount)1 MerkleAccountTokens (com.hedera.services.state.merkle.MerkleAccountTokens)1 MerkleSpecialFiles (com.hedera.services.state.merkle.MerkleSpecialFiles)1 MerkleTopic (com.hedera.services.state.merkle.MerkleTopic)1