Search in sources :

Example 16 with ContractFunctionResult

use of com.hederahashgraph.api.proto.java.ContractFunctionResult in project hedera-mirror-node by hashgraph.

the class ContractResultMigrationTest method migrate.

@SuppressWarnings("deprecation")
@Test
void migrate() throws Exception {
    ContractFunctionResult.Builder functionResult = contractFunctionResult();
    MigrationContractResult contractResult = contractResult(functionResult);
    insert(contractResult);
    contractResultMigration.doMigrate();
    ContractLoginfo loginfo = functionResult.getLogInfo(0);
    assertThat(getContractLogs()).hasSize(1).first().returns(loginfo.getBloom().toByteArray(), MigrationContractLog::getBloom).returns(contractResult.getConsensusTimestamp(), MigrationContractLog::getConsensusTimestamp).returns(loginfo.getContractID().getContractNum(), MigrationContractLog::getContractId).returns(0, MigrationContractLog::getIndex).returns(Hex.encodeHexString(loginfo.getTopic(0).toByteArray()), MigrationContractLog::getTopic0).returns(Hex.encodeHexString(loginfo.getTopic(1).toByteArray()), MigrationContractLog::getTopic1).returns(Hex.encodeHexString(loginfo.getTopic(2).toByteArray()), MigrationContractLog::getTopic2).returns(Hex.encodeHexString(loginfo.getTopic(3).toByteArray()), MigrationContractLog::getTopic3);
    assertThat(getContractResults()).hasSize(1).first().returns(functionResult.getBloom().toByteArray(), MigrationContractResult::getBloom).returns(contractResult.getConsensusTimestamp(), MigrationContractResult::getConsensusTimestamp).returns(functionResult.getContractCallResult().toByteArray(), MigrationContractResult::getCallResult).returns(functionResult.getContractID().getContractNum(), MigrationContractResult::getContractId).returns(functionResult.getErrorMessage(), MigrationContractResult::getErrorMessage).returns(functionResult.getCreatedContractIDsList().stream().map(EntityId::of).map(EntityId::getId).toArray(Long[]::new), MigrationContractResult::getCreatedContractIds);
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) ContractFunctionResult(com.hederahashgraph.api.proto.java.ContractFunctionResult) MigrationContractResult(com.hedera.mirror.importer.migration.ContractResultMigration.MigrationContractResult) MigrationContractLog(com.hedera.mirror.importer.migration.ContractResultMigration.MigrationContractLog) ContractLoginfo(com.hederahashgraph.api.proto.java.ContractLoginfo) Test(org.junit.jupiter.api.Test) IntegrationTest(com.hedera.mirror.importer.IntegrationTest)

Example 17 with ContractFunctionResult

use of com.hederahashgraph.api.proto.java.ContractFunctionResult in project hedera-mirror-node by hashgraph.

the class ContractResultMigrationTest method migrateWhenEmptyTopic.

@Test
void migrateWhenEmptyTopic() throws Exception {
    ContractFunctionResult.Builder functionResult = contractFunctionResult();
    functionResult.setLogInfo(0, functionResult.getLogInfoBuilder(0).clearTopic().addTopic(ByteString.copyFrom(new byte[0])));
    MigrationContractResult contractResult = contractResult(functionResult);
    insert(contractResult);
    contractResultMigration.doMigrate();
    assertThat(getContractLogs()).hasSize(1).first().returns("", MigrationContractLog::getTopic0).returns(null, MigrationContractLog::getTopic1).returns(null, MigrationContractLog::getTopic2).returns(null, MigrationContractLog::getTopic3);
}
Also used : ContractFunctionResult(com.hederahashgraph.api.proto.java.ContractFunctionResult) MigrationContractResult(com.hedera.mirror.importer.migration.ContractResultMigration.MigrationContractResult) MigrationContractLog(com.hedera.mirror.importer.migration.ContractResultMigration.MigrationContractLog) Test(org.junit.jupiter.api.Test) IntegrationTest(com.hedera.mirror.importer.IntegrationTest)

Example 18 with ContractFunctionResult

use of com.hederahashgraph.api.proto.java.ContractFunctionResult in project hedera-mirror-node by hashgraph.

the class ContractResultMigrationTest method migrateWhenEmptyContractIDs.

@Test
void migrateWhenEmptyContractIDs() throws Exception {
    ContractFunctionResult.Builder functionResult = contractFunctionResult().clearContractID().clearCreatedContractIDs().addCreatedContractIDs(ContractID.getDefaultInstance());
    MigrationContractResult contractResult = contractResult(functionResult);
    insert(contractResult);
    contractResultMigration.doMigrate();
    assertThat(getContractResults()).hasSize(1).first().returns(null, MigrationContractResult::getContractId).returns(new Long[] { null }, MigrationContractResult::getCreatedContractIds);
}
Also used : ContractFunctionResult(com.hederahashgraph.api.proto.java.ContractFunctionResult) MigrationContractResult(com.hedera.mirror.importer.migration.ContractResultMigration.MigrationContractResult) Test(org.junit.jupiter.api.Test) IntegrationTest(com.hedera.mirror.importer.IntegrationTest)

Example 19 with ContractFunctionResult

use of com.hederahashgraph.api.proto.java.ContractFunctionResult in project hedera-mirror-node by hashgraph.

the class ContractResultServiceImplIntegrationTest method contractResultZeroLogs.

@Test
void contractResultZeroLogs() {
    RecordItem recordItem = recordItemBuilder.contractCall().record(x -> x.setContractCallResult(recordItemBuilder.contractFunctionResult(CONTRACT_ID).clearLogInfo())).build();
    ContractFunctionResult contractFunctionResult = recordItem.getRecord().getContractCallResult();
    contractResultsTest(recordItem, contractFunctionResult);
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) ContractResultRepository(com.hedera.mirror.importer.repository.ContractResultRepository) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RequiredArgsConstructor(lombok.RequiredArgsConstructor) Autowired(org.springframework.beans.factory.annotation.Autowired) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) ContractID(com.hederahashgraph.api.proto.java.ContractID) DomainBuilder(com.hedera.mirror.common.domain.DomainBuilder) RecordFile(com.hedera.mirror.common.domain.transaction.RecordFile) ContractStateChangeRepository(com.hedera.mirror.importer.repository.ContractStateChangeRepository) RecordItemBuilder(com.hedera.mirror.importer.parser.domain.RecordItemBuilder) ContractResult(com.hedera.mirror.common.domain.contract.ContractResult) DomainUtils(com.hedera.mirror.common.util.DomainUtils) ContractStateChange(com.hedera.mirror.common.domain.contract.ContractStateChange) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) RecordStreamFileListener(com.hedera.mirror.importer.parser.record.RecordStreamFileListener) DATA(com.hedera.mirror.importer.domain.StreamFilename.FileType.DATA) StreamType(com.hedera.mirror.common.domain.StreamType) ContractLog(com.hedera.mirror.common.domain.contract.ContractLog) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) ByteString(com.google.protobuf.ByteString) Test(org.junit.jupiter.api.Test) IntegrationTest(com.hedera.mirror.importer.IntegrationTest) TokenType(com.hederahashgraph.api.proto.java.TokenType) ContractLogRepository(com.hedera.mirror.importer.repository.ContractLogRepository) ObjectAssert(org.assertj.core.api.ObjectAssert) TransactionTemplate(org.springframework.transaction.support.TransactionTemplate) ContractFunctionResult(com.hederahashgraph.api.proto.java.ContractFunctionResult) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) Transaction(com.hedera.mirror.common.domain.transaction.Transaction) ContractFunctionResult(com.hederahashgraph.api.proto.java.ContractFunctionResult) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) Test(org.junit.jupiter.api.Test) IntegrationTest(com.hedera.mirror.importer.IntegrationTest)

Example 20 with ContractFunctionResult

use of com.hederahashgraph.api.proto.java.ContractFunctionResult in project hedera-mirror-node by hashgraph.

the class ContractResultServiceImplIntegrationTest method getContractResultOnCall.

@Test
void getContractResultOnCall() {
    RecordItem recordItem = recordItemBuilder.contractCall().build();
    ContractFunctionResult contractFunctionResult = recordItem.getRecord().getContractCallResult();
    contractResultsTest(recordItem, contractFunctionResult);
}
Also used : ContractFunctionResult(com.hederahashgraph.api.proto.java.ContractFunctionResult) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) Test(org.junit.jupiter.api.Test) IntegrationTest(com.hedera.mirror.importer.IntegrationTest)

Aggregations

ContractFunctionResult (com.hederahashgraph.api.proto.java.ContractFunctionResult)30 Test (org.junit.jupiter.api.Test)20 RecordItem (com.hedera.mirror.common.domain.transaction.RecordItem)14 IntegrationTest (com.hedera.mirror.importer.IntegrationTest)13 ByteString (com.google.protobuf.ByteString)12 EntityId (com.hedera.mirror.common.domain.entity.EntityId)12 RecordFile (com.hedera.mirror.common.domain.transaction.RecordFile)12 ContractLog (com.hedera.mirror.common.domain.contract.ContractLog)11 ContractResult (com.hedera.mirror.common.domain.contract.ContractResult)11 ContractStateChange (com.hedera.mirror.common.domain.contract.ContractStateChange)11 DomainUtils (com.hedera.mirror.common.util.DomainUtils)11 RecordItemBuilder (com.hedera.mirror.importer.parser.domain.RecordItemBuilder)11 ContractLogRepository (com.hedera.mirror.importer.repository.ContractLogRepository)11 ContractStateChangeRepository (com.hedera.mirror.importer.repository.ContractStateChangeRepository)11 ContractID (com.hederahashgraph.api.proto.java.ContractID)11 ResponseCodeEnum (com.hederahashgraph.api.proto.java.ResponseCodeEnum)11 TokenType (com.hederahashgraph.api.proto.java.TokenType)11 Collectors (java.util.stream.Collectors)11 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)11 ObjectAssert (org.assertj.core.api.ObjectAssert)11