use of co.rsk.trie.TrieStore in project rskj by rsksmart.
the class BlockExecutorTest method generateBlockWithOneStrangeTransaction.
public TestObjects generateBlockWithOneStrangeTransaction(int strangeTransactionType) {
TrieStore trieStore = new TrieStoreImpl(new HashMapDB());
Repository repository = new MutableRepository(trieStore, new Trie(trieStore));
Repository track = repository.startTracking();
Account account = createAccount("acctest1", track, Coin.valueOf(30000));
Account account2 = createAccount("acctest2", track, Coin.valueOf(10L));
track.commit();
Assert.assertFalse(Arrays.equals(EMPTY_TRIE_HASH, repository.getRoot()));
BlockExecutor executor = buildBlockExecutor(trieStore);
List<Transaction> txs = new ArrayList<>();
Transaction tx = createStrangeTransaction(account, account2, BigInteger.TEN, repository.getNonce(account.getAddress()), strangeTransactionType);
txs.add(tx);
List<BlockHeader> uncles = new ArrayList<>();
Block genesis = BlockChainImplTest.getGenesisBlock(trieStore);
genesis.setStateRoot(repository.getRoot());
Block block = new BlockGenerator().createChildBlock(genesis, txs, uncles, 1, null);
// Forces all transactions included
executor.executeAndFillReal(block, genesis.getHeader());
repository.save();
return new TestObjects(trieStore, block, genesis, tx, account);
}
use of co.rsk.trie.TrieStore in project rskj by rsksmart.
the class NetworkStateExporterTest method setup.
@Before
public void setup() {
TrieStore trieStore = new TrieStoreImpl(new HashMapDB());
MutableTrieImpl mutableTrie = new MutableTrieImpl(trieStore, new Trie(trieStore));
repository = new MutableRepository(mutableTrie);
blockchain = mock(Blockchain.class);
block = mock(Block.class);
when(blockchain.getBestBlock()).thenReturn(block);
BlockHeader blockHeader = mock(BlockHeader.class);
when(block.getHeader()).thenReturn(blockHeader);
RepositoryLocator repositoryLocator = mock(RepositoryLocator.class);
when(repositoryLocator.snapshotAt(block.getHeader())).thenReturn(new MutableRepository(mutableTrie));
this.nse = new NetworkStateExporter(repositoryLocator, blockchain);
}
use of co.rsk.trie.TrieStore in project rskj by rsksmart.
the class ShowStateInfo method onExecute.
@Override
protected void onExecute(@Nonnull String[] args, @Nonnull RskContext ctx) throws Exception {
BlockStore blockStore = ctx.getBlockStore();
TrieStore trieStore = ctx.getTrieStore();
printStateInfo(args, blockStore, trieStore);
}
use of co.rsk.trie.TrieStore in project rskj by rsksmart.
the class RskContextTest method shouldBuildMultiTrieStoreMigratingSingleTrieStore.
@Test
public void shouldBuildMultiTrieStoreMigratingSingleTrieStore() throws IOException {
rskContext.close();
long numberOfEpochs = 3;
Path testDatabasesDirectory = databaseDir.toPath();
doReturn(new GarbageCollectorConfig(true, 1000, (int) numberOfEpochs)).when(testProperties).garbageCollectorConfig();
rskContext = makeRskContext();
TrieStore trieStore = rskContext.getTrieStore();
assertThat(trieStore, is(instanceOf(MultiTrieStore.class)));
assertThat(Files.list(testDatabasesDirectory).count(), is(numberOfEpochs));
assertThat(Files.list(testDatabasesDirectory).noneMatch(p -> p.getFileName().toString().equals("unitrie")), is(true));
}
use of co.rsk.trie.TrieStore in project rskj by rsksmart.
the class RskContextTest method shouldBuildMultiTrieStore.
@Test
public void shouldBuildMultiTrieStore() throws IOException {
long numberOfEpochs = 3;
Path testDatabasesDirectory = databaseDir.toPath();
doReturn(new GarbageCollectorConfig(true, 1000, (int) numberOfEpochs)).when(testProperties).garbageCollectorConfig();
TrieStore trieStore = rskContext.getTrieStore();
assertThat(trieStore, is(instanceOf(MultiTrieStore.class)));
assertThat(Files.list(testDatabasesDirectory).count(), is(numberOfEpochs));
}
Aggregations