Example #1
0
 async def _test_trie_sync():
     src_trie, contents = make_random_trie(random)
     dest_db = FakeAsyncAtomicDB()
     nodes_cache = AtomicDB()
     scheduler = HexaryTrieSync(src_trie.root_hash, dest_db, nodes_cache,
                                ExtendedDebugLogger("test"))
     requests = scheduler.next_batch()
     while len(requests) > 0:
         results = []
         for request in requests:
             results.append(
                 [request.node_key, src_trie.db[request.node_key]])
         await scheduler.process(results)
         requests = scheduler.next_batch(10)
     dest_trie = HexaryTrie(dest_db, src_trie.root_hash)
     for key, value in contents.items():
         assert dest_trie[key] == value
Example #2
0
async def test_state_sync():
    raw_db, state_root, contents = make_random_state(1000)
    dest_db = FakeAsyncAtomicDB()
    nodes_cache = AtomicDB()
    scheduler = StateSync(state_root, dest_db, nodes_cache,
                          ExtendedDebugLogger('test'))
    requests = scheduler.next_batch(10)
    while requests:
        results = []
        for request in requests:
            results.append([request.node_key, raw_db[request.node_key]])
        await scheduler.process(results)
        requests = scheduler.next_batch(10)

    result_account_db = AccountDB(dest_db, state_root)
    for addr, account_data in contents.items():
        balance, nonce, storage, code = account_data
        assert result_account_db.get_balance(addr) == balance
        assert result_account_db.get_nonce(addr) == nonce
        assert result_account_db.get_storage(addr, 0) == storage
        assert result_account_db.get_code(addr) == code
Example #3
0
def chaindb_churner(leveldb_churner):
    chain = load_mining_chain(FakeAsyncAtomicDB(leveldb_churner))
    assert chain.chaindb.get_canonical_head().block_number == 129
    return chain.chaindb
Example #4
0
def chaindb_fresh():
    chain = load_mining_chain(FakeAsyncAtomicDB())
    assert chain.chaindb.get_canonical_head().block_number == 0
    return chain.chaindb