use of com.hederahashgraph.api.proto.java.ContractID in project hedera-services by hashgraph.
the class UtilVerbs method contractListWithPropertiesInheritedFrom.
public static HapiSpecOperation contractListWithPropertiesInheritedFrom(final String contractList, final long expectedSize, final String parent) {
return withOpContext((spec, ctxLog) -> {
List<HapiSpecOperation> opsList = new ArrayList<HapiSpecOperation>();
long contractListSize = spec.registry().getAmount(contractList + "Size");
Assertions.assertEquals(expectedSize, contractListSize, contractList + " has bad size!");
if (contractListSize > 1) {
ContractID currentID = spec.registry().getContractId(contractList + "0");
long nextIndex = 1;
while (nextIndex < contractListSize) {
ContractID nextID = spec.registry().getContractId(contractList + nextIndex);
Assertions.assertEquals(currentID.getShardNum(), nextID.getShardNum());
Assertions.assertEquals(currentID.getRealmNum(), nextID.getRealmNum());
Assertions.assertTrue(currentID.getContractNum() < nextID.getContractNum());
currentID = nextID;
nextIndex++;
}
}
for (long i = 0; i < contractListSize; i++) {
HapiSpecOperation op = getContractInfo(contractList + i).has(contractWith().propertiesInheritedFrom(parent)).logged();
opsList.add(op);
}
CustomSpecAssert.allRunFor(spec, opsList);
});
}
use of com.hederahashgraph.api.proto.java.ContractID in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerContractTest method setupContract.
private SetupResult setupContract(ContractID contractId, ContractIdType contractIdType, boolean persist, boolean cache, Consumer<Contract.ContractBuilder> customizer) {
EntityId entityId = EntityId.of(contractId);
byte[] evmAddress = getEvmAddress(contractIdType, entityId);
ContractID protoContractId = getContractId(CONTRACT_ID, evmAddress);
var builder = domainBuilder.contract().customize(c -> c.evmAddress(evmAddress).id(entityId.getId()).num(entityId.getEntityNum()));
if (customizer != null) {
builder.customize(customizer);
}
Contract contract = persist ? builder.persist() : builder.get();
if (cache) {
contractIds.put(protoContractId, entityId);
}
return new SetupResult(contract, protoContractId);
}
use of com.hederahashgraph.api.proto.java.ContractID in project hedera-mirror-node by hashgraph.
the class NonFeeTransferExtractionStrategyImplTest method extractNonFeeTransfersContractCallReceipt.
@Test
void extractNonFeeTransfersContractCallReceipt() {
var amount = 123456L;
var contractNum = 8888L;
ContractID contractIdBody = ContractID.newBuilder().setContractNum(-1L).build();
ContractID contractIdReceipt = ContractID.newBuilder().setContractNum(contractNum).build();
var transactionBody = getContractCallTransactionBody(-1L, amount);
var contractCallResult = ContractFunctionResult.newBuilder().setContractID(contractIdReceipt);
var receipt = TransactionReceipt.newBuilder().setContractID(contractIdReceipt).setStatus(ResponseCodeEnum.SUCCESS);
var transactionRecord = TransactionRecord.newBuilder().setReceipt(receipt).setContractCallResult(contractCallResult).build();
when(entityIdService.lookup(contractIdReceipt, contractIdBody)).thenReturn(EntityId.of(contractIdReceipt));
var result = extractionStrategy.extractNonFeeTransfers(transactionBody, transactionRecord);
assertAll(() -> assertEquals(2, StreamSupport.stream(result.spliterator(), false).count()), () -> assertResult(createAccountAmounts(contractNum, amount, payerAccountNum, -amount), result));
}
use of com.hederahashgraph.api.proto.java.ContractID in project hedera-mirror-node by hashgraph.
the class NonFeeTransferExtractionStrategyImplTest method extractNonFeeTransfersContractCallBody.
@Test
void extractNonFeeTransfersContractCallBody() {
var amount = 123456L;
var contractNum = 8888L;
ContractID contractId = ContractID.newBuilder().setContractNum(contractNum).build();
var transactionBody = getContractCallTransactionBody(contractNum, amount);
var contractCallResult = ContractFunctionResult.newBuilder().setContractID(contractId);
var transactionRecord = getSimpleTransactionRecord().toBuilder().setContractCallResult(contractCallResult).build();
when(entityIdService.lookup(ContractID.getDefaultInstance(), contractId)).thenReturn(EntityId.of(contractId));
var result = extractionStrategy.extractNonFeeTransfers(transactionBody, transactionRecord);
assertAll(() -> assertEquals(2, StreamSupport.stream(result.spliterator(), false).count()), () -> assertResult(createAccountAmounts(contractNum, amount, payerAccountNum, -amount), result));
}
use of com.hederahashgraph.api.proto.java.ContractID in project hedera-mirror-node by hashgraph.
the class ContractUpdateTransactionHandlerTest method testGetEntityIdReceipt.
@Test
void testGetEntityIdReceipt() {
var recordItem = recordItemBuilder.contractUpdate().build();
ContractID contractIdBody = recordItem.getTransactionBody().getContractUpdateInstance().getContractID();
ContractID contractIdReceipt = recordItem.getRecord().getReceipt().getContractID();
EntityId expectedEntityId = EntityId.of(contractIdReceipt);
when(entityIdService.lookup(contractIdReceipt, contractIdBody)).thenReturn(expectedEntityId);
EntityId entityId = transactionHandler.getEntity(recordItem);
assertThat(entityId).isEqualTo(expectedEntityId);
}
Aggregations