use of com.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.
the class RecordFileParserTest method totalGasUsedMustBeCorrect.
@Test
void totalGasUsedMustBeCorrect() {
when(mirrorDateRangePropertiesProcessor.getDateRangeFilter(parserProperties.getStreamType())).thenReturn(DateRangeFilter.all());
long timestamp = ++count;
ContractFunctionResult contractFunctionResult1 = contractFunctionResult(10000000000L, new byte[] { 0, 6, 4, 0, 5, 7, 2 });
RecordItem recordItem1 = contractCreate(contractFunctionResult1, timestamp, 0);
ContractFunctionResult contractFunctionResult2 = contractFunctionResult(100000000000L, new byte[] { 3, 5, 1, 7, 4, 4, 0 });
RecordItem recordItem2 = contractCall(contractFunctionResult2, timestamp, 0);
ContractFunctionResult contractFunctionResult3 = contractFunctionResult(1000000000000L, new byte[] { 0, 1, 1, 2, 2, 6, 0 });
RecordItem recordItem3 = ethereumTransaction(contractFunctionResult3, timestamp, 0);
ContractFunctionResult contractFunctionResult4 = contractFunctionResult(1000000000000L, new byte[] { 0, 1, 1, 2, 2, 6, 0 });
RecordItem recordItem4 = ethereumTransaction(contractFunctionResult4, timestamp, 1);
RecordFile recordFile = getStreamFile(Flux.just(recordItem1, recordItem2, recordItem3, recordItem4), timestamp);
parser.parse(recordFile);
byte[] expectedLogBloom = new byte[] { 3, 7, 5, 7, 7, 7, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
assertAll(() -> assertEquals(10000000000L + 100000000000L + 1000000000000L, recordFile.getGasUsed()), () -> assertArrayEquals(expectedLogBloom, recordFile.getLogsBloom()), () -> verify(recordStreamFileListener, times(1)).onStart(), () -> verify(recordStreamFileListener, times(1)).onEnd(recordFile), () -> verify(recordItemListener, times(1)).onItem(recordItem1), () -> verify(recordItemListener, times(1)).onItem(recordItem2), () -> verify(recordItemListener, times(1)).onItem(recordItem3));
}
use of com.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.
the class AbstractEntityRecordItemListenerTest method parseRecordItemsAndCommit.
protected void parseRecordItemsAndCommit(List<RecordItem> recordItems) {
transactionTemplate.executeWithoutResult(status -> {
Instant instant = Instant.ofEpochSecond(0, recordItems.get(0).getConsensusTimestamp());
String filename = StreamFilename.getFilename(StreamType.RECORD, DATA, instant);
long consensusStart = recordItems.get(0).getConsensusTimestamp();
long consensusEnd = recordItems.get(recordItems.size() - 1).getConsensusTimestamp();
RecordFile recordFile = recordFile(consensusStart, consensusEnd, filename);
recordStreamFileListener.onStart();
// process each record item
for (RecordItem recordItem : recordItems) {
entityRecordItemListener.onItem(recordItem);
}
// commit, close connection
recordStreamFileListener.onEnd(recordFile);
});
}
use of com.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.
the class ContractCreateTransactionHandlerTest method updateTransactionStakedAccountId.
@Test
void updateTransactionStakedAccountId() {
// given
final AccountID accountID = AccountID.newBuilder().setAccountNum(1L).build();
var recordItem = recordItemBuilder.contractCreate().transactionBody(b -> b.clearAutoRenewAccountId().setDeclineReward(false).setStakedAccountId(accountID)).build();
// when
transactionHandler.updateTransaction(transaction(recordItem), recordItem);
// then
verify(entityListener).onContract(contracts.capture());
assertThat(contracts.getValue()).isNotNull().returns(false, Contract::isDeclineReward).returns(accountID.getAccountNum(), Contract::getStakedAccountId).returns(-1L, Contract::getStakedNodeId).returns(Utility.getEpochDay(recordItem.getConsensusTimestamp()), Contract::getStakePeriodStart);
}
use of com.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.
the class ContractCreateTransactionHandlerTest 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.contractCreate().transactionBody(b -> b.getAutoRenewAccountIdBuilder().setAlias(alias)).build();
var contractId = EntityId.of(recordItem.getRecord().getReceipt().getContractID());
var timestamp = recordItem.getConsensusTimestamp();
var transaction = domainBuilder.transaction().customize(t -> t.consensusTimestamp(timestamp).entityId(contractId)).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.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.
the class ContractUpdateTransactionHandlerTest method updateTransactionStakedAccountId.
@Test
void updateTransactionStakedAccountId() {
AccountID accountId = AccountID.newBuilder().setAccountNum(1L).build();
RecordItem withStakedNodeIdSet = recordItemBuilder.contractUpdate().transactionBody(body -> body.clear().setStakedAccountId(accountId)).build();
setupForContractUpdateTransactionTest(withStakedNodeIdSet, t -> assertThat(t).returns(1L, Contract::getStakedAccountId).returns(false, Contract::isDeclineReward).returns(-1L, Contract::getStakedNodeId).returns(Utility.getEpochDay(withStakedNodeIdSet.getConsensusTimestamp()), Contract::getStakePeriodStart));
}
Aggregations