Search in sources :

Example 6 with MockDB

use of org.aion.db.impl.mockdb.MockDB in project aion by aionnetwork.

the class TrieTest method testInsertRandomMultipleItems.

/**
 * @param pairs
 * @implNote By design the keys are distinct due to the use of HashMap.
 */
@Test
@Parameters(method = "keyValuePairsParameters")
public void testInsertRandomMultipleItems(HashMap<String, String> pairs) {
    boolean print = false;
    if (print) {
        System.out.println("Number of pairs = " + pairs.size());
    }
    TrieImpl trie = new TrieImpl(new MockDB("TestInsertRandomMultipleItems"));
    String key, value;
    for (Map.Entry<String, String> entry : pairs.entrySet()) {
        key = entry.getKey();
        value = entry.getValue();
        if (print) {
            System.out.println("(" + key + "," + value + ")");
        }
        // insert (key,value)
        trie.update(key, value);
        assertThat(new String(trie.get(key))).isEqualTo(value);
    }
    // ensure that everything is still there
    for (Map.Entry<String, String> entry : pairs.entrySet()) {
        key = entry.getKey();
        value = entry.getValue();
        assertThat(new String(trie.get(key))).isEqualTo(value);
    }
}
Also used : TrieImpl(org.aion.mcf.trie.TrieImpl) MockDB(org.aion.db.impl.mockdb.MockDB) Parameters(junitparams.Parameters) Test(org.junit.Test)

Aggregations

MockDB (org.aion.db.impl.mockdb.MockDB)6 TrieImpl (org.aion.mcf.trie.TrieImpl)5 Test (org.junit.Test)5 Parameters (junitparams.Parameters)3 Before (org.junit.Before)1