use of com.hederahashgraph.api.proto.java.TransactionID in project hedera-services by hashgraph.
the class ScheduleSignResourceUsageTest method returnsDefaultIfInfoMissing.
@Test
void returnsDefaultIfInfoMissing() throws Exception {
// setup:
long start = 1_234_567L;
TransactionID txnId = TransactionID.newBuilder().setTransactionValidStart(Timestamp.newBuilder().setSeconds(start)).build();
given(scheduleSignTxn.getTransactionID()).willReturn(txnId);
given(view.infoForSchedule(target)).willReturn(Optional.empty());
given(scheduleOpsUsage.scheduleSignUsage(scheduleSignTxn, sigUsage, start + 1800)).willReturn(expected);
// expect:
assertEquals(expected, subject.usageGiven(scheduleSignTxn, obj, view));
// and:
verify(view).infoForSchedule(target);
}
use of com.hederahashgraph.api.proto.java.TransactionID in project hedera-services by hashgraph.
the class ContextOptionValidatorTest method recognizesExpiredCondition.
@Test
void recognizesExpiredCondition() {
SignedTxnAccessor accessor = mock(SignedTxnAccessor.class);
// given:
long validDuration = 1_000L;
Instant validStart = Instant.ofEpochSecond(1_234_567L);
Instant consensusTime = Instant.ofEpochSecond(validStart.getEpochSecond() + validDuration + 1);
// and:
TransactionID txnId = TransactionID.newBuilder().setTransactionValidStart(Timestamp.newBuilder().setSeconds(validStart.getEpochSecond())).build();
TransactionBody txn = TransactionBody.newBuilder().setTransactionID(txnId).setTransactionValidDuration(Duration.newBuilder().setSeconds(validDuration)).build();
// and:
given(accessor.getTxn()).willReturn(txn);
given(accessor.getTxnId()).willReturn(txnId);
// when:
ResponseCodeEnum status = subject.chronologyStatus(accessor, consensusTime);
// then:
assertEquals(TRANSACTION_EXPIRED, status);
// and:
assertEquals(TRANSACTION_EXPIRED, subject.chronologyStatusForTxn(validStart, validDuration, consensusTime));
}
use of com.hederahashgraph.api.proto.java.TransactionID in project hedera-services by hashgraph.
the class HapiSpecOperation method registerTxnSubmitted.
private void registerTxnSubmitted(HapiApiSpec spec) throws Throwable {
if (txnSubmitted != Transaction.getDefaultInstance()) {
spec.registry().saveBytes(txnName, txnSubmitted.toByteString());
TransactionID txnId = extractTxnId(txnSubmitted);
spec.registry().saveTxnId(txnName, txnId);
}
}
use of com.hederahashgraph.api.proto.java.TransactionID in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerTopicTest method submitMessageTestInvalidChunkInfo.
@Test
void submitMessageTestInvalidChunkInfo() {
// given
var id = 10_000_000L;
var topicId = TopicID.newBuilder().setTopicNum(9000).build();
var scheduled = false;
var nonce = 0;
TransactionID initialTransactionId = createTransactionID(null, TestUtils.toTimestamp(Long.MAX_VALUE, Integer.MAX_VALUE), scheduled, nonce);
var transaction = createSubmitMessageTransaction(topicId, "message", 3, 5, initialTransactionId);
var transactionRecord = createTransactionRecord(topicId, 10_000L, "running-hash".getBytes(), 2, id, SUCCESS);
// when
parseRecordItemAndCommit(new RecordItem(transaction, transactionRecord));
// then
assertEquals(0L, entityRepository.count());
assertEquals(1L, topicMessageRepository.count());
assertThat(topicMessageRepository.findById(id)).get().extracting(TopicMessage::getValidStartTimestamp, TopicMessage::getPayerAccountId).containsExactly(null, PAYER_ACCOUNT_ID);
}
use of com.hederahashgraph.api.proto.java.TransactionID in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerTopicTest method submitMessageTest.
@ParameterizedTest
@CsvSource({ "0.0.9000, test-message0, 9000000, runninghash, 1, 1, , , , false, 0", "0.0.9001, test-message1, 9000001, runninghash1, 9223372036854775807, 2, 1, 1, 89999999, false, 0", "0.0.9001, test-message2, 9000001, runninghash2, 9223372036854775807, 2, 2, 4, 89999999, false, 0", "0.0.9001, test-message3, 9000001, runninghash3, 9223372036854775807, 2, 4, 4, 89999999, false, 0", "0.0.9001, test-message4, 9000001, runninghash3, 9223372036854775807, 2, 4, 4, 89999999, true, 7" })
void submitMessageTest(@ConvertWith(TopicIdArgumentConverter.class) TopicID topicId, String message, long consensusTimestamp, String runningHash, long sequenceNumber, int runningHashVersion, Integer chunkNum, Integer chunkTotal, Long validStartNs, Boolean scheduled, Integer nonce) {
var responseCode = SUCCESS;
TransactionID initialTransactionId = null;
if (chunkNum != null) {
initialTransactionId = createTransactionID(PAYER_ACCOUNT_ID.getEntityNum(), TestUtils.toTimestamp(validStartNs), scheduled, nonce);
}
var topicMessage = createTopicMessage(topicId, message, sequenceNumber, runningHash, consensusTimestamp, runningHashVersion, chunkNum, chunkTotal, PAYER_ACCOUNT_ID, initialTransactionId);
var transaction = createSubmitMessageTransaction(topicId, message, chunkNum, chunkTotal, initialTransactionId);
var transactionRecord = createTransactionRecord(topicId, sequenceNumber, runningHash.getBytes(), runningHashVersion, consensusTimestamp, responseCode);
parseRecordItemAndCommit(new RecordItem(transaction, transactionRecord));
assertTransactionInRepository(responseCode, consensusTimestamp, topicId.getTopicNum());
assertEquals(0L, entityRepository.count());
assertThat(topicMessageRepository.findById(consensusTimestamp)).get().isEqualTo(topicMessage);
}
Aggregations