use of co.rsk.trie.TrieStore in project rskj by rsksmart.
the class ContractDetailsImplTest method usingSameExternalStorage.
@Test
public void usingSameExternalStorage() {
TrieStore store = new TrieStoreImpl(new HashMapDB());
Trie trie = new TrieImpl(store, false);
byte[] accountAddress = randomAddress();
ContractDetailsImpl details = new ContractDetailsImpl(config, accountAddress, trie, null);
int nkeys = IN_MEMORY_STORAGE_LIMIT;
for (int k = 1; k <= nkeys + 1; k++) details.put(new DataWord(k), new DataWord(k * 2));
Assert.assertTrue(details.hasExternalStorage());
details.syncStorage();
ContractDetailsImpl details1 = new ContractDetailsImpl(config, details.getEncoded());
ContractDetailsImpl details2 = new ContractDetailsImpl(config, details.getEncoded());
Assert.assertTrue(details1.hasExternalStorage());
Assert.assertTrue(details2.hasExternalStorage());
for (int k = 1; k <= nkeys + 1; k++) Assert.assertNotNull(details1.get(new DataWord(k)));
for (int k = 1; k <= nkeys + 1; k++) Assert.assertNotNull(details2.get(new DataWord(k)));
details1.syncStorage();
details2.syncStorage();
}
use of co.rsk.trie.TrieStore in project rskj by rsksmart.
the class RepositoryImplTest method flushNoReconnect.
@Test
public void flushNoReconnect() {
TrieStore store = new TrieStoreImpl(new HashMapDB());
RepositoryImpl repository = new RepositoryImpl(config, store);
RskAddress accAddress = randomAccountAddress();
byte[] initialRoot = repository.getRoot();
repository.createAccount(accAddress);
repository.flushNoReconnect();
Assert.assertTrue(repository.isExist(accAddress));
}
use of co.rsk.trie.TrieStore in project rskj by rsksmart.
the class TransactionModuleTest method sendRawTransactionWithAutoMining.
@Test
public void sendRawTransactionWithAutoMining() throws Exception {
ReceiptStore receiptStore = new ReceiptStoreImpl(new HashMapDB());
World world = new World(receiptStore);
BlockChainImpl blockchain = world.getBlockChain();
TrieStore trieStore = world.getTrieStore();
RepositoryLocator repositoryLocator = world.getRepositoryLocator();
BlockStore blockStore = world.getBlockStore();
TransactionPool transactionPool = new TransactionPoolImpl(config, repositoryLocator, blockStore, blockFactory, null, buildTransactionExecutorFactory(blockStore, receiptStore, world.getBlockTxSignatureCache()), world.getReceivedTxSignatureCache(), 10, 100);
TransactionGateway transactionGateway = new TransactionGateway(new SimpleChannelManager(), transactionPool);
Web3Impl web3 = createEnvironment(blockchain, receiptStore, trieStore, transactionPool, blockStore, true, world.getBlockTxSignatureCache(), transactionGateway);
String txHash = sendRawTransaction(web3);
Assert.assertEquals(1, blockchain.getBestBlock().getNumber());
Assert.assertEquals(2, blockchain.getBestBlock().getTransactionsList().size());
Transaction txInBlock = getTransactionFromBlockWhichWasSend(blockchain, txHash);
// Transaction tx must be in the block mined.
Assert.assertEquals(txHash, txInBlock.getHash().toJsonString());
}
use of co.rsk.trie.TrieStore in project rskj by rsksmart.
the class TransactionModuleTest method sendTransactionMustBeMined.
@Test
public void sendTransactionMustBeMined() {
World world = new World();
BlockChainImpl blockchain = world.getBlockChain();
TrieStore trieStore = world.getTrieStore();
RepositoryLocator repositoryLocator = world.getRepositoryLocator();
RepositorySnapshot repository = repositoryLocator.snapshotAt(blockchain.getBestBlock().getHeader());
BlockStore blockStore = world.getBlockStore();
TransactionPool transactionPool = new TransactionPoolImpl(config, repositoryLocator, blockStore, blockFactory, null, buildTransactionExecutorFactory(blockStore, null, world.getBlockTxSignatureCache()), world.getReceivedTxSignatureCache(), 10, 100);
TransactionGateway transactionGateway = new TransactionGateway(new SimpleChannelManager(), transactionPool);
Web3Impl web3 = createEnvironment(blockchain, null, trieStore, transactionPool, blockStore, true, world.getBlockTxSignatureCache(), transactionGateway);
String tx = sendTransaction(web3, repository);
Assert.assertEquals(1, blockchain.getBestBlock().getNumber());
Assert.assertEquals(2, blockchain.getBestBlock().getTransactionsList().size());
Transaction txInBlock = getTransactionFromBlockWhichWasSend(blockchain, tx);
// Transaction tx must be in the block mined.
Assert.assertEquals(tx, txInBlock.getHash().toJsonString());
}
use of co.rsk.trie.TrieStore in project rskj by rsksmart.
the class TransactionModuleTest method sendRawTransactionWithoutAutoMining.
@Test
public void sendRawTransactionWithoutAutoMining() {
ReceiptStore receiptStore = new ReceiptStoreImpl(new HashMapDB());
World world = new World(receiptStore);
BlockChainImpl blockchain = world.getBlockChain();
TrieStore trieStore = world.getTrieStore();
RepositoryLocator repositoryLocator = world.getRepositoryLocator();
BlockStore blockStore = world.getBlockStore();
TransactionPool transactionPool = new TransactionPoolImpl(config, repositoryLocator, blockStore, blockFactory, null, buildTransactionExecutorFactory(blockStore, receiptStore, world.getBlockTxSignatureCache()), world.getReceivedTxSignatureCache(), 10, 100);
TransactionGateway transactionGateway = new TransactionGateway(new SimpleChannelManager(), transactionPool);
Web3Impl web3 = createEnvironment(blockchain, receiptStore, trieStore, transactionPool, blockStore, false, world.getBlockTxSignatureCache(), transactionGateway);
String txHash = sendRawTransaction(web3);
Assert.assertEquals(0, blockchain.getBestBlock().getNumber());
Assert.assertEquals(1, transactionPool.getPendingTransactions().size());
Assert.assertEquals(txHash, transactionPool.getPendingTransactions().get(0).getHash().toJsonString());
}
Aggregations