Search in sources :

Example 6 with PersonalModule

use of co.rsk.rpc.modules.personal.PersonalModule 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 7 with PersonalModule

use of co.rsk.rpc.modules.personal.PersonalModule in project rskj by rsksmart.

the class Web3ImplTest method eth_coinbase.

@Test
public void eth_coinbase() {
    String originalCoinbase = "1dcc4de8dec75d7aab85b513f0a142fd40d49347";
    MinerServer minerServerMock = Mockito.mock(MinerServer.class);
    Mockito.when(minerServerMock.getCoinbaseAddress()).thenReturn(new RskAddress(originalCoinbase));
    Ethereum ethMock = Web3Mocks.getMockEthereum();
    Blockchain blockchain = Web3Mocks.getMockBlockchain();
    TransactionPool transactionPool = Web3Mocks.getMockTransactionPool();
    BlockStore blockStore = Web3Mocks.getMockBlockStore();
    RskSystemProperties mockProperties = Web3Mocks.getMockProperties();
    PersonalModule personalModule = new PersonalModuleWalletDisabled();
    Web3 web3 = new Web3Impl(ethMock, blockchain, transactionPool, blockStore, null, mockProperties, null, minerServerMock, personalModule, null, null, Web3Mocks.getMockChannelManager(), Web3Mocks.getMockRepository(), null, null, null, null, null);
    Assert.assertEquals("0x" + originalCoinbase, web3.eth_coinbase());
    Mockito.verify(minerServerMock, Mockito.times(1)).getCoinbaseAddress();
}
Also used : BlockStore(org.ethereum.db.BlockStore) MinerServer(co.rsk.mine.MinerServer) Ethereum(org.ethereum.facade.Ethereum) PersonalModule(co.rsk.rpc.modules.personal.PersonalModule) PersonalModuleWalletDisabled(co.rsk.rpc.modules.personal.PersonalModuleWalletDisabled) RskSystemProperties(co.rsk.config.RskSystemProperties) Test(org.junit.Test)

Example 8 with PersonalModule

use of co.rsk.rpc.modules.personal.PersonalModule in project rskj by rsksmart.

the class Web3ImplTest method eth_mining.

@Test
public void eth_mining() {
    Ethereum ethMock = Web3Mocks.getMockEthereum();
    Blockchain blockchain = Web3Mocks.getMockBlockchain();
    TransactionPool transactionPool = Web3Mocks.getMockTransactionPool();
    BlockStore blockStore = Web3Mocks.getMockBlockStore();
    RskSystemProperties mockProperties = Web3Mocks.getMockProperties();
    MinerClient minerClient = new SimpleMinerClient();
    PersonalModule personalModule = new PersonalModuleWalletDisabled();
    TxPoolModule txPoolModule = new TxPoolModuleImpl(Web3Mocks.getMockTransactionPool());
    Web3 web3 = new Web3Impl(ethMock, blockchain, transactionPool, blockStore, null, mockProperties, minerClient, null, personalModule, null, txPoolModule, Web3Mocks.getMockChannelManager(), Web3Mocks.getMockRepository(), null, null, null, null, null);
    Assert.assertTrue("Node is not mining", !web3.eth_mining());
    try {
        minerClient.mine();
        Assert.assertTrue("Node is mining", web3.eth_mining());
    } finally {
        minerClient.stop();
    }
    Assert.assertTrue("Node is not mining", !web3.eth_mining());
}
Also used : BlockStore(org.ethereum.db.BlockStore) TxPoolModuleImpl(co.rsk.rpc.modules.txpool.TxPoolModuleImpl) PersonalModuleWalletDisabled(co.rsk.rpc.modules.personal.PersonalModuleWalletDisabled) MinerClient(co.rsk.mine.MinerClient) Ethereum(org.ethereum.facade.Ethereum) PersonalModule(co.rsk.rpc.modules.personal.PersonalModule) TxPoolModule(co.rsk.rpc.modules.txpool.TxPoolModule) RskSystemProperties(co.rsk.config.RskSystemProperties) Test(org.junit.Test)

Aggregations

PersonalModule (co.rsk.rpc.modules.personal.PersonalModule)8 RskSystemProperties (co.rsk.config.RskSystemProperties)6 TxPoolModule (co.rsk.rpc.modules.txpool.TxPoolModule)6 TxPoolModuleImpl (co.rsk.rpc.modules.txpool.TxPoolModuleImpl)6 PersonalModuleWalletDisabled (co.rsk.rpc.modules.personal.PersonalModuleWalletDisabled)5 Test (org.junit.Test)5 EthModule (co.rsk.rpc.modules.eth.EthModule)4 Ethereum (org.ethereum.facade.Ethereum)4 ExecutionBlockRetriever (co.rsk.rpc.ExecutionBlockRetriever)3 Web3RskImpl (co.rsk.rpc.Web3RskImpl)3 EthModuleSolidityDisabled (co.rsk.rpc.modules.eth.EthModuleSolidityDisabled)3 EthModuleWalletEnabled (co.rsk.rpc.modules.eth.EthModuleWalletEnabled)3 PersonalModuleWalletEnabled (co.rsk.rpc.modules.personal.PersonalModuleWalletEnabled)3 BlockStore (org.ethereum.db.BlockStore)3 Wallet (co.rsk.core.Wallet)2 Blockchain (org.ethereum.core.Blockchain)2 NetworkStateExporter (co.rsk.core.NetworkStateExporter)1 Rsk (co.rsk.core.Rsk)1 MinerClient (co.rsk.mine.MinerClient)1 MinerServer (co.rsk.mine.MinerServer)1