use of co.rsk.trie.Trie in project rskj by rsksmart.
the class TrieImplHashTest method sonWithNoSiblingsAndOnlyOneSonShouldBringSameHashBaseCase.
@Test
public void sonWithNoSiblingsAndOnlyOneSonShouldBringSameHashBaseCase() {
Trie trie1 = new TrieImpl().put("roose", "42".getBytes()).put("roosevalt", "4243".getBytes()).put("roosevaltroosevalt", "424344".getBytes()).delete("roosevalt");
Trie trie2 = new TrieImpl().put("roose", "42".getBytes()).put("roosevaltroosevalt", "424344".getBytes());
Assert.assertTrue(Arrays.equals(trie1.get("roose"), "42".getBytes()));
Assert.assertTrue(Arrays.equals(trie1.get("roosevaltroosevalt"), "424344".getBytes()));
Assert.assertNull(trie1.get("roosevalt"));
Assert.assertEquals(trie1.getHash(), trie2.getHash());
}
use of co.rsk.trie.Trie in project rskj by rsksmart.
the class TrieImplHashTest method sonWithNoSiblingsAndOnlyOneSonShouldBringSameHashRecursionCase.
@Test
public void sonWithNoSiblingsAndOnlyOneSonShouldBringSameHashRecursionCase() {
Trie trie1 = new TrieImpl().put("ro", "4".getBytes()).put("roose", "42".getBytes()).put("roosevalt", "4243".getBytes()).put("roosevaltroosevalt", "424344".getBytes()).delete("roosevalt");
Trie trie2 = new TrieImpl().put("ro", "4".getBytes()).put("roose", "42".getBytes()).put("roosevaltroosevalt", "424344".getBytes());
Assert.assertTrue(Arrays.equals(trie1.get("ro"), "4".getBytes()));
Assert.assertTrue(Arrays.equals(trie1.get("roose"), "42".getBytes()));
Assert.assertTrue(Arrays.equals(trie1.get("roosevaltroosevalt"), "424344".getBytes()));
Assert.assertNull(trie1.get("roosevalt"));
Assert.assertEquals(trie1.getHash(), trie2.getHash());
}
use of co.rsk.trie.Trie in project rskj by rsksmart.
the class TrieImplHashTest method sonWithNoSiblingsAndOnlyOneSonWithSonsShouldBringSameHashBaseCase.
@Test
public void sonWithNoSiblingsAndOnlyOneSonWithSonsShouldBringSameHashBaseCase() {
Trie trie1 = new TrieImpl().put("roose", "42".getBytes()).put("roosevalt", "4243".getBytes()).put("roosevaltroosevalt", "424344".getBytes()).put("roosevaltroosevaltroosevaltroosevalt", "42434445".getBytes()).delete("roosevalt");
Trie trie2 = new TrieImpl().put("roose", "42".getBytes()).put("roosevaltroosevalt", "424344".getBytes()).put("roosevaltroosevaltroosevaltroosevalt", "42434445".getBytes());
Assert.assertTrue(Arrays.equals(trie1.get("roose"), "42".getBytes()));
Assert.assertTrue(Arrays.equals(trie1.get("roosevaltroosevalt"), "424344".getBytes()));
Assert.assertTrue(Arrays.equals(trie1.get("roosevaltroosevaltroosevaltroosevalt"), "42434445".getBytes()));
Assert.assertNull(trie1.get("roosevalt"));
Assert.assertEquals(trie1.getHash(), trie2.getHash());
}
use of co.rsk.trie.Trie in project rskj by rsksmart.
the class TrieImplHashTest method sonWithNoSiblingsAndOnlyOneSonWithSonsShouldBringSameHashRecursionCase.
@Test
public void sonWithNoSiblingsAndOnlyOneSonWithSonsShouldBringSameHashRecursionCase() {
Trie trie1 = new TrieImpl().put("ro", "4".getBytes()).put("roose", "42".getBytes()).put("roosevalt", "4243".getBytes()).put("roosevaltroosevalt", "424344".getBytes()).put("roosevaltroosevaltroosevaltroosevalt", "42434445".getBytes()).delete("roosevalt");
Trie trie2 = new TrieImpl().put("ro", "4".getBytes()).put("roose", "42".getBytes()).put("roosevaltroosevalt", "424344".getBytes()).put("roosevaltroosevaltroosevaltroosevalt", "42434445".getBytes());
Assert.assertTrue(Arrays.equals(trie1.get("ro"), "4".getBytes()));
Assert.assertTrue(Arrays.equals(trie1.get("roose"), "42".getBytes()));
Assert.assertTrue(Arrays.equals(trie1.get("roosevaltroosevalt"), "424344".getBytes()));
Assert.assertTrue(Arrays.equals(trie1.get("roosevaltroosevaltroosevaltroosevalt"), "42434445".getBytes()));
Assert.assertNull(trie1.get("roosevalt"));
Assert.assertEquals(trie1.getHash(), trie2.getHash());
}
Aggregations