Search in sources :

Example 6 with ReversibleTransactionExecutor

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

the class EthModuleTest method test_revertedTransaction.

@Test
public void test_revertedTransaction() {
    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 = Hex.decode("08c379a000000000000000000000000000000000000000000000000000000000" + "0000002000000000000000000000000000000000000000000000000000000000" + "0000000f6465706f73697420746f6f2062696700000000000000000000000000" + "00000000");
    ProgramResult executorResult = mock(ProgramResult.class);
    when(executorResult.isRevert()).thenReturn(true);
    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());
    try {
        eth.call(args, "latest");
    } catch (RskJsonRpcRequestException e) {
        assertThat(e.getMessage(), Matchers.containsString("deposit too big"));
    }
}
Also used : RskJsonRpcRequestException(org.ethereum.rpc.exception.RskJsonRpcRequestException) 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