Search in sources :

Example 1 with ReversibleTransactionExecutor

use of co.rsk.core.ReversibleTransactionExecutor in project rskj by rsksmart.

the class EthModuleTest method callWithoutReturn.

@Test
public void callWithoutReturn() {
    CallArguments args = new CallArguments();
    BlockResult blockResult = mock(BlockResult.class);
    Block block = mock(Block.class);
    ExecutionBlockRetriever retriever = mock(ExecutionBlockRetriever.class);
    when(retriever.retrieveExecutionBlock("latest")).thenReturn(blockResult);
    when(blockResult.getBlock()).thenReturn(block);
    byte[] hReturn = new byte[0];
    ProgramResult executorResult = mock(ProgramResult.class);
    when(executorResult.getHReturn()).thenReturn(hReturn);
    ReversibleTransactionExecutor executor = mock(ReversibleTransactionExecutor.class);
    when(executor.executeTransaction(eq(blockResult.getBlock()), any(), any(), any(), any(), any(), any(), any())).thenReturn(executorResult);
    EthModule eth = new EthModule(null, anyByte(), null, null, executor, retriever, null, null, null, new BridgeSupportFactory(null, null, null), config.getGasEstimationCap());
    String expectedResult = TypeConverter.toUnformattedJsonHex(hReturn);
    String actualResult = eth.call(args, "latest");
    assertEquals(expectedResult, actualResult);
}
Also used : BlockResult(co.rsk.core.bc.BlockResult) CallArguments(org.ethereum.rpc.CallArguments) ProgramResult(org.ethereum.vm.program.ProgramResult) Block(org.ethereum.core.Block) ReversibleTransactionExecutor(co.rsk.core.ReversibleTransactionExecutor) BridgeSupportFactory(co.rsk.peg.BridgeSupportFactory) ExecutionBlockRetriever(co.rsk.rpc.ExecutionBlockRetriever) Test(org.junit.Test)

Example 2 with ReversibleTransactionExecutor

use of co.rsk.core.ReversibleTransactionExecutor in project rskj by rsksmart.

the class NestedContractsTest method buildEthModule.

private EthModule buildEthModule(World world) {
    final TestSystemProperties config = new TestSystemProperties();
    TransactionExecutorFactory executor = new TransactionExecutorFactory(config, world.getBlockStore(), null, null, new ProgramInvokeFactoryImpl(), new PrecompiledContracts(config, world.getBridgeSupportFactory()), null);
    return new EthModule(null, Constants.REGTEST_CHAIN_ID, world.getBlockChain(), world.getTransactionPool(), new ReversibleTransactionExecutor(world.getRepositoryLocator(), executor), new ExecutionBlockRetriever(null, world.getBlockChain(), null, null), world.getRepositoryLocator(), null, null, world.getBridgeSupportFactory(), config.getGasEstimationCap());
}
Also used : PrecompiledContracts(org.ethereum.vm.PrecompiledContracts) EthModule(co.rsk.rpc.modules.eth.EthModule) ReversibleTransactionExecutor(co.rsk.core.ReversibleTransactionExecutor) ExecutionBlockRetriever(co.rsk.rpc.ExecutionBlockRetriever) TestSystemProperties(co.rsk.config.TestSystemProperties) ProgramInvokeFactoryImpl(org.ethereum.vm.program.invoke.ProgramInvokeFactoryImpl) TransactionExecutorFactory(co.rsk.core.TransactionExecutorFactory)

Example 3 with ReversibleTransactionExecutor

use of co.rsk.core.ReversibleTransactionExecutor in project rskj by rsksmart.

the class EthModuleTestUtils method buildBasicEthModuleForGasEstimation.

public static EthModuleGasEstimation buildBasicEthModuleForGasEstimation(World world) {
    TestSystemProperties config = new TestSystemProperties();
    TransactionExecutorFactory executor = buildBasicExecutorFactory(world, config);
    return new EthModuleGasEstimation(null, Constants.REGTEST_CHAIN_ID, world.getBlockChain(), null, new ReversibleTransactionExecutor(world.getRepositoryLocator(), executor), new ExecutionBlockRetriever(null, world.getBlockChain(), null, null), null, null, null, world.getBridgeSupportFactory(), config.getGasEstimationCap());
}
Also used : ReversibleTransactionExecutor(co.rsk.core.ReversibleTransactionExecutor) ExecutionBlockRetriever(co.rsk.rpc.ExecutionBlockRetriever) TestSystemProperties(co.rsk.config.TestSystemProperties) TransactionExecutorFactory(co.rsk.core.TransactionExecutorFactory)

Example 4 with ReversibleTransactionExecutor

use of co.rsk.core.ReversibleTransactionExecutor in project rskj by rsksmart.

the class EthModuleTestUtils method buildBasicEthModule.

public static EthModule buildBasicEthModule(World world) {
    TestSystemProperties config = new TestSystemProperties();
    TransactionExecutorFactory executor = buildBasicExecutorFactory(world, config);
    return new EthModule(null, Constants.REGTEST_CHAIN_ID, world.getBlockChain(), null, new ReversibleTransactionExecutor(world.getRepositoryLocator(), executor), new ExecutionBlockRetriever(null, world.getBlockChain(), null, null), null, null, null, world.getBridgeSupportFactory(), config.getGasEstimationCap());
}
Also used : EthModule(co.rsk.rpc.modules.eth.EthModule) ReversibleTransactionExecutor(co.rsk.core.ReversibleTransactionExecutor) ExecutionBlockRetriever(co.rsk.rpc.ExecutionBlockRetriever) TestSystemProperties(co.rsk.config.TestSystemProperties) TransactionExecutorFactory(co.rsk.core.TransactionExecutorFactory)

Example 5 with ReversibleTransactionExecutor

use of co.rsk.core.ReversibleTransactionExecutor in project rskj by rsksmart.

the class EthModuleTest method callSmokeTest.

@Test
public void callSmokeTest() {
    CallArguments args = new CallArguments();
    BlockResult blockResult = mock(BlockResult.class);
    Block block = mock(Block.class);
    ExecutionBlockRetriever retriever = mock(ExecutionBlockRetriever.class);
    when(retriever.retrieveExecutionBlock("latest")).thenReturn(blockResult);
    when(blockResult.getBlock()).thenReturn(block);
    byte[] hReturn = TypeConverter.stringToByteArray("hello");
    ProgramResult executorResult = mock(ProgramResult.class);
    when(executorResult.getHReturn()).thenReturn(hReturn);
    ReversibleTransactionExecutor executor = mock(ReversibleTransactionExecutor.class);
    when(executor.executeTransaction(eq(blockResult.getBlock()), any(), any(), any(), any(), any(), any(), any())).thenReturn(executorResult);
    EthModule eth = new EthModule(null, anyByte(), null, null, executor, retriever, null, null, null, new BridgeSupportFactory(null, null, null), config.getGasEstimationCap());
    String expectedResult = TypeConverter.toUnformattedJsonHex(hReturn);
    String actualResult = eth.call(args, "latest");
    assertEquals(expectedResult, actualResult);
}
Also used : BlockResult(co.rsk.core.bc.BlockResult) CallArguments(org.ethereum.rpc.CallArguments) ProgramResult(org.ethereum.vm.program.ProgramResult) Block(org.ethereum.core.Block) ReversibleTransactionExecutor(co.rsk.core.ReversibleTransactionExecutor) BridgeSupportFactory(co.rsk.peg.BridgeSupportFactory) ExecutionBlockRetriever(co.rsk.rpc.ExecutionBlockRetriever) Test(org.junit.Test)

Aggregations

ReversibleTransactionExecutor (co.rsk.core.ReversibleTransactionExecutor)6 ExecutionBlockRetriever (co.rsk.rpc.ExecutionBlockRetriever)6 TestSystemProperties (co.rsk.config.TestSystemProperties)3 TransactionExecutorFactory (co.rsk.core.TransactionExecutorFactory)3 BlockResult (co.rsk.core.bc.BlockResult)3 BridgeSupportFactory (co.rsk.peg.BridgeSupportFactory)3 Block (org.ethereum.core.Block)3 CallArguments (org.ethereum.rpc.CallArguments)3 ProgramResult (org.ethereum.vm.program.ProgramResult)3 Test (org.junit.Test)3 EthModule (co.rsk.rpc.modules.eth.EthModule)2 RskJsonRpcRequestException (org.ethereum.rpc.exception.RskJsonRpcRequestException)1 PrecompiledContracts (org.ethereum.vm.PrecompiledContracts)1 ProgramInvokeFactoryImpl (org.ethereum.vm.program.invoke.ProgramInvokeFactoryImpl)1