use of org.ethereum.datasource.HashMapDB 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));
}
use of org.ethereum.datasource.HashMapDB in project rskj by rsksmart.
the class SecureTrieImplSaveRetrieveTest method updateSaveRetrieveAndGetOneThousandKeyValuesUsingBinaryTree.
@Test
public void updateSaveRetrieveAndGetOneThousandKeyValuesUsingBinaryTree() {
HashMapDB map = new HashMapDB();
TrieStoreImpl store = new TrieStoreImpl(map);
Trie trie = new TrieImpl(store, true);
for (int k = 0; k < 1000; k++) trie = trie.put(k + "", (k + "").getBytes());
trie.save();
Trie trie2 = store.retrieve(trie.getHash().getBytes());
Assert.assertNotNull(trie2);
Assert.assertEquals(trie.getHash(), trie2.getHash());
for (int k = 0; k < 1000; k++) {
String key = k + "";
byte[] expected = trie.get(key);
byte[] value = trie2.get(key);
Assert.assertArrayEquals(expected, value);
}
}
use of org.ethereum.datasource.HashMapDB in project rskj by rsksmart.
the class SecureTrieImplSaveRetrieveTest method updateSaveRetrieveAndGetOneThousandKeyValuesInverseOrder.
@Test
public void updateSaveRetrieveAndGetOneThousandKeyValuesInverseOrder() {
HashMapDB map = new HashMapDB();
TrieStoreImpl store = new TrieStoreImpl(map);
Trie trie = new TrieImpl(store, true);
for (int k = 1000; k > 0; k--) trie = trie.put(k + "", (k + "").getBytes());
trie.save();
Trie trie2 = store.retrieve(trie.getHash().getBytes());
Assert.assertNotNull(trie2);
Assert.assertEquals(trie.getHash(), trie2.getHash());
for (int k = 1000; k > 0; k--) {
String key = k + "";
byte[] expected = trie.get(key);
byte[] value = trie2.get(key);
Assert.assertArrayEquals(expected, value);
}
}
use of org.ethereum.datasource.HashMapDB in project rskj by rsksmart.
the class SecureTrieImplSaveRetrieveTest method updateSaveRetrieveAndGetOneThousandKeyValues.
@Test
public void updateSaveRetrieveAndGetOneThousandKeyValues() {
HashMapDB map = new HashMapDB();
TrieStoreImpl store = new TrieStoreImpl(map);
Trie trie = new TrieImpl(store, true);
for (int k = 0; k < 1000; k++) trie = trie.put(k + "", (k + "").getBytes());
trie.save();
Trie trie2 = store.retrieve(trie.getHash().getBytes());
Assert.assertNotNull(trie2);
Assert.assertEquals(trie.getHash(), trie2.getHash());
for (int k = 0; k < 1000; k++) {
String key = k + "";
byte[] expected = trie.get(key);
byte[] value = trie2.get(key);
Assert.assertArrayEquals(expected, value);
}
}
use of org.ethereum.datasource.HashMapDB in project rskj by rsksmart.
the class SecureTrieImplStoreTest method saveFullTrieTwice.
@Test
public void saveFullTrieTwice() {
HashMapDB map = new HashMapDB();
TrieStoreImpl store = new TrieStoreImpl(map);
Trie trie = new TrieImpl(store, true).put("foo", "bar".getBytes());
trie.save();
Assert.assertEquals(trie.trieSize(), store.getSaveCount());
trie.save();
Assert.assertEquals(trie.trieSize(), store.getSaveCount());
}
Aggregations