Skip to content

Test Storage Trie Structure

Documentation for tests/mpt/test_storage_trie_structure.py@02aafd78.

Generate fixtures for these test cases for Bogota with:

fill -v tests/mpt/test_storage_trie_structure.py --fork Bogota

Exercise the Merkle Patricia Trie via storage slots.

Every test writes slots whose keccak256 hashes (see constants.py) force one node operation: a leaf split, an extension split, a branch collapse, an extension merge, or a leaf crossing the 32-byte inlining threshold.

Tests with several transactions write through SLOT_WRITER, so successive transactions or blocks can write different slots of one contract; single-transaction tests use fixed code.

Test Functions Overview

Name Type Cases (Bogota) Description
test_delete_all_slots_empties_trie state_test 3 Delete every slot in one transaction.
test_delete_around_inline_leaves blockchain_test 4 Delete next to inline leaves; re-insert in the next block.
test_delete_from_block_built_trie blockchain_test 14 Zero one slot of a trie built in an earlier block, then restore it.
test_delete_from_genesis_trie state_test 14 Zero one slot of a storage trie committed at genesis.
test_delete_inline_leaf_survivor_stays_inline blockchain_test 2 Collapse a branch of inline leaves; the survivor stays inline.
test_delete_missing_is_noop state_test 3 Zero a slot that is not in the trie; the root does not change.
test_delete_sibling_and_update_survivor_same_block blockchain_test 1 Zero one sibling and overwrite the other within one block.
test_delete_then_reinsert_same_block blockchain_test 2 Zero a slot and write it back within one block.
test_delete_via_zero_value state_test 1 Zero the only slot.
test_embedded_leaf_boundary state_test 5 Leaf RLP of exactly 30, 31, 32 and 33 bytes.
test_insert_diverges_at_extension_first_nibble state_test 2 Insert a key that differs from a root extension in its first nibble.
test_insert_full_branch_across_blocks blockchain_test 2 Fill a 16-way branch over two blocks, in two orders.
test_insert_full_branch_arity_sixteen state_test 1 Sixteen slots sharing four nibbles fill every child of one branch.
test_insert_into_committed_extension state_test 1 Insert a key that diverges in the middle of a committed extension.
test_insert_leaf_into_empty_trie state_test 1 First write into an empty storage trie.
test_insert_pair_sharing_one_nibble state_test 1 Two slots sharing one nibble: the shortest extension a split creates.
test_insert_splits_below_root_branch state_test 2 Split a leaf that hangs off a committed root branch.
test_insert_splits_extension_under_branch state_test 4 Split an extension that hangs off a root branch, at each offset.
test_insert_splits_into_extension_and_branch state_test 1 Two slots sharing four nibbles, written into an empty trie.
test_insert_splits_nested_extension_first_nibble state_test 1 Insert a key that differs from a nested extension in its first nibble.
test_insert_then_delete_beside_real_change blockchain_test 1 Round-trip one leaf's value while its sibling really changes.
test_insert_then_delete_same_block blockchain_test 3 Write a slot and zero it again in one block; the root does not change.
test_mass_delete_sixteen_to_one state_test 1 Zero fifteen of sixteen children in one transaction.
test_one_to_sixteen_into_committed_leaf blockchain_test 1 Grow a committed single leaf into a full branch in one block.
test_replace_child_within_branch_slot blockchain_test 1 Zero a leaf and write another key into the same branch slot.
test_restructure_two_disjoint_paths_same_block blockchain_test 2 Restructure two sibling subtrees of the root branch in one block.
test_root_branch_arity_sixteen state_test 3 Fill a 16-way root branch from empty, or reduce one to 15 or 1 child.
test_shared_node_deleted_in_one_trie blockchain_test 1 Two contracts hold byte-identical storage tries; one is emptied.
test_two_shape_changes_at_different_depths blockchain_test 1 Collapse at depth 2 and split at depth 3 within one block.
test_two_storage_tries_reshaped_same_block blockchain_test 1 Collapse one contract's trie and split another's in one block.
test_update_existing_leaf state_test 1 Overwrite the only leaf; the value changes, the shape does not.
test_update_inline_leaf blockchain_test 2 Overwrite an inline leaf's value, then restore it.