Search in sources :

Example 6 with TxPoolModule

use of co.rsk.rpc.modules.txpool.TxPoolModule in project rskj by rsksmart.

the class Web3ImplSnapshotTest method createWeb3.

private static Web3Impl createWeb3(World world, SimpleEthereum ethereum, MinerServer minerServer) {
    MinerClientImpl minerClient = new MinerClientImpl(null, minerServer, config);
    PersonalModule pm = new PersonalModuleWalletDisabled();
    TxPoolModule tpm = new TxPoolModuleImpl(Web3Mocks.getMockTransactionPool());
    ethereum.repository = world.getRepository();
    ethereum.blockchain = world.getBlockChain();
    return new Web3Impl(ethereum, world.getBlockChain(), null, world.getBlockChain().getBlockStore(), null, Web3Mocks.getMockProperties(), minerClient, minerServer, pm, null, tpm, Web3Mocks.getMockChannelManager(), ethereum.repository, null, null, null, null, null);
}
Also used : PersonalModule(co.rsk.rpc.modules.personal.PersonalModule) TxPoolModuleImpl(co.rsk.rpc.modules.txpool.TxPoolModuleImpl) PersonalModuleWalletDisabled(co.rsk.rpc.modules.personal.PersonalModuleWalletDisabled) TxPoolModule(co.rsk.rpc.modules.txpool.TxPoolModule)

Example 7 with TxPoolModule

use of co.rsk.rpc.modules.txpool.TxPoolModule in project rskj by rsksmart.

the class Web3ImplTest method eth_compileSolidity.

@Test
@Ignore
public void eth_compileSolidity() throws Exception {
    RskSystemProperties systemProperties = Mockito.mock(RskSystemProperties.class);
    String solc = System.getProperty("solc");
    if (StringUtils.isEmpty(solc))
        solc = "/usr/bin/solc";
    Mockito.when(systemProperties.customSolcPath()).thenReturn(solc);
    Ethereum eth = Mockito.mock(Ethereum.class);
    EthModule ethModule = new EthModule(config, null, null, new ExecutionBlockRetriever(null, null, null), new EthModuleSolidityEnabled(new SolidityCompiler(systemProperties)), null);
    PersonalModule personalModule = new PersonalModuleWalletDisabled();
    TxPoolModule txPoolModule = new TxPoolModuleImpl(Web3Mocks.getMockTransactionPool());
    Web3Impl web3 = new Web3RskImpl(eth, null, null, systemProperties, null, null, personalModule, ethModule, txPoolModule, Web3Mocks.getMockChannelManager(), Web3Mocks.getMockRepository(), null, null, null, null, null, null, null, null);
    String contract = "pragma solidity ^0.4.1; contract rsk { function multiply(uint a) returns(uint d) {   return a * 7;   } }";
    Map<String, CompilationResultDTO> result = web3.eth_compileSolidity(contract);
    org.junit.Assert.assertNotNull(result);
    CompilationResultDTO dto = result.get("rsk");
    if (dto == null)
        dto = result.get("<stdin>:rsk");
    org.junit.Assert.assertEquals(contract, dto.info.getSource());
}
Also used : Web3RskImpl(co.rsk.rpc.Web3RskImpl) TxPoolModuleImpl(co.rsk.rpc.modules.txpool.TxPoolModuleImpl) PersonalModuleWalletDisabled(co.rsk.rpc.modules.personal.PersonalModuleWalletDisabled) SolidityCompiler(org.ethereum.solidity.compiler.SolidityCompiler) EthModuleSolidityEnabled(co.rsk.rpc.modules.eth.EthModuleSolidityEnabled) CompilationResultDTO(org.ethereum.rpc.dto.CompilationResultDTO) Ethereum(org.ethereum.facade.Ethereum) EthModule(co.rsk.rpc.modules.eth.EthModule) PersonalModule(co.rsk.rpc.modules.personal.PersonalModule) ExecutionBlockRetriever(co.rsk.rpc.ExecutionBlockRetriever) TxPoolModule(co.rsk.rpc.modules.txpool.TxPoolModule) RskSystemProperties(co.rsk.config.RskSystemProperties) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 8 with TxPoolModule

use of co.rsk.rpc.modules.txpool.TxPoolModule in project rskj by rsksmart.

the class Web3ImplTest method eth_compileSolidityWithoutSolidity.

@Test
public void eth_compileSolidityWithoutSolidity() throws Exception {
    SystemProperties systemProperties = Mockito.mock(SystemProperties.class);
    String solc = System.getProperty("solc");
    if (StringUtils.isEmpty(solc))
        solc = "/usr/bin/solc";
    Mockito.when(systemProperties.customSolcPath()).thenReturn(solc);
    Wallet wallet = WalletFactory.createWallet();
    Ethereum eth = Web3Mocks.getMockEthereum();
    Blockchain blockchain = Web3Mocks.getMockBlockchain();
    TransactionPool transactionPool = Web3Mocks.getMockTransactionPool();
    EthModule ethModule = new EthModule(config, blockchain, null, new ExecutionBlockRetriever(blockchain, null, null), new EthModuleSolidityDisabled(), new EthModuleWalletEnabled(config, eth, wallet, null));
    TxPoolModule txPoolModule = new TxPoolModuleImpl(Web3Mocks.getMockTransactionPool());
    Web3Impl web3 = new Web3RskImpl(eth, blockchain, transactionPool, config, null, null, new PersonalModuleWalletDisabled(), ethModule, txPoolModule, Web3Mocks.getMockChannelManager(), Web3Mocks.getMockRepository(), null, null, null, null, null, null, null, null);
    String contract = "pragma solidity ^0.4.1; contract rsk { function multiply(uint a) returns(uint d) {   return a * 7;   } }";
    Map<String, CompilationResultDTO> result = web3.eth_compileSolidity(contract);
    org.junit.Assert.assertNotNull(result);
    org.junit.Assert.assertEquals(0, result.size());
}
Also used : EthModuleSolidityDisabled(co.rsk.rpc.modules.eth.EthModuleSolidityDisabled) Web3RskImpl(co.rsk.rpc.Web3RskImpl) TxPoolModuleImpl(co.rsk.rpc.modules.txpool.TxPoolModuleImpl) PersonalModuleWalletDisabled(co.rsk.rpc.modules.personal.PersonalModuleWalletDisabled) EthModuleWalletEnabled(co.rsk.rpc.modules.eth.EthModuleWalletEnabled) SystemProperties(org.ethereum.config.SystemProperties) RskSystemProperties(co.rsk.config.RskSystemProperties) CompilationResultDTO(org.ethereum.rpc.dto.CompilationResultDTO) Ethereum(org.ethereum.facade.Ethereum) EthModule(co.rsk.rpc.modules.eth.EthModule) ExecutionBlockRetriever(co.rsk.rpc.ExecutionBlockRetriever) TxPoolModule(co.rsk.rpc.modules.txpool.TxPoolModule) Test(org.junit.Test)

Example 9 with TxPoolModule

use of co.rsk.rpc.modules.txpool.TxPoolModule in project rskj by rsksmart.

the class Web3ImplTest method createWeb3.

private Web3Impl createWeb3(SimpleEthereum eth, PeerServer peerServer) {
    wallet = WalletFactory.createWallet();
    Blockchain blockchain = Web3Mocks.getMockBlockchain();
    BlockStore blockStore = Web3Mocks.getMockBlockStore();
    MiningMainchainView mainchainView = new MiningMainchainViewImpl(blockStore, 449);
    TransactionPool transactionPool = Web3Mocks.getMockTransactionPool();
    PersonalModuleWalletEnabled personalModule = new PersonalModuleWalletEnabled(config, eth, wallet, null);
    EthModule ethModule = new EthModule(config.getNetworkConstants().getBridgeConstants(), config.getNetworkConstants().getChainId(), blockchain, transactionPool, null, new ExecutionBlockRetriever(mainchainView, blockchain, null, null), null, new EthModuleWalletEnabled(wallet), null, new BridgeSupportFactory(null, config.getNetworkConstants().getBridgeConstants(), config.getActivationConfig()), config.getGasEstimationCap());
    TxPoolModule txPoolModule = new TxPoolModuleImpl(Web3Mocks.getMockTransactionPool());
    DebugModule debugModule = new DebugModuleImpl(null, null, Web3Mocks.getMockMessageHandler(), null);
    MinerClient minerClient = new SimpleMinerClient();
    ChannelManager channelManager = new SimpleChannelManager();
    return new Web3RskImpl(eth, blockchain, config, minerClient, Web3Mocks.getMockMinerServer(), personalModule, ethModule, null, txPoolModule, null, debugModule, null, null, channelManager, null, null, null, null, peerServer, null, null, null, null, null, new Web3InformationRetriever(transactionPool, blockchain, mock(RepositoryLocator.class), mock(ExecutionBlockRetriever.class)), null);
}
Also used : BlockStore(org.ethereum.db.BlockStore) ChannelManager(org.ethereum.net.server.ChannelManager) Web3RskImpl(co.rsk.rpc.Web3RskImpl) TxPoolModuleImpl(co.rsk.rpc.modules.txpool.TxPoolModuleImpl) DebugModuleImpl(co.rsk.rpc.modules.debug.DebugModuleImpl) MiningMainchainViewImpl(co.rsk.core.bc.MiningMainchainViewImpl) PersonalModuleWalletEnabled(co.rsk.rpc.modules.personal.PersonalModuleWalletEnabled) MiningMainchainView(co.rsk.core.bc.MiningMainchainView) EthModuleWalletEnabled(co.rsk.rpc.modules.eth.EthModuleWalletEnabled) MinerClient(co.rsk.mine.MinerClient) Web3InformationRetriever(co.rsk.rpc.Web3InformationRetriever) EthModule(co.rsk.rpc.modules.eth.EthModule) DebugModule(co.rsk.rpc.modules.debug.DebugModule) BridgeSupportFactory(co.rsk.peg.BridgeSupportFactory) ExecutionBlockRetriever(co.rsk.rpc.ExecutionBlockRetriever) TxPoolModule(co.rsk.rpc.modules.txpool.TxPoolModule)

Example 10 with TxPoolModule

use of co.rsk.rpc.modules.txpool.TxPoolModule in project rskj by rsksmart.

the class Web3ImplTest method eth_mining.

@Test
public void eth_mining() {
    Ethereum ethMock = Web3Mocks.getMockEthereum();
    Blockchain blockchain = Web3Mocks.getMockBlockchain();
    BlockStore blockStore = Web3Mocks.getMockBlockStore();
    RskSystemProperties mockProperties = Web3Mocks.getMockProperties();
    MinerClient minerClient = new SimpleMinerClient();
    PersonalModule personalModule = new PersonalModuleWalletDisabled();
    TxPoolModule txPoolModule = new TxPoolModuleImpl(Web3Mocks.getMockTransactionPool());
    DebugModule debugModule = new DebugModuleImpl(null, null, Web3Mocks.getMockMessageHandler(), null);
    Web3 web3 = new Web3Impl(ethMock, blockchain, blockStore, null, mockProperties, minerClient, null, personalModule, null, null, txPoolModule, null, debugModule, null, null, Web3Mocks.getMockChannelManager(), null, null, null, null, null, null, null, mock(Web3InformationRetriever.class), null);
    assertTrue("Node is not mining", !web3.eth_mining());
    try {
        minerClient.start();
        assertTrue("Node is mining", web3.eth_mining());
    } finally {
        minerClient.stop();
    }
    assertTrue("Node is not mining", !web3.eth_mining());
}
Also used : BlockStore(org.ethereum.db.BlockStore) TxPoolModuleImpl(co.rsk.rpc.modules.txpool.TxPoolModuleImpl) DebugModuleImpl(co.rsk.rpc.modules.debug.DebugModuleImpl) PersonalModuleWalletDisabled(co.rsk.rpc.modules.personal.PersonalModuleWalletDisabled) MinerClient(co.rsk.mine.MinerClient) Web3InformationRetriever(co.rsk.rpc.Web3InformationRetriever) Ethereum(org.ethereum.facade.Ethereum) PersonalModule(co.rsk.rpc.modules.personal.PersonalModule) DebugModule(co.rsk.rpc.modules.debug.DebugModule) TxPoolModule(co.rsk.rpc.modules.txpool.TxPoolModule) RskSystemProperties(co.rsk.config.RskSystemProperties) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

TxPoolModule (co.rsk.rpc.modules.txpool.TxPoolModule)14 TxPoolModuleImpl (co.rsk.rpc.modules.txpool.TxPoolModuleImpl)14 ExecutionBlockRetriever (co.rsk.rpc.ExecutionBlockRetriever)10 Web3RskImpl (co.rsk.rpc.Web3RskImpl)10 EthModule (co.rsk.rpc.modules.eth.EthModule)10 EthModuleWalletEnabled (co.rsk.rpc.modules.eth.EthModuleWalletEnabled)9 PersonalModuleWalletEnabled (co.rsk.rpc.modules.personal.PersonalModuleWalletEnabled)9 DebugModule (co.rsk.rpc.modules.debug.DebugModule)8 DebugModuleImpl (co.rsk.rpc.modules.debug.DebugModuleImpl)8 PersonalModule (co.rsk.rpc.modules.personal.PersonalModule)8 BridgeSupportFactory (co.rsk.peg.BridgeSupportFactory)6 MinerClient (co.rsk.mine.MinerClient)5 Web3InformationRetriever (co.rsk.rpc.Web3InformationRetriever)5 PersonalModuleWalletDisabled (co.rsk.rpc.modules.personal.PersonalModuleWalletDisabled)5 ChannelManager (org.ethereum.net.server.ChannelManager)5 RskSystemProperties (co.rsk.config.RskSystemProperties)4 MiningMainchainView (co.rsk.core.bc.MiningMainchainView)4 EthModuleSolidityDisabled (co.rsk.rpc.modules.eth.EthModuleSolidityDisabled)4 Ethereum (org.ethereum.facade.Ethereum)4 Test (org.junit.Test)4