use of com.hederahashgraph.api.proto.java.ContractFunctionResult in project hedera-services by hashgraph.
the class ContractFnResultAsserts method contractCallResult.
public ContractFnResultAsserts contractCallResult(ContractCallResult contractCallResult) {
registerProvider((spec, o) -> {
ContractFunctionResult result = (ContractFunctionResult) o;
Assertions.assertEquals(ByteString.copyFrom(contractCallResult.getBytes().toArray()), result.getContractCallResult(), "Wrong contract call result!");
});
return this;
}
use of com.hederahashgraph.api.proto.java.ContractFunctionResult in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerTokenTest method tokenSupplyNftsPrecompile.
private void tokenSupplyNftsPrecompile(boolean isMint) {
entityProperties.getPersist().setContractResults(true);
// given
createAndAssociateToken(TOKEN_ID, NON_FUNGIBLE_UNIQUE, SYMBOL, CREATE_TIMESTAMP, ASSOCIATE_TIMESTAMP, PAYER2, false, false, false, 0);
long timestamp = 10L;
TokenTransferList mintTransfer = nftTransfer(TOKEN_ID, PAYER, DEFAULT_ACCOUNT_ID, SERIAL_NUMBER_LIST);
Transaction transaction = tokenSupplyTransaction(TOKEN_ID, NON_FUNGIBLE_UNIQUE, isMint, 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 EntityRecordItemListenerContractTest method assertContractCreateResult.
private void assertContractCreateResult(ContractCreateTransactionBody transactionBody, TransactionRecord record) {
long consensusTimestamp = DomainUtils.timestampInNanosMax(record.getConsensusTimestamp());
TransactionReceipt receipt = record.getReceipt();
ContractFunctionResult result = record.getContractCreateResult();
ObjectAssert<ContractResult> contractResult = assertThat(contractResultRepository.findAll()).filteredOn(c -> c.getConsensusTimestamp().equals(consensusTimestamp)).hasSize(1).first().returns(transactionBody.getInitialBalance(), ContractResult::getAmount).returns(consensusTimestamp, ContractResult::getConsensusTimestamp).returns(EntityId.of(receipt.getContractID()), ContractResult::getContractId).returns(toBytes(transactionBody.getConstructorParameters()), ContractResult::getFunctionParameters).returns(transactionBody.getGas(), ContractResult::getGasLimit);
if (receipt.getStatus() == ResponseCodeEnum.SUCCESS) {
contractResult.returns(EntityId.of(receipt.getContractID()), ContractResult::getContractId);
}
assertContractResult(consensusTimestamp, result, result.getLogInfoList(), contractResult, result.getStateChangesList());
}
use of com.hederahashgraph.api.proto.java.ContractFunctionResult in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerContractTest method assertPartialContractCallResult.
private void assertPartialContractCallResult(ContractCallTransactionBody transactionBody, TransactionRecord record) {
long consensusTimestamp = DomainUtils.timestampInNanosMax(record.getConsensusTimestamp());
ContractFunctionResult result = record.getContractCallResult();
ObjectAssert<ContractResult> contractResult = assertThat(contractResultRepository.findAll()).filteredOn(c -> c.getConsensusTimestamp().equals(consensusTimestamp)).hasSize(1).first().returns(transactionBody.getAmount(), ContractResult::getAmount).returns(consensusTimestamp, ContractResult::getConsensusTimestamp).returns(EntityId.of(transactionBody.getContractID()), ContractResult::getContractId).returns(toBytes(transactionBody.getFunctionParameters()), ContractResult::getFunctionParameters).returns(transactionBody.getGas(), ContractResult::getGasLimit);
assertPartialContractResult(contractResult);
}
use of com.hederahashgraph.api.proto.java.ContractFunctionResult in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerTokenTest method tokenDissociatePrecompile.
@Test
void tokenDissociatePrecompile() {
createAndAssociateToken(TOKEN_ID, FUNGIBLE_COMMON, SYMBOL, CREATE_TIMESTAMP, ASSOCIATE_TIMESTAMP, PAYER2, false, false, false, INITIAL_SUPPLY);
Transaction dissociateTransaction = tokenDissociate(List.of(TOKEN_ID), PAYER2);
long dissociateTimeStamp = 10L;
AtomicReference<ContractFunctionResult> contractFunctionResultAtomic = new AtomicReference<>();
insertAndParseTransaction(dissociateTimeStamp, dissociateTransaction, builder -> {
buildContractFunctionResult(builder.getContractCallResultBuilder());
contractFunctionResultAtomic.set(builder.getContractCallResult());
});
assertTokenAccountInRepository(TOKEN_ID, PAYER2, ASSOCIATE_TIMESTAMP, dissociateTimeStamp, false, TokenFreezeStatusEnum.NOT_APPLICABLE, TokenKycStatusEnum.NOT_APPLICABLE);
assertContractResult(dissociateTimeStamp, contractFunctionResultAtomic.get());
}
Aggregations