velas/triedb

Implement fuzzy test for diff/verify and DataWithRoot

Opened this issue · 0 comments

vldm commented

Fully random test for diff/verify.

KeyLen - variable (in some short range [4..8] limited by nibbles values]
dataLen - variable (random with len [0..32])

Implement following algorithm:

  1. Generate Abstract::Map<Key, DataWithRoot>, DataWithRoot = Struct + storage:Map<Key, Data>
  2. Create trie from Map.
  3. Generate Abstract::Diff based on Map from 1 (Vector of random Inserts and removes from original Map) Vec<Key, DataWithRootChange> DataWithRootChange = Insert(Struct, Key, Data) | Remove(Key);
  4. Use Diff to create second trie

for verify:

  1. Clone first trie (from step 2)
  2. create diff and apply to create new trie.

assert:

  1. That diff can be created from first and second trie (step 2, step 5)
  2. Check that verify method return ok for diff creation method.
  3. Check that after apply internall storage from original db, and one that apply diffs is the same.