Search in sources :

Example 21 with ProgramResult

use of org.ethereum.vm.program.ProgramResult in project rskj by rsksmart.

the class EthModuleTest method callSmokeTest.

@Test
public void callSmokeTest() {
    Web3.CallArguments args = new Web3.CallArguments();
    Block executionBlock = mock(Block.class);
    ExecutionBlockRetriever retriever = mock(ExecutionBlockRetriever.class);
    when(retriever.getExecutionBlock("latest")).thenReturn(executionBlock);
    byte[] hreturn = TypeConverter.stringToByteArray("hello");
    ProgramResult executorResult = mock(ProgramResult.class);
    when(executorResult.getHReturn()).thenReturn(hreturn);
    ReversibleTransactionExecutor executor = mock(ReversibleTransactionExecutor.class);
    when(executor.executeTransaction(eq(executionBlock), any(), any(), any(), any(), any(), any(), any())).thenReturn(executorResult);
    EthModule eth = new EthModule(null, null, executor, retriever, null, null);
    String result = eth.call(args, "latest");
    assertThat(result, is(TypeConverter.toJsonHex(hreturn)));
}
Also used : Web3(org.ethereum.rpc.Web3) ProgramResult(org.ethereum.vm.program.ProgramResult) Block(org.ethereum.core.Block) ReversibleTransactionExecutor(co.rsk.core.ReversibleTransactionExecutor) ExecutionBlockRetriever(co.rsk.rpc.ExecutionBlockRetriever) Test(org.junit.Test)

Example 22 with ProgramResult

use of org.ethereum.vm.program.ProgramResult in project rskj by rsksmart.

the class ProgramTest method helloContractIsNotPayable.

@Test
public void helloContractIsNotPayable() {
    ProgramResult result = TestContract.hello().executeFunction("hello", BigInteger.TEN);
    Assert.assertTrue(result.isRevert());
    Assert.assertNull(result.getException());
}
Also used : ProgramResult(org.ethereum.vm.program.ProgramResult) Test(org.junit.Test)

Example 23 with ProgramResult

use of org.ethereum.vm.program.ProgramResult in project rskj by rsksmart.

the class ProgramTest method cantCreateTooLargeContract.

@Test
public void cantCreateTooLargeContract() {
    ProgramResult result = TestContract.bigTest().createContract();
    Assert.assertFalse(result.isRevert());
    Assert.assertNotNull(result.getException());
    Assert.assertTrue(result.getException() instanceof RuntimeException);
}
Also used : ProgramResult(org.ethereum.vm.program.ProgramResult) Test(org.junit.Test)

Aggregations

ProgramResult (org.ethereum.vm.program.ProgramResult)23 Test (org.junit.Test)19 Block (org.ethereum.core.Block)6 TestContract (co.rsk.util.TestContract)5 CallTransaction (org.ethereum.core.CallTransaction)4 ContractDetails (org.ethereum.db.ContractDetails)4 ExecutionBlockRetriever (co.rsk.rpc.ExecutionBlockRetriever)2 BigInteger (java.math.BigInteger)2 BlockStoreDummy (org.ethereum.db.BlockStoreDummy)2 StateTestSuite (org.ethereum.jsontestsuite.StateTestSuite)2 StateTestRunner (org.ethereum.jsontestsuite.runners.StateTestRunner)2 ReversibleTransactionExecutor (co.rsk.core.ReversibleTransactionExecutor)1 RskAddress (co.rsk.core.RskAddress)1 BlockChainImpl (co.rsk.core.bc.BlockChainImpl)1 MinerClient (co.rsk.mine.MinerClient)1 Web3RskImpl (co.rsk.rpc.Web3RskImpl)1 EthModule (co.rsk.rpc.modules.eth.EthModule)1 EthModuleSolidityDisabled (co.rsk.rpc.modules.eth.EthModuleSolidityDisabled)1 EthModuleWalletEnabled (co.rsk.rpc.modules.eth.EthModuleWalletEnabled)1 PersonalModuleWalletEnabled (co.rsk.rpc.modules.personal.PersonalModuleWalletEnabled)1