use of com.hederahashgraph.api.proto.java.TopicID in project hedera-services by hashgraph.
the class HapiTopicDelete method resolveTopicId.
private TopicID resolveTopicId(HapiApiSpec spec) {
if (topicFn.isPresent()) {
TopicID topicID = topicFn.get().apply(spec);
topic = Optional.of(HapiPropertySource.asTopicString(topicID));
return topicID;
}
if (topic.isPresent()) {
return asTopicId(topic.get(), spec);
}
return TopicID.getDefaultInstance();
}
use of com.hederahashgraph.api.proto.java.TopicID in project hedera-mirror-node by hashgraph.
the class ConsensusUpdateTopicTransactionHandlerTest method updateTransactionThrowsWithAliasNotFound.
@ParameterizedTest(name = "{0}")
@EnumSource(value = PartialDataAction.class, names = { "DEFAULT", "ERROR" })
void updateTransactionThrowsWithAliasNotFound(PartialDataAction partialDataAction) {
// given
recordParserProperties.setPartialDataAction(partialDataAction);
var alias = DomainUtils.fromBytes(domainBuilder.key());
var recordItem = recordItemBuilder.consensusUpdateTopic().transactionBody(b -> b.getAutoRenewAccountBuilder().setAlias(alias)).build();
var topicId = EntityId.of(recordItem.getTransactionBody().getConsensusUpdateTopic().getTopicID());
var timestamp = recordItem.getConsensusTimestamp();
var transaction = domainBuilder.transaction().customize(t -> t.consensusTimestamp(timestamp).entityId(topicId)).get();
when(entityIdService.lookup(AccountID.newBuilder().setAlias(alias).build())).thenThrow(new AliasNotFoundException("alias", ACCOUNT));
// when, then
assertThrows(AliasNotFoundException.class, () -> transactionHandler.updateTransaction(transaction, recordItem));
}
use of com.hederahashgraph.api.proto.java.TopicID in project hedera-mirror-node by hashgraph.
the class PubSubRecordItemListenerTest method testPubSubMessageNullEntityId.
@Test
void testPubSubMessageNullEntityId() throws Exception {
// given
byte[] message = new byte[] { 'a', 'b', 'c' };
TopicID topicID = TopicID.newBuilder().setTopicNum(10L).build();
EntityId topicIdEntity = EntityId.of(topicID);
ConsensusSubmitMessageTransactionBody submitMessage = ConsensusSubmitMessageTransactionBody.newBuilder().setMessage(ByteString.copyFrom(message)).setTopicID(topicID).build();
Transaction transaction = buildTransaction(builder -> builder.setConsensusSubmitMessage(submitMessage));
// when
doReturn(null).when(transactionHandler).getEntity(any());
pubSubRecordItemListener.onItem(new RecordItem(transaction, DEFAULT_RECORD));
// then
var pubSubMessage = assertPubSubMessage(buildPubSubTransaction(transaction), 1);
assertThat(pubSubMessage.getEntity()).isEqualTo(null);
assertThat(pubSubMessage.getNonFeeTransfers()).isNull();
}
use of com.hederahashgraph.api.proto.java.TopicID in project hedera-mirror-node by hashgraph.
the class ConsensusControllerTest method missingTopicID.
@Test
void missingTopicID() {
ConsensusTopicQuery query = ConsensusTopicQuery.newBuilder().build();
grpcConsensusService.subscribeTopic(Mono.just(query)).as(StepVerifier::create).expectErrorSatisfies(t -> assertException(t, Status.Code.INVALID_ARGUMENT, "topicId: must not be null")).verify(Duration.ofMillis(500));
}
use of com.hederahashgraph.api.proto.java.TopicID in project hedera-services by hashgraph.
the class TxnReceipt method fromGrpc.
/* --- Helpers --- */
public static TxnReceipt fromGrpc(TransactionReceipt grpc) {
final var effRates = grpc.hasExchangeRate() ? ExchangeRates.fromGrpc(grpc.getExchangeRate()) : null;
String status = grpc.getStatus() != null ? grpc.getStatus().name() : null;
EntityId accountId = grpc.hasAccountID() ? EntityId.fromGrpcAccountId(grpc.getAccountID()) : null;
EntityId jFileID = grpc.hasFileID() ? EntityId.fromGrpcFileId(grpc.getFileID()) : null;
EntityId jContractID = grpc.hasContractID() ? EntityId.fromGrpcContractId(grpc.getContractID()) : null;
EntityId topicId = grpc.hasTopicID() ? EntityId.fromGrpcTopicId(grpc.getTopicID()) : null;
EntityId tokenId = grpc.hasTokenID() ? EntityId.fromGrpcTokenId(grpc.getTokenID()) : null;
EntityId scheduleId = grpc.hasScheduleID() ? EntityId.fromGrpcScheduleId(grpc.getScheduleID()) : null;
long runningHashVersion = Math.max(MISSING_RUNNING_HASH_VERSION, grpc.getTopicRunningHashVersion());
long newTotalSupply = grpc.getNewTotalSupply();
long[] serialNumbers = grpc.getSerialNumbersList().stream().mapToLong(l -> l).toArray();
TxnId scheduledTxnId = grpc.hasScheduledTransactionID() ? TxnId.fromGrpc(grpc.getScheduledTransactionID()) : MISSING_SCHEDULED_TXN_ID;
return TxnReceipt.newBuilder().setStatus(status).setAccountId(accountId).setFileId(jFileID).setContractId(jContractID).setTokenId(tokenId).setScheduleId(scheduleId).setExchangeRates(effRates).setTopicId(topicId).setTopicSequenceNumber(grpc.getTopicSequenceNumber()).setTopicRunningHash(grpc.getTopicRunningHash().toByteArray()).setRunningHashVersion(runningHashVersion).setNewTotalSupply(newTotalSupply).setScheduledTxnId(scheduledTxnId).setSerialNumbers(serialNumbers).build();
}
Aggregations