use of org.ethereum.datasource.HashMapDB in project rskj by rsksmart.
the class SecureTrieImplStoreTest method retrieveTrieWithLongValuesByHash.
@Test
public void retrieveTrieWithLongValuesByHash() {
HashMapDB map = new HashMapDB();
TrieStoreImpl store = new TrieStoreImpl(map);
Trie trie = new TrieImpl(store, true).put("bar", TrieImplValueTest.makeValue(100)).put("foo", TrieImplValueTest.makeValue(200));
trie.save();
int size = trie.trieSize();
Trie trie2 = store.retrieve(trie.getHash().getBytes());
Assert.assertEquals(1, store.getRetrieveCount());
Assert.assertEquals(size, trie2.trieSize());
Assert.assertEquals(size, store.getRetrieveCount());
}
use of org.ethereum.datasource.HashMapDB in project rskj by rsksmart.
the class SecureTrieImplStoreTest method saveFullTrieUpdateAndSaveAgainUsingBinaryTrie.
@Test
public void saveFullTrieUpdateAndSaveAgainUsingBinaryTrie() {
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 = trie.put("foo", "bar2".getBytes());
trie.save();
Assert.assertEquals(trie.trieSize() + 1, store.getSaveCount());
}
use of org.ethereum.datasource.HashMapDB in project rskj by rsksmart.
the class SecureTrieImplStoreTest method saveFullTrieWithLongValueTwice.
@Test
public void saveFullTrieWithLongValueTwice() {
HashMapDB map = new HashMapDB();
TrieStoreImpl store = new TrieStoreImpl(map);
Trie trie = new TrieImpl(store, true).put("foo", TrieImplValueTest.makeValue(100));
trie.save();
Assert.assertEquals(2, store.getSaveCount());
trie.save();
Assert.assertEquals(2, store.getSaveCount());
}
use of org.ethereum.datasource.HashMapDB in project rskj by rsksmart.
the class SecureTrieImplStoreTest method saveFullTrieUpdateAndSaveAgain.
@Test
public void saveFullTrieUpdateAndSaveAgain() {
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 = trie.put("foo", "bar2".getBytes());
trie.save();
Assert.assertEquals(trie.trieSize() + 1, store.getSaveCount());
}
use of org.ethereum.datasource.HashMapDB in project rskj by rsksmart.
the class SecureTrieImplStoreTest method saveTrieNode.
@Test
public void saveTrieNode() {
HashMapDB map = new HashMapDB();
TrieStoreImpl store = new TrieStoreImpl(map);
Trie trie = new TrieImpl(store, true).put("foo", "bar".getBytes());
store.save(trie);
Assert.assertEquals(1, map.keys().size());
Assert.assertNotNull(map.get(trie.getHash().getBytes()));
Assert.assertArrayEquals(trie.toMessage(), map.get(trie.getHash().getBytes()));
Assert.assertEquals(1, store.getSaveCount());
}
Aggregations