def get(self, key): validate_is_bytes(key) trie_key = bytes_to_nibbles(key) root_hash = self.root_hash try: return self._get(root_hash, trie_key) except MissingTraversalNode as traverse_exc: raise MissingTrieNode( traverse_exc.missing_node_hash, root_hash, key, traverse_exc.nibbles_traversed, ) from traverse_exc
def _raise_missing_node(self, exception, key): # Indicate more information about which key was requested, which node was missing, etc raise MissingTrieNode(exception.args[0], self.root_hash, key) from exception
def test_invalid_MissingTrieNode_prefix(invalid_prefix, exception): with pytest.raises(exception): MissingTrieNode(b'', b'', b'', invalid_prefix)
def test_valid_MissingTrieNode_prefix(valid_prefix): exception = MissingTrieNode(b'', b'', b'', valid_prefix) assert exception.prefix == valid_prefix if valid_prefix is not None: assert str(Nibbles(valid_prefix)) in repr(exception)