Search in sources :

Example 6 with ReceiptStore

use of org.ethereum.db.ReceiptStore in project rskj by rsksmart.

the class Web3ImplTest method getUnknownTransactionReceipt.

@Test
public void getUnknownTransactionReceipt() throws Exception {
    ReceiptStore receiptStore = new ReceiptStoreImpl(new HashMapDB());
    World world = new World(receiptStore);
    Web3Impl web3 = createWeb3(world, receiptStore);
    Account acc1 = new AccountBuilder().name("acc1").build();
    Account acc2 = new AccountBuilder().name("acc2").build();
    Transaction tx = new TransactionBuilder().sender(acc1).receiver(acc2).value(BigInteger.valueOf(1000000)).build();
    String hashString = tx.getHash().toHexString();
    Assert.assertNull(web3.eth_getTransactionReceipt(hashString));
}
Also used : ReceiptStoreImpl(org.ethereum.db.ReceiptStoreImpl) TransactionBuilder(co.rsk.test.builders.TransactionBuilder) AccountBuilder(co.rsk.test.builders.AccountBuilder) HashMapDB(org.ethereum.datasource.HashMapDB) World(co.rsk.test.World) ReceiptStore(org.ethereum.db.ReceiptStore) Test(org.junit.Test)

Example 7 with ReceiptStore

use of org.ethereum.db.ReceiptStore in project rskj by rsksmart.

the class BlockChainImplTest method createBlockChain.

private static BlockChainImpl createBlockChain(Repository repository, IndexedBlockStore blockStore, BlockValidatorImpl blockValidator) {
    KeyValueDataSource ds = new HashMapDB();
    ds.init();
    ReceiptStore receiptStore = new ReceiptStoreImpl(ds);
    AdminInfo adminInfo = new SimpleAdminInfo();
    EthereumListener listener = new BlockExecutorTest.SimpleEthereumListener();
    BlockChainImpl blockChain = new BlockChainImpl(config, repository, blockStore, receiptStore, null, listener, adminInfo, blockValidator);
    TransactionPoolImpl transactionPool = new TransactionPoolImpl(config, repository, blockStore, receiptStore, null, listener, 10, 100);
    blockChain.setTransactionPool(transactionPool);
    return blockChain;
}
Also used : ReceiptStoreImpl(org.ethereum.db.ReceiptStoreImpl) EthereumListener(org.ethereum.listener.EthereumListener) AdminInfo(org.ethereum.manager.AdminInfo) KeyValueDataSource(org.ethereum.datasource.KeyValueDataSource) HashMapDB(org.ethereum.datasource.HashMapDB) ReceiptStore(org.ethereum.db.ReceiptStore)

Example 8 with ReceiptStore

use of org.ethereum.db.ReceiptStore in project rskj by rsksmart.

the class Web3ImplLogsTest method getWeb3WithEventInContractCreation.

private Web3Impl getWeb3WithEventInContractCreation() {
    ReceiptStore receiptStore = new ReceiptStoreImpl(new HashMapDB());
    World world = getWorld3WithBlockWithEventInContractCreation(config, receiptStore);
    TransactionPool transactionPool = new TransactionPoolImpl(config, world.getRepository(), world.getBlockChain().getBlockStore(), receiptStore, null, null, 10, 100);
    Web3Impl web3 = createWeb3(world.getBlockChain(), transactionPool, receiptStore);
    web3.personal_newAccountWithSeed("notDefault");
    return web3;
}
Also used : ReceiptStoreImpl(org.ethereum.db.ReceiptStoreImpl) TransactionPoolImpl(co.rsk.core.bc.TransactionPoolImpl) HashMapDB(org.ethereum.datasource.HashMapDB) World(co.rsk.test.World) ReceiptStore(org.ethereum.db.ReceiptStore)

Example 9 with ReceiptStore

use of org.ethereum.db.ReceiptStore in project rskj by rsksmart.

the class Web3ImplTest method getTransactionReceiptNotInMainBlockchain.

@Test
public void getTransactionReceiptNotInMainBlockchain() throws Exception {
    ReceiptStore receiptStore = new ReceiptStoreImpl(new HashMapDB());
    World world = new World(receiptStore);
    Web3Impl web3 = createWeb3(world, receiptStore);
    Account acc1 = new AccountBuilder(world).name("acc1").balance(Coin.valueOf(2000000)).build();
    Account acc2 = new AccountBuilder().name("acc2").build();
    Transaction tx = new TransactionBuilder().sender(acc1).receiver(acc2).value(BigInteger.valueOf(1000000)).build();
    List<Transaction> txs = new ArrayList<>();
    txs.add(tx);
    Block genesis = world.getBlockChain().getBestBlock();
    Block block1 = new BlockBuilder(world).parent(genesis).difficulty(3l).transactions(txs).build();
    org.junit.Assert.assertEquals(ImportResult.IMPORTED_BEST, world.getBlockChain().tryToConnect(block1));
    Block block1b = new BlockBuilder(world).parent(genesis).difficulty(block1.getDifficulty().asBigInteger().longValue() - 1).build();
    Block block2b = new BlockBuilder(world).difficulty(2).parent(block1b).build();
    org.junit.Assert.assertEquals(ImportResult.IMPORTED_NOT_BEST, world.getBlockChain().tryToConnect(block1b));
    org.junit.Assert.assertEquals(ImportResult.IMPORTED_BEST, world.getBlockChain().tryToConnect(block2b));
    String hashString = tx.getHash().toHexString();
    TransactionReceiptDTO tr = web3.eth_getTransactionReceipt(hashString);
    Assert.assertNull(tr);
}
Also used : TransactionBuilder(co.rsk.test.builders.TransactionBuilder) HashMapDB(org.ethereum.datasource.HashMapDB) World(co.rsk.test.World) ReceiptStoreImpl(org.ethereum.db.ReceiptStoreImpl) TransactionReceiptDTO(org.ethereum.rpc.dto.TransactionReceiptDTO) AccountBuilder(co.rsk.test.builders.AccountBuilder) ReceiptStore(org.ethereum.db.ReceiptStore) BlockBuilder(co.rsk.test.builders.BlockBuilder) Test(org.junit.Test)

Aggregations

ReceiptStore (org.ethereum.db.ReceiptStore)9 HashMapDB (org.ethereum.datasource.HashMapDB)8 ReceiptStoreImpl (org.ethereum.db.ReceiptStoreImpl)8 World (co.rsk.test.World)6 Test (org.junit.Test)5 AccountBuilder (co.rsk.test.builders.AccountBuilder)4 TransactionPoolImpl (co.rsk.core.bc.TransactionPoolImpl)3 BlockBuilder (co.rsk.test.builders.BlockBuilder)3 TransactionBuilder (co.rsk.test.builders.TransactionBuilder)3 BlockChainImpl (co.rsk.core.bc.BlockChainImpl)2 RepositoryImpl (co.rsk.db.RepositoryImpl)2 KeyValueDataSource (org.ethereum.datasource.KeyValueDataSource)2 AdminInfo (org.ethereum.manager.AdminInfo)2 TransactionReceiptDTO (org.ethereum.rpc.dto.TransactionReceiptDTO)2 co.rsk.bitcoinj.core (co.rsk.bitcoinj.core)1 BlockGenerator (co.rsk.blockchain.utils.BlockGenerator)1 RskSystemProperties (co.rsk.config.RskSystemProperties)1 BlockDifficulty (co.rsk.core.BlockDifficulty)1 RskAddress (co.rsk.core.RskAddress)1 SimpleRskTransaction (co.rsk.peg.simples.SimpleRskTransaction)1