use of com.hedera.mirror.common.domain.contract.Contract in project hedera-mirror-node by hashgraph.
the class ContractCreateTransactionHandlerTest method getUpdateEntityTestSpecsForCreateTransaction.
@Override
protected List<UpdateEntityTestSpec> getUpdateEntityTestSpecsForCreateTransaction(Descriptors.FieldDescriptor memoField) {
List<UpdateEntityTestSpec> testSpecs = super.getUpdateEntityTestSpecsForCreateTransaction(memoField);
TransactionBody body = getTransactionBodyForUpdateEntityWithoutMemo();
Message innerBody = getInnerBody(body);
body = getTransactionBody(body, innerBody);
byte[] evmAddress = TestUtils.generateRandomByteArray(20);
var contractCreateResult = ContractFunctionResult.newBuilder().setEvmAddress(BytesValue.of(ByteString.copyFrom(evmAddress)));
var recordBuilder = getDefaultTransactionRecord().setContractCreateResult(contractCreateResult);
AbstractEntity expected = getExpectedUpdatedEntity();
((Contract) expected).setEvmAddress(evmAddress);
expected.setMemo("");
testSpecs.add(UpdateEntityTestSpec.builder().description("create contract entity with evm address in record").expected(expected).recordItem(getRecordItem(body, recordBuilder.build())).build());
return testSpecs;
}
use of com.hedera.mirror.common.domain.contract.Contract in project hedera-mirror-node by hashgraph.
the class ContractDeleteTransactionHandlerTest method getUpdateEntityTestSpecs.
@Override
protected List<UpdateEntityTestSpec> getUpdateEntityTestSpecs() {
List<UpdateEntityTestSpec> specs = new ArrayList<>();
Contract expected = (Contract) getExpectedEntityWithTimestamp();
expected.setDeleted(true);
expected.setObtainerId(EntityId.of(OBTAINER_NUM, EntityType.ACCOUNT));
expected.setPermanentRemoval(false);
specs.add(UpdateEntityTestSpec.builder().description("Delete with account obtainer").expected(expected).recordItem(getRecordItem(getDefaultTransactionBody().build(), getDefaultTransactionRecord().build())).build());
TransactionBody.Builder transactionBody = TransactionBody.newBuilder().setContractDeleteInstance(ContractDeleteTransactionBody.newBuilder().setContractID(ContractID.newBuilder().setContractNum(DEFAULT_ENTITY_NUM).build()).setPermanentRemoval(true).setTransferContractID(ContractID.newBuilder().setContractNum(OBTAINER_NUM).build()));
expected = TestUtils.clone(expected);
expected.setPermanentRemoval(true);
specs.add(UpdateEntityTestSpec.builder().description("Delete with contract obtainer and permanent removal").expected(expected).recordItem(getRecordItem(transactionBody.build(), getDefaultTransactionRecord().build())).build());
return specs;
}
use of com.hedera.mirror.common.domain.contract.Contract in project hedera-mirror-node by hashgraph.
the class ContractUpdateTransactionHandlerTest method updateTransactionWithAliasNotFoundAndPartialDataActionSkip.
@Test
void updateTransactionWithAliasNotFoundAndPartialDataActionSkip() {
recordParserProperties.setPartialDataAction(PartialDataAction.SKIP);
var alias = DomainUtils.fromBytes(domainBuilder.key());
var recordItem = recordItemBuilder.contractUpdate().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));
transactionHandler.updateTransaction(transaction, recordItem);
assertContractUpdate(timestamp, contractId, t -> assertThat(t).returns(null, Contract::getAutoRenewAccountId).satisfies(c -> assertThat(c.getAutoRenewPeriod()).isPositive()).satisfies(c -> assertThat(c.getExpirationTimestamp()).isPositive()).satisfies(c -> assertThat(c.getKey()).isNotEmpty()).satisfies(c -> assertThat(c.getMaxAutomaticTokenAssociations()).isPositive()).satisfies(c -> assertThat(c.getMemo()).isNotEmpty()).satisfies(c -> assertThat(c.getPublicKey()).isNotEmpty()).satisfies(c -> assertThat(c.getProxyAccountId().getId()).isPositive()));
}
use of com.hedera.mirror.common.domain.contract.Contract in project hedera-mirror-node by hashgraph.
the class ContractUpdateTransactionHandlerTest method updateTransactionDeclineReward.
@Test
void updateTransactionDeclineReward() {
RecordItemBuilder recordItemBuilder = new RecordItemBuilder();
RecordItem withDeclineValueSet = recordItemBuilder.contractUpdate().transactionBody(body -> body.setDeclineReward(BoolValue.of(false)).clearStakedAccountId().clearStakedNodeId()).build();
setupForContractUpdateTransactionTest(withDeclineValueSet, t -> assertThat(t).returns(false, Contract::isDeclineReward).returns(null, Contract::getStakedNodeId).returns(null, Contract::getStakedAccountId).returns(Utility.getEpochDay(withDeclineValueSet.getConsensusTimestamp()), Contract::getStakePeriodStart));
}
Aggregations