Search in sources :

Example 1 with SystemProperties

use of org.ethereum.config.SystemProperties 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 2 with SystemProperties

use of org.ethereum.config.SystemProperties in project rskj by rsksmart.

the class CompilerTest method simpleTest.

@Test
@Ignore
public void simpleTest() throws IOException {
    SystemProperties systemProperties = Mockito.mock(SystemProperties.class);
    String solc = System.getProperty("solc");
    if (solc == null || solc.isEmpty())
        solc = "/usr/bin/solc";
    Mockito.when(systemProperties.customSolcPath()).thenReturn(solc);
    SolidityCompiler solidityCompiler = new SolidityCompiler(systemProperties);
    String contract = "contract a {" + "  int i1;" + "  function i() returns (int) {" + "    return i1;" + "  }" + "}";
    SolidityCompiler.Result res = solidityCompiler.compile(contract.getBytes(), true, SolidityCompiler.Options.ABI, SolidityCompiler.Options.BIN, SolidityCompiler.Options.INTERFACE);
    System.out.println("Out: '" + res.output + "'");
    System.out.println("Err: '" + res.errors + "'");
    CompilationResult result = CompilationResult.parse(res.output);
    CompilationResult.ContractMetadata cmeta = result.contracts.get("a");
    if (cmeta == null)
        cmeta = result.contracts.get("<stdin>:a");
    if (cmeta != null)
        System.out.println(cmeta.bin);
    else
        Assert.fail();
}
Also used : SystemProperties(org.ethereum.config.SystemProperties) CompilationResult(org.ethereum.solidity.compiler.CompilationResult) SolidityCompiler(org.ethereum.solidity.compiler.SolidityCompiler) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

SystemProperties (org.ethereum.config.SystemProperties)2 Test (org.junit.Test)2 RskSystemProperties (co.rsk.config.RskSystemProperties)1 ExecutionBlockRetriever (co.rsk.rpc.ExecutionBlockRetriever)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 PersonalModuleWalletDisabled (co.rsk.rpc.modules.personal.PersonalModuleWalletDisabled)1 TxPoolModule (co.rsk.rpc.modules.txpool.TxPoolModule)1 TxPoolModuleImpl (co.rsk.rpc.modules.txpool.TxPoolModuleImpl)1 Ethereum (org.ethereum.facade.Ethereum)1 CompilationResultDTO (org.ethereum.rpc.dto.CompilationResultDTO)1 CompilationResult (org.ethereum.solidity.compiler.CompilationResult)1 SolidityCompiler (org.ethereum.solidity.compiler.SolidityCompiler)1 Ignore (org.junit.Ignore)1