Search in sources :

Example 26 with World

use of co.rsk.test.World in project rskj by rsksmart.

the class Web3ImplLogsTest method getLogsFromBlockchainWithCallContractAndFilterByKnownTopicInList.

@Test
public void getLogsFromBlockchainWithCallContractAndFilterByKnownTopicInList() throws Exception {
    World world = new World();
    Web3Impl web3 = getWeb3WithContractCall(world);
    Block block1 = world.getBlockChain().getBlockByNumber(1l);
    Web3.FilterRequest fr = new Web3.FilterRequest();
    fr.fromBlock = "earliest";
    fr.topics = new Object[1];
    List<String> topics = new ArrayList<>();
    topics.add(GET_VALUED_EVENT_SIGNATURE);
    fr.topics[0] = topics;
    Object[] logs = web3.eth_getLogs(fr);
    Assert.assertNotNull(logs);
    String address = "0x" + Hex.toHexString(block1.getTransactionsList().get(0).getContractAddress().getBytes());
    Assert.assertEquals(1, logs.length);
    Assert.assertEquals(address, ((LogFilterElement) logs[0]).address);
}
Also used : ArrayList(java.util.ArrayList) World(co.rsk.test.World) Test(org.junit.Test)

Example 27 with World

use of co.rsk.test.World in project rskj by rsksmart.

the class RepositoryDumpTest method dumpState.

@Test
public void dumpState() {
    World world = new World();
    world.getRepository().dumpState(world.getBlockChain().getBestBlock(), 0, 0, null);
}
Also used : World(co.rsk.test.World) Test(org.junit.Test)

Example 28 with World

use of co.rsk.test.World in project rskj by rsksmart.

the class TwoAsyncNodeTest method createNode.

private static SimpleAsyncNode createNode(int size) {
    final World world = new World();
    final BlockStore store = new BlockStore();
    final Blockchain blockchain = world.getBlockChain();
    List<Block> blocks = new BlockGenerator().getBlockChain(blockchain.getBestBlock(), size);
    for (Block b : blocks) blockchain.tryToConnect(b);
    BlockNodeInformation nodeInformation = new BlockNodeInformation();
    SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING;
    BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration);
    NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration);
    NodeMessageHandler handler = new NodeMessageHandler(config, processor, null, null, null, null, null, new DummyBlockValidationRule());
    return new SimpleAsyncNode(handler);
}
Also used : DummyBlockValidationRule(co.rsk.validators.DummyBlockValidationRule) Blockchain(org.ethereum.core.Blockchain) World(co.rsk.test.World) BlockGenerator(co.rsk.blockchain.utils.BlockGenerator) SimpleAsyncNode(co.rsk.net.simples.SimpleAsyncNode) Block(org.ethereum.core.Block) SyncConfiguration(co.rsk.net.sync.SyncConfiguration)

Example 29 with World

use of co.rsk.test.World in project rskj by rsksmart.

the class Web3ImplScoringTest method createWeb3.

private static Web3Impl createWeb3(PeerScoringManager peerScoringManager) {
    SimpleRsk rsk = new SimpleRsk();
    World world = new World();
    rsk.blockchain = world.getBlockChain();
    Wallet wallet = WalletFactory.createWallet();
    RskSystemProperties config = new RskSystemProperties();
    PersonalModule pm = new PersonalModuleWalletEnabled(config, rsk, wallet, null);
    EthModule em = new EthModule(config, world.getBlockChain(), null, new ExecutionBlockRetriever(world.getBlockChain(), null, null), new EthModuleSolidityDisabled(), new EthModuleWalletEnabled(config, rsk, wallet, null));
    TxPoolModule tpm = new TxPoolModuleImpl(Web3Mocks.getMockTransactionPool());
    return new Web3RskImpl(rsk, world.getBlockChain(), null, config, Web3Mocks.getMockMinerClient(), Web3Mocks.getMockMinerServer(), pm, em, tpm, Web3Mocks.getMockChannelManager(), rsk.getRepository(), peerScoringManager, null, null, null, null, null, null, null);
}
Also used : EthModuleSolidityDisabled(co.rsk.rpc.modules.eth.EthModuleSolidityDisabled) Wallet(co.rsk.core.Wallet) Web3RskImpl(co.rsk.rpc.Web3RskImpl) SimpleRsk(org.ethereum.rpc.Simples.SimpleRsk) TxPoolModuleImpl(co.rsk.rpc.modules.txpool.TxPoolModuleImpl) World(co.rsk.test.World) PersonalModuleWalletEnabled(co.rsk.rpc.modules.personal.PersonalModuleWalletEnabled) EthModuleWalletEnabled(co.rsk.rpc.modules.eth.EthModuleWalletEnabled) PersonalModule(co.rsk.rpc.modules.personal.PersonalModule) EthModule(co.rsk.rpc.modules.eth.EthModule) ExecutionBlockRetriever(co.rsk.rpc.ExecutionBlockRetriever) TxPoolModule(co.rsk.rpc.modules.txpool.TxPoolModule) RskSystemProperties(co.rsk.config.RskSystemProperties)

Example 30 with World

use of co.rsk.test.World in project rskj by rsksmart.

the class Web3ImplSnapshotTest method takeFirstSnapshot.

@Test
public void takeFirstSnapshot() {
    World world = new World();
    Web3Impl web3 = createWeb3(world);
    String result = web3.evm_snapshot();
    Assert.assertNotNull(result);
    Assert.assertEquals("0x1", result);
}
Also used : World(co.rsk.test.World) Test(org.junit.Test)

Aggregations

World (co.rsk.test.World)134 Test (org.junit.Test)114 BlockBuilder (co.rsk.test.builders.BlockBuilder)36 AccountBuilder (co.rsk.test.builders.AccountBuilder)33 WorldDslProcessor (co.rsk.test.dsl.WorldDslProcessor)24 DslParser (co.rsk.test.dsl.DslParser)23 Block (org.ethereum.core.Block)20 Blockchain (org.ethereum.core.Blockchain)19 SyncConfiguration (co.rsk.net.sync.SyncConfiguration)15 TransactionBuilder (co.rsk.test.builders.TransactionBuilder)15 BlockGenerator (co.rsk.blockchain.utils.BlockGenerator)14 TransactionPoolImpl (co.rsk.core.bc.TransactionPoolImpl)14 ArrayList (java.util.ArrayList)13 SimpleEthereum (org.ethereum.rpc.Simples.SimpleEthereum)13 BlockChainImpl (co.rsk.core.bc.BlockChainImpl)11 SimpleMessageChannel (co.rsk.net.simples.SimpleMessageChannel)11 ProofOfWorkRule (co.rsk.validators.ProofOfWorkRule)11 BigInteger (java.math.BigInteger)10 DummyBlockValidationRule (co.rsk.validators.DummyBlockValidationRule)9 Account (org.ethereum.core.Account)8