Skip to content

Commit 400cc1d

Browse files
committed
test: use strat where v=def
1 parent fc179a8 commit 400cc1d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

tests/test_smt.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from hypothesis import (
2+
23
given,
34
strategies as st,
45
)
@@ -11,13 +12,21 @@
1112
)
1213

1314

15+
@st.composite
16+
def binary_tuples(draw):
17+
size = draw(st.integers(min_value=1, max_value=32))
18+
v = draw(st.binary(min_size=size, max_size=size))
19+
default = draw(st.binary(min_size=size, max_size=size))
20+
return (v, default)
21+
22+
1423
@given(
1524
k=st.binary(min_size=1, max_size=32),
16-
v=st.binary(min_size=1, max_size=32),
17-
default=st.binary(min_size=1, max_size=32),
25+
values=binary_tuples(),
1826
)
19-
def test_simple_kv(k, v, default):
27+
def test_simple_kv(k, values):
2028
# default must be different than v
29+
v, default = values
2130
default = BLANK_NODE if default == v else default
2231
smt = SparseMerkleTree(key_size=len(k), default=default)
2332
empty_root = smt.root_hash

0 commit comments

Comments
 (0)