-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding unit tests, mutation tests, other tests #29
base: next
Are you sure you want to change the base?
Conversation
tests/unit_test.mligo
Outdated
@@ -0,0 +1,98 @@ | |||
(* This is a unit testing framework for ctez *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the different between test.mligo and unit_test.mligo? Please indicate in file comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just pushed a commit that:
- Adds comments at the head of each file explaining exactly what is tested and how
- Adds the
.py
file that generates the data and expected values - Updates the
test_params
file with the parameters generated by the.py
file
… This necesstiated changing test_params for reproducibility.
Have just found some bugs in |
…nd the special cases induced by the unit tests themselves.
…out the commands in the main function. This is a ligo bug that should hopefully be fixed soon. Tests on the drift functionality will come after some ligo bug fixes.
The tests here should run and pass with the current codebase, with the following caveats:
In case the comments in
|
tests/generate_test_params.py
Outdated
x = random.randint(0,100000000000000) # between 0 and 100_000_000 XTZ | ||
y = random.randint(0,100000000000000) # between 0 and 100_000_000 CTEZ | ||
dx = random.randint(0, min(x,y)) # so as to not exceed the supply | ||
target = random.randint(0, 28147497671065600) # betweeen 0 and 100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100 * 2**48 is more readable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. Changed and pushed.
# Generate the following vector: | ||
# (x, y, dx, target, rounds, const_fee) | ||
for i in range(n): | ||
x = random.randint(0,100000000000000) # between 0 and 100_000_000 XTZ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10**8
Do you mutez though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the parameter x
varies between 0
and 100_000_000_000_000 mutez
, or 100_000_000 tez
(did I understand your question right?)
tests/generate_test_params.py
Outdated
for i in range(len(rand_data)): | ||
if switch: | ||
(x,y,dy,a,rounds,const_fee) = rand_data[i] | ||
b = 281474976710656 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2**48
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. Changed and pushed.
These add unit tests and mutation tests (both in the
unit_tests.mligo
).See comments on the mutation tests for how the output should be interpreted.
A current bug in Ligo is giving problems for
test.mligo
.