-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pack last timestamp into one uint256 and add tests
- Loading branch information
1 parent
b0079e3
commit 2f3f931
Showing
4 changed files
with
75 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import boa | ||
from boa.test import strategy | ||
from hypothesis import given, settings | ||
|
||
|
||
@given(val=strategy("uint256[3]", max_value=10**18)) | ||
@settings(max_examples=10000, deadline=None) | ||
def test_pack_unpack_three_integers(swap, twocrypto_factory, val): | ||
|
||
for contract in [swap, twocrypto_factory]: | ||
packed = contract.internal._pack_3(val) | ||
unpacked = swap.internal._unpack_3(packed) # swap unpacks | ||
for i in range(3): | ||
assert unpacked[i] == val[i] | ||
|
||
|
||
@given(val=strategy("uint256[2]", max_value=2**128)) | ||
@settings(max_examples=10000, deadline=None) | ||
def test_pack_unpack_2_integers(swap, val): | ||
|
||
if max(val) >= 2**128: | ||
with boa.reverts(): | ||
swap.internal._pack_2(val[0], val[1]) | ||
return | ||
|
||
packed = swap.internal._pack_2(val[0], val[1]) | ||
unpacked = swap.internal._unpack_2(packed) # swap unpacks | ||
for i in range(2): | ||
assert unpacked[i] == val[i] |