use of com.hederahashgraph.api.proto.java.ContractFunctionResult in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerTokenTest method tokenBurnNftsPrecompile.
@Test
void tokenBurnNftsPrecompile() {
long mintTimestamp = 10L;
tokenSupplyMintNftsPrecompile(mintTimestamp);
long burnTimestamp = 15L;
Transaction transaction = tokenSupplyTransaction(TOKEN_ID, NON_FUNGIBLE_UNIQUE, false, 0, SERIAL_NUMBER_LIST);
AtomicReference<ContractFunctionResult> contractFunctionResultAtomic = new AtomicReference<>();
insertAndParseTransaction(burnTimestamp, transaction, builder -> {
builder.getReceiptBuilder().setNewTotalSupply(SERIAL_NUMBER_LIST.size()).addAllSerialNumbers(SERIAL_NUMBER_LIST);
buildContractFunctionResult(builder.getContractCallResultBuilder());
contractFunctionResultAtomic.set(builder.getContractCallResult());
});
assertNftInRepository(TOKEN_ID, SERIAL_NUMBER_1, true, mintTimestamp, burnTimestamp, METADATA.getBytes(), null, true);
assertNftInRepository(TOKEN_ID, SERIAL_NUMBER_2, true, mintTimestamp, burnTimestamp, METADATA.getBytes(), null, true);
assertContractResult(burnTimestamp, contractFunctionResultAtomic.get());
}
use of com.hederahashgraph.api.proto.java.ContractFunctionResult in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerTokenTest method tokenSupplyFtsPrecompile.
private void tokenSupplyFtsPrecompile(boolean isMint) {
createAndAssociateToken(TOKEN_ID, FUNGIBLE_COMMON, SYMBOL, CREATE_TIMESTAMP, ASSOCIATE_TIMESTAMP, PAYER2, false, false, false, INITIAL_SUPPLY);
long amount = 1000;
long mintTimestamp = 10L;
TokenTransferList tokenTransfer = tokenTransfer(TOKEN_ID, PAYER, amount);
Transaction transaction = tokenSupplyTransaction(TOKEN_ID, FUNGIBLE_COMMON, isMint, amount, null);
AtomicReference<ContractFunctionResult> contractFunctionResultAtomic = new AtomicReference<>();
insertAndParseTransaction(mintTimestamp, transaction, builder -> {
builder.getReceiptBuilder().setNewTotalSupply(INITIAL_SUPPLY + amount);
builder.addTokenTransferLists(tokenTransfer);
buildContractFunctionResult(builder.getContractCallResultBuilder());
contractFunctionResultAtomic.set(builder.getContractCallResult());
});
// Verify
assertThat(tokenTransferRepository.count()).isEqualTo(2L);
assertTokenTransferInRepository(TOKEN_ID, PAYER, CREATE_TIMESTAMP, INITIAL_SUPPLY);
assertTokenTransferInRepository(TOKEN_ID, PAYER, mintTimestamp, amount);
assertTokenInRepository(TOKEN_ID, true, CREATE_TIMESTAMP, mintTimestamp, SYMBOL, INITIAL_SUPPLY + amount);
assertContractResult(mintTimestamp, contractFunctionResultAtomic.get());
}
use of com.hederahashgraph.api.proto.java.ContractFunctionResult in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerTokenTest method tokenSupplyMintNftsPrecompile.
private void tokenSupplyMintNftsPrecompile(long timestamp) {
// given
createAndAssociateToken(TOKEN_ID, NON_FUNGIBLE_UNIQUE, SYMBOL, CREATE_TIMESTAMP, ASSOCIATE_TIMESTAMP, PAYER2, false, false, false, 0);
TokenTransferList mintTransfer = nftTransfer(TOKEN_ID, PAYER, DEFAULT_ACCOUNT_ID, SERIAL_NUMBER_LIST);
Transaction transaction = tokenSupplyTransaction(TOKEN_ID, NON_FUNGIBLE_UNIQUE, true, 0, SERIAL_NUMBER_LIST);
// when
AtomicReference<ContractFunctionResult> contractFunctionResultAtomic = new AtomicReference<>();
insertAndParseTransaction(timestamp, transaction, builder -> {
builder.getReceiptBuilder().setNewTotalSupply(SERIAL_NUMBER_LIST.size()).addAllSerialNumbers(SERIAL_NUMBER_LIST);
builder.addTokenTransferLists(mintTransfer);
buildContractFunctionResult(builder.getContractCallResultBuilder());
contractFunctionResultAtomic.set(builder.getContractCallResult());
});
// then
assertThat(nftTransferRepository.count()).isEqualTo(2L);
assertNftTransferInRepository(timestamp, SERIAL_NUMBER_2, TOKEN_ID, PAYER, null);
assertNftTransferInRepository(timestamp, SERIAL_NUMBER_1, TOKEN_ID, PAYER, null);
assertTokenInRepository(TOKEN_ID, true, CREATE_TIMESTAMP, timestamp, SYMBOL, 2);
assertNftInRepository(TOKEN_ID, SERIAL_NUMBER_1, true, timestamp, timestamp, METADATA.getBytes(), EntityId.of(PAYER), false);
assertNftInRepository(TOKEN_ID, SERIAL_NUMBER_2, true, timestamp, timestamp, METADATA.getBytes(), EntityId.of(PAYER), false);
assertContractResult(timestamp, contractFunctionResultAtomic.get());
}
use of com.hederahashgraph.api.proto.java.ContractFunctionResult in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerTokenTest method tokenAssociatePrecompile.
@Test
void tokenAssociatePrecompile() {
createTokenEntity(TOKEN_ID, FUNGIBLE_COMMON, SYMBOL, CREATE_TIMESTAMP, true, true, true);
Transaction associateTransaction = tokenAssociate(List.of(TOKEN_ID), PAYER2);
AtomicReference<ContractFunctionResult> contractFunctionResultAtomic = new AtomicReference<>();
insertAndParseTransaction(ASSOCIATE_TIMESTAMP, associateTransaction, builder -> {
buildContractFunctionResult(builder.getContractCallResultBuilder());
contractFunctionResultAtomic.set(builder.getContractCallResult());
});
assertTokenAccountInRepository(TOKEN_ID, PAYER2, ASSOCIATE_TIMESTAMP, ASSOCIATE_TIMESTAMP, true, TokenFreezeStatusEnum.UNFROZEN, TokenKycStatusEnum.REVOKED);
assertContractResult(ASSOCIATE_TIMESTAMP, contractFunctionResultAtomic.get());
}
use of com.hederahashgraph.api.proto.java.ContractFunctionResult 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));
}
Aggregations