Search in sources :

Example 6 with StateView

use of com.hedera.services.context.primitives.StateView 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 StateView

use of com.hedera.services.context.primitives.StateView 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 StateView

use of com.hedera.services.context.primitives.StateView 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 StateView

use of com.hedera.services.context.primitives.StateView 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 StateView

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

the class GetAccountInfoAnswerTest method identifiesFailInvalid.

@Test
void identifiesFailInvalid() throws Throwable {
    // setup:
    Query query = validQuery(ANSWER_ONLY, fee, target);
    // and:
    StateView view = mock(StateView.class);
    given(view.infoForAccount(any(), any())).willReturn(Optional.empty());
    // when:
    Response response = subject.responseGiven(query, view, OK, fee);
    // then:
    assertTrue(response.hasCryptoGetInfo());
    assertEquals(FAIL_INVALID, response.getCryptoGetInfo().getHeader().getNodeTransactionPrecheckCode());
    assertEquals(ANSWER_ONLY, response.getCryptoGetInfo().getHeader().getResponseType());
}
Also used : CryptoGetInfoResponse(com.hederahashgraph.api.proto.java.CryptoGetInfoResponse) Response(com.hederahashgraph.api.proto.java.Response) CryptoGetInfoQuery(com.hederahashgraph.api.proto.java.CryptoGetInfoQuery) Query(com.hederahashgraph.api.proto.java.Query) StateView(com.hedera.services.context.primitives.StateView) Test(org.junit.jupiter.api.Test)

Aggregations

StateView (com.hedera.services.context.primitives.StateView)11 MutableStateChildren (com.hedera.services.context.MutableStateChildren)10 BeforeEach (org.junit.jupiter.api.BeforeEach)8 MerkleMap (com.swirlds.merkle.map.MerkleMap)6 NodeLocalProperties (com.hedera.services.context.properties.NodeLocalProperties)4 AnswerFunctions (com.hedera.services.queries.answering.AnswerFunctions)4 OptionValidator (com.hedera.services.txns.validation.OptionValidator)4 RecordCache (com.hedera.services.records.RecordCache)2 MerkleTokenRelStatus (com.hedera.services.state.merkle.MerkleTokenRelStatus)2 NetworkInfo (com.hedera.services.config.NetworkInfo)1 AliasManager (com.hedera.services.ledger.accounts.AliasManager)1 MerkleAccountTokens (com.hedera.services.state.merkle.MerkleAccountTokens)1 MerkleToken (com.hedera.services.state.merkle.MerkleToken)1 FcTokenAllowance (com.hedera.services.state.submerkle.FcTokenAllowance)1 FcTokenAllowanceId (com.hedera.services.state.submerkle.FcTokenAllowanceId)1 ScheduleStore (com.hedera.services.store.schedule.ScheduleStore)1 TokenStore (com.hedera.services.store.tokens.TokenStore)1 EntityNum (com.hedera.services.utils.EntityNum)1 CryptoGetInfoQuery (com.hederahashgraph.api.proto.java.CryptoGetInfoQuery)1 CryptoGetInfoResponse (com.hederahashgraph.api.proto.java.CryptoGetInfoResponse)1