use of org.aion.mcf.trie.TrieImpl in project aion by aionnetwork.
the class TrieTestWithRootHashValues method testDeleteLongString2.
@Test
public void testDeleteLongString2() {
String ROOT_HASH_BEFORE = "e020de34ca26f8d373ff2c0a8ac3a4cb9032bfa7a194c68330b7ac3584a1d388";
String ROOT_HASH_AFTER = "334511f0c4897677b782d13a6fa1e58e18de6b24879d57ced430bad5ac831cb2";
TrieImpl trie = new TrieImpl(mockDb);
trie.update(ca, LONG_STRING);
assertEquals(LONG_STRING, new String(trie.get(ca)));
trie.update(cat, LONG_STRING);
assertEquals(LONG_STRING, new String(trie.get(cat)));
assertEquals(ROOT_HASH_BEFORE, Hex.toHexString(trie.getRootHash()));
trie.delete(cat);
assertEquals("", new String(trie.get(cat)));
assertEquals(ROOT_HASH_AFTER, Hex.toHexString(trie.getRootHash()));
}
use of org.aion.mcf.trie.TrieImpl in project aion by aionnetwork.
the class TrieTestWithRootHashValues method testDeleteAll.
@Test
public void testDeleteAll() {
String ROOT_HASH_BEFORE = "a84739b4762ddf15e3acc4e6957e5ab2bbfaaef00fe9d436a7369c6f058ec90d";
TrieImpl trie = new TrieImpl(null);
assertEquals(ROOT_HASH_EMPTY, Hex.toHexString(trie.getRootHash()));
trie.update(ca, dude);
trie.update(cat, dog);
trie.update(doge, LONG_STRING);
assertEquals(ROOT_HASH_BEFORE, Hex.toHexString(trie.getRootHash()));
trie.delete(ca);
trie.delete(cat);
trie.delete(doge);
assertEquals(ROOT_HASH_EMPTY, Hex.toHexString(trie.getRootHash()));
}
use of org.aion.mcf.trie.TrieImpl in project aion by aionnetwork.
the class TrieTestWithRootHashValues method testDeleteLongString1.
@Test
public void testDeleteLongString1() {
String ROOT_HASH_BEFORE = "318961a1c8f3724286e8e80d312352f01450bc4892c165cc7614e1c2e5a0012a";
String ROOT_HASH_AFTER = "63356ecf33b083e244122fca7a9b128cc7620d438d5d62e4f8b5168f1fb0527b";
TrieImpl trie = new TrieImpl(mockDb);
trie.update(cat, LONG_STRING);
assertEquals(LONG_STRING, new String(trie.get(cat)));
trie.update(dog, LONG_STRING);
assertEquals(LONG_STRING, new String(trie.get(dog)));
assertEquals(ROOT_HASH_BEFORE, Hex.toHexString(trie.getRootHash()));
trie.delete(dog);
assertEquals("", new String(trie.get(dog)));
assertEquals(ROOT_HASH_AFTER, Hex.toHexString(trie.getRootHash()));
}
use of org.aion.mcf.trie.TrieImpl in project aion by aionnetwork.
the class TrieTestWithRootHashValues method testDeleteLongString3.
@Test
public void testDeleteLongString3() {
String ROOT_HASH_BEFORE = "e020de34ca26f8d373ff2c0a8ac3a4cb9032bfa7a194c68330b7ac3584a1d388";
String ROOT_HASH_AFTER = "63356ecf33b083e244122fca7a9b128cc7620d438d5d62e4f8b5168f1fb0527b";
TrieImpl trie = new TrieImpl(mockDb);
trie.update(cat, LONG_STRING);
assertEquals(LONG_STRING, new String(trie.get(cat)));
trie.update(ca, LONG_STRING);
assertEquals(LONG_STRING, new String(trie.get(ca)));
assertEquals(ROOT_HASH_BEFORE, Hex.toHexString(trie.getRootHash()));
trie.delete(ca);
assertEquals("", new String(trie.get(ca)));
assertEquals(ROOT_HASH_AFTER, Hex.toHexString(trie.getRootHash()));
}
use of org.aion.mcf.trie.TrieImpl in project aion by aionnetwork.
the class TrieTestWithRootHashValues method testDeleteMultipleItems1.
@Test
public void testDeleteMultipleItems1() {
String ROOT_HASH_BEFORE = "3a784eddf1936515f0313b073f99e3bd65c38689021d24855f62a9601ea41717";
String ROOT_HASH_AFTER1 = "60a2e75cfa153c4af2783bd6cb48fd6bed84c6381bc2c8f02792c046b46c0653";
String ROOT_HASH_AFTER2 = "a84739b4762ddf15e3acc4e6957e5ab2bbfaaef00fe9d436a7369c6f058ec90d";
TrieImpl trie = new TrieImpl(mockDb);
trie.update(cat, dog);
assertEquals(dog, new String(trie.get(cat)));
trie.update(ca, dude);
assertEquals(dude, new String(trie.get(ca)));
trie.update(doge, LONG_STRING);
assertEquals(LONG_STRING, new String(trie.get(doge)));
trie.update(dog, test);
assertEquals(test, new String(trie.get(dog)));
trie.update(test, LONG_STRING);
assertEquals(LONG_STRING, new String(trie.get(test)));
assertEquals(ROOT_HASH_BEFORE, Hex.toHexString(trie.getRootHash()));
trie.delete(dog);
assertEquals("", new String(trie.get(dog)));
assertEquals(ROOT_HASH_AFTER1, Hex.toHexString(trie.getRootHash()));
trie.delete(test);
assertEquals("", new String(trie.get(test)));
assertEquals(ROOT_HASH_AFTER2, Hex.toHexString(trie.getRootHash()));
}
Aggregations