From dc790d2a669b6843c284ed914bee2a2ff9982828 Mon Sep 17 00:00:00 2001 From: Jason Carver Date: Fri, 12 Jun 2020 10:41:43 -0700 Subject: [PATCH] Add trie walk test of partial leaf traversal Recently, there was a fix for incorrectly raising a TraversedPartialPath when traversing into a leaf, even if the suffix of the leaf did not match the traversal path. See: https://github.com/ethereum/py-trie/pull/114 This bug was actually found during a hypothesis run during a trie walk. Although there are new unit tests making sure the leaf traversal works properly, it seems worth adding the example explicitly as a kind of backup test that the scenario works properly during a trie walk & backfill. --- tests/test_hexary_trie_walk.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test_hexary_trie_walk.py b/tests/test_hexary_trie_walk.py index 47b5d583..2f30c2ef 100644 --- a/tests/test_hexary_trie_walk.py +++ b/tests/test_hexary_trie_walk.py @@ -222,6 +222,16 @@ def test_trie_walk_backfilling_with_traverse_from(trie_keys, minimum_value_lengt index_nibbles=[], index_nibbles2=[], ) +@example( + # Catch bug where TraversedPartialPath is raised when traversing into a leaf, + # even though the leaf suffix doesn't match the prefix that was being traversed to. + trie_keys=[b'\x00\x00\x00', b'\x10\x00\x00'], + minimum_value_length=26, + number_explorations=86, + trie_changes=[(1, None)], + index_nibbles=[], + index_nibbles2=[], +) def test_trie_walk_root_change_with_traverse( trie_keys, minimum_value_length,