use of com.hederahashgraph.api.proto.java.TopicID in project hedera-services by hashgraph.
the class BaseHederaLedgerTestHelper method commonSetup.
protected void commonSetup() {
sideEffectsTracker = mock(SideEffectsTracker.class);
creator = mock(ExpiringCreations.class);
historian = mock(AccountRecordsHistorian.class);
ids = new EntityIdSource() {
long nextId = NEXT_ID;
@Override
public TopicID newTopicId(final AccountID sponsor) {
return TopicID.newBuilder().setTopicNum(nextId++).build();
}
@Override
public AccountID newAccountId(AccountID newAccountSponsor) {
return AccountID.newBuilder().setAccountNum(nextId++).build();
}
@Override
public ContractID newContractId(AccountID newContractSponsor) {
return ContractID.newBuilder().setContractNum(nextId++).build();
}
@Override
public FileID newFileId(AccountID newFileSponsor) {
return FileID.newBuilder().setFileNum(nextId++).build();
}
@Override
public TokenID newTokenId(AccountID sponsor) {
return TokenID.newBuilder().setTokenNum(nextId++).build();
}
@Override
public ScheduleID newScheduleId(AccountID sponsor) {
return ScheduleID.newBuilder().setScheduleNum(nextId++).build();
}
@Override
public void reclaimLastId() {
nextId--;
}
@Override
public void reclaimProvisionalIds() {
}
@Override
public void resetProvisionalIds() {
}
};
}
use of com.hederahashgraph.api.proto.java.TopicID in project hedera-services by hashgraph.
the class GetMerkleTopicInfoAnswerTest method syntaxCheckValidatesTidIfPresent.
@Test
void syntaxCheckValidatesTidIfPresent() {
// setup:
TopicID tid = asTopic(idLit);
// given:
ConsensusGetTopicInfoQuery op = ConsensusGetTopicInfoQuery.newBuilder().setTopicID(tid).build();
Query query = Query.newBuilder().setConsensusGetTopicInfo(op).build();
// and:
given(optionValidator.queryableTopicStatus(tid, topics)).willReturn(TOPIC_EXPIRED);
// when:
ResponseCodeEnum status = subject.checkValidity(query, view);
// expect:
assertEquals(TOPIC_EXPIRED, status);
}
use of com.hederahashgraph.api.proto.java.TopicID in project hedera-services by hashgraph.
the class GetMerkleTopicInfoAnswerTest method requiresOkMetaValidity.
@Test
void requiresOkMetaValidity() {
// setup:
TopicID id = asTopic(idLit);
// given:
ConsensusGetTopicInfoQuery op = ConsensusGetTopicInfoQuery.newBuilder().setTopicID(id).build();
Query query = Query.newBuilder().setConsensusGetTopicInfo(op).build();
// when:
Response response = subject.responseGiven(query, view, PLATFORM_NOT_ACTIVE);
ResponseCodeEnum status = response.getConsensusGetTopicInfo().getHeader().getNodeTransactionPrecheckCode();
// expect:
assertEquals(PLATFORM_NOT_ACTIVE, status);
assertEquals(id, response.getConsensusGetTopicInfo().getTopicID());
}
use of com.hederahashgraph.api.proto.java.TopicID in project hedera-services by hashgraph.
the class SeqNoEntityIdSourceTest method returnsExpectedTopicId.
@Test
void returnsExpectedTopicId() {
given(seqNo.getAndIncrement()).willReturn(222L);
TopicID id = subject.newTopicId(sponsor);
assertEquals(asTopic("1.2.222"), id);
}
use of com.hederahashgraph.api.proto.java.TopicID in project hedera-services by hashgraph.
the class MerkleTopicTest method topicFrom.
private MerkleTopic topicFrom(int s) throws IOException {
long v = 1_234_567L + s * 1_000_000L;
long t = s + 1;
AccountID payer = AccountID.newBuilder().setAccountNum(123).build();
TopicID id = TopicID.newBuilder().setTopicNum(s).build();
var topic = new MerkleTopic(memos[s], adminKeys[s], submitKeys[s], v, new EntityId(t, t * 2, t * 3), new RichInstant(v, s));
for (int i = 0; i < s; i++) {
topic.updateRunningHashAndSequenceNumber(payer, "Hello world!".getBytes(), id, Instant.ofEpochSecond(v, i));
}
topic.setKey(EntityNum.fromInt(s));
return topic;
}
Aggregations