Search in sources :

Example 11 with RskTestFactory

use of org.ethereum.util.RskTestFactory in project rskj by rsksmart.

the class LogFilterTest method twoEventsAfterTwoBlocksWithEventAndToLatestBlock.

@Test
public void twoEventsAfterTwoBlocksWithEventAndToLatestBlock() {
    RskTestFactory factory = new RskTestFactory();
    Blockchain blockchain = factory.getBlockchain();
    BlockStore blockStore = factory.getBlockStore();
    RepositoryLocator repositoryLocator = factory.getRepositoryLocator();
    Web3ImplLogsTest.addEmptyBlockToBlockchain(blockchain, blockStore, repositoryLocator, factory.getTrieStore());
    Block block = blockchain.getBestBlock();
    AddressesTopicsFilter atfilter = new AddressesTopicsFilter(new RskAddress[0], null);
    LogFilter filter = new LogFilter(atfilter, blockchain, false, true);
    filter.newBlockReceived(block);
    filter.newBlockReceived(block);
    Object[] result = filter.getEvents();
    Assert.assertNotNull(result);
    Assert.assertEquals(2, result.length);
}
Also used : RepositoryLocator(co.rsk.db.RepositoryLocator) BlockStore(org.ethereum.db.BlockStore) Blockchain(org.ethereum.core.Blockchain) Block(org.ethereum.core.Block) RskTestFactory(org.ethereum.util.RskTestFactory) Test(org.junit.Test)

Example 12 with RskTestFactory

use of org.ethereum.util.RskTestFactory in project rskj by rsksmart.

the class LogFilterTest method onlyOneEventAfterTwoBlocksWithEventAndFromLatestBlock.

@Test
public void onlyOneEventAfterTwoBlocksWithEventAndFromLatestBlock() {
    RskTestFactory factory = new RskTestFactory();
    Blockchain blockchain = factory.getBlockchain();
    BlockStore blockStore = factory.getBlockStore();
    RepositoryLocator repositoryLocator = factory.getRepositoryLocator();
    Web3ImplLogsTest.addEmptyBlockToBlockchain(blockchain, blockStore, repositoryLocator, factory.getTrieStore());
    Block block = blockchain.getBestBlock();
    AddressesTopicsFilter atfilter = new AddressesTopicsFilter(new RskAddress[0], null);
    LogFilter filter = new LogFilter(atfilter, blockchain, true, true);
    filter.newBlockReceived(block);
    filter.newBlockReceived(block);
    Object[] result = filter.getEvents();
    Assert.assertNotNull(result);
    Assert.assertEquals(1, result.length);
}
Also used : RepositoryLocator(co.rsk.db.RepositoryLocator) BlockStore(org.ethereum.db.BlockStore) Blockchain(org.ethereum.core.Blockchain) Block(org.ethereum.core.Block) RskTestFactory(org.ethereum.util.RskTestFactory) Test(org.junit.Test)

Example 13 with RskTestFactory

use of org.ethereum.util.RskTestFactory in project rskj by rsksmart.

the class LogFilterTest method eventAfterBlockWithEvent.

@Test
public void eventAfterBlockWithEvent() {
    RskTestFactory factory = new RskTestFactory();
    Blockchain blockchain = factory.getBlockchain();
    BlockStore blockStore = factory.getBlockStore();
    RepositoryLocator repositoryLocator = factory.getRepositoryLocator();
    Web3ImplLogsTest.addEmptyBlockToBlockchain(blockchain, blockStore, repositoryLocator, factory.getTrieStore());
    Block block = blockchain.getBestBlock();
    AddressesTopicsFilter atfilter = new AddressesTopicsFilter(new RskAddress[0], null);
    LogFilter filter = new LogFilter(atfilter, blockchain, false, true);
    filter.newBlockReceived(block);
    Object[] result = filter.getEvents();
    Assert.assertNotNull(result);
    Assert.assertEquals(1, result.length);
}
Also used : RepositoryLocator(co.rsk.db.RepositoryLocator) BlockStore(org.ethereum.db.BlockStore) Blockchain(org.ethereum.core.Blockchain) Block(org.ethereum.core.Block) RskTestFactory(org.ethereum.util.RskTestFactory) Test(org.junit.Test)

Aggregations

RskTestFactory (org.ethereum.util.RskTestFactory)13 Before (org.junit.Before)7 TestGenesisLoader (co.rsk.core.genesis.TestGenesisLoader)5 Blockchain (org.ethereum.core.Blockchain)5 Test (org.junit.Test)5 RepositoryLocator (co.rsk.db.RepositoryLocator)4 Block (org.ethereum.core.Block)3 BlockStore (org.ethereum.db.BlockStore)3 TestSystemProperties (co.rsk.config.TestSystemProperties)2 BlockDifficulty (co.rsk.core.BlockDifficulty)1 RskAddress (co.rsk.core.RskAddress)1 RepositorySnapshot (co.rsk.db.RepositorySnapshot)1 BlockBuilder (co.rsk.test.builders.BlockBuilder)1 ActivationConfig (org.ethereum.config.blockchain.upgrades.ActivationConfig)1 ConsensusRule (org.ethereum.config.blockchain.upgrades.ConsensusRule)1 Genesis (org.ethereum.core.Genesis)1 GenesisLoader (org.ethereum.core.genesis.GenesisLoader)1 CompositeEthereumListener (org.ethereum.listener.CompositeEthereumListener)1