Fixed deletes
This commit is contained in:
parent
210cae3fed
commit
6707f00277
|
@ -56,7 +56,10 @@ def _get(db, node, keypath):
|
|||
|
||||
def _update(db, node, keypath, val):
|
||||
if not keypath:
|
||||
return hash_and_save(db, val)
|
||||
if val:
|
||||
return hash_and_save(db, val)
|
||||
else:
|
||||
return b''
|
||||
if not node:
|
||||
return hash_and_save(db, encode_kv_node(keypath, hash_and_save(db, val)))
|
||||
L, R, nodetype = parse_node(db.get(node))
|
||||
|
|
|
@ -21,12 +21,17 @@ for i in range(3):
|
|||
#print(t.to_dict())
|
||||
t.update(k, v)
|
||||
assert t.get(k) == v
|
||||
#t.print_nodes()
|
||||
if not random.randrange(100):
|
||||
t.to_dict()
|
||||
assert r1 is None or t.root == r1
|
||||
r1 = t.root
|
||||
t.update(kvpairs[0][0], kvpairs[0][1])
|
||||
assert t.root == r1
|
||||
print(t.get_branch(kvpairs[0][0]))
|
||||
print(encode_hex(t.root))
|
||||
for k, v in shuffle_in_place(kvpairs):
|
||||
t.update(k, b'')
|
||||
if not random.randrange(100):
|
||||
t.to_dict()
|
||||
assert t.root == b''
|
||||
|
||||
t.to_dict()
|
||||
|
|
Loading…
Reference in New Issue