Search in sources :

Example 1 with ExecutionBlockRetriever

use of co.rsk.rpc.ExecutionBlockRetriever in project rskj by rsksmart.

the class Web3ImplTest method createWeb3.

private Web3Impl createWeb3(Ethereum eth, Blockchain blockchain, TransactionPool transactionPool, BlockStore blockStore, BlockProcessor nodeBlockProcessor, ConfigCapabilities configCapabilities, ReceiptStore receiptStore) {
    wallet = WalletFactory.createWallet();
    PersonalModuleWalletEnabled personalModule = new PersonalModuleWalletEnabled(config, eth, wallet, transactionPool);
    ReversibleTransactionExecutor executor = Mockito.mock(ReversibleTransactionExecutor.class);
    ProgramResult res = new ProgramResult();
    res.setHReturn(TypeConverter.stringHexToByteArray("0x0000000000000000000000000000000000000000000000000000000064617665"));
    Mockito.when(executor.executeTransaction(Matchers.any(), Matchers.any(), Matchers.any(), Matchers.any(), Matchers.any(), Matchers.any(), Matchers.any(), Matchers.any())).thenReturn(res);
    EthModule ethModule = new EthModule(config, blockchain, executor, new ExecutionBlockRetriever(blockchain, null, null), new EthModuleSolidityDisabled(), new EthModuleWalletEnabled(config, eth, wallet, transactionPool));
    TxPoolModule txPoolModule = new TxPoolModuleImpl(transactionPool);
    MinerClient minerClient = new SimpleMinerClient();
    ChannelManager channelManager = new SimpleChannelManager();
    return new Web3RskImpl(eth, blockchain, transactionPool, config, minerClient, Web3Mocks.getMockMinerServer(), personalModule, ethModule, txPoolModule, channelManager, Web3Mocks.getMockRepository(), null, null, blockStore, receiptStore, null, nodeBlockProcessor, null, configCapabilities);
}
Also used : ChannelManager(org.ethereum.net.server.ChannelManager) EthModuleSolidityDisabled(co.rsk.rpc.modules.eth.EthModuleSolidityDisabled) ProgramResult(org.ethereum.vm.program.ProgramResult) Web3RskImpl(co.rsk.rpc.Web3RskImpl) TxPoolModuleImpl(co.rsk.rpc.modules.txpool.TxPoolModuleImpl) PersonalModuleWalletEnabled(co.rsk.rpc.modules.personal.PersonalModuleWalletEnabled) EthModuleWalletEnabled(co.rsk.rpc.modules.eth.EthModuleWalletEnabled) MinerClient(co.rsk.mine.MinerClient) EthModule(co.rsk.rpc.modules.eth.EthModule) ExecutionBlockRetriever(co.rsk.rpc.ExecutionBlockRetriever) TxPoolModule(co.rsk.rpc.modules.txpool.TxPoolModule)

Example 2 with ExecutionBlockRetriever

use of co.rsk.rpc.ExecutionBlockRetriever 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 3 with ExecutionBlockRetriever

use of co.rsk.rpc.ExecutionBlockRetriever 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 4 with ExecutionBlockRetriever

use of co.rsk.rpc.ExecutionBlockRetriever 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 5 with ExecutionBlockRetriever

use of co.rsk.rpc.ExecutionBlockRetriever 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)

Aggregations

ExecutionBlockRetriever (co.rsk.rpc.ExecutionBlockRetriever)16 EthModule (co.rsk.rpc.modules.eth.EthModule)11 Web3RskImpl (co.rsk.rpc.Web3RskImpl)10 TxPoolModule (co.rsk.rpc.modules.txpool.TxPoolModule)10 TxPoolModuleImpl (co.rsk.rpc.modules.txpool.TxPoolModuleImpl)10 BridgeSupportFactory (co.rsk.peg.BridgeSupportFactory)9 EthModuleWalletEnabled (co.rsk.rpc.modules.eth.EthModuleWalletEnabled)8 PersonalModuleWalletEnabled (co.rsk.rpc.modules.personal.PersonalModuleWalletEnabled)8 ReversibleTransactionExecutor (co.rsk.core.ReversibleTransactionExecutor)6 DebugModule (co.rsk.rpc.modules.debug.DebugModule)6 DebugModuleImpl (co.rsk.rpc.modules.debug.DebugModuleImpl)6 ChannelManager (org.ethereum.net.server.ChannelManager)5 ProgramResult (org.ethereum.vm.program.ProgramResult)5 Test (org.junit.Test)5 TestSystemProperties (co.rsk.config.TestSystemProperties)4 MiningMainchainView (co.rsk.core.bc.MiningMainchainView)4 MinerClient (co.rsk.mine.MinerClient)4 Web3InformationRetriever (co.rsk.rpc.Web3InformationRetriever)4 PersonalModule (co.rsk.rpc.modules.personal.PersonalModule)4 TransactionExecutorFactory (co.rsk.core.TransactionExecutorFactory)3