generated from stacks-network/.github
-
Notifications
You must be signed in to change notification settings - Fork 18
Helping Test
Brice Dobry edited this page Oct 7, 2023
·
2 revisions
- This directory is home to the Clarity test files: tests/contracts/
-
tests/tests/lib_tests.rs defines the tests
- There's heavy macro use, so it might look a little weird, but hopefully you can see how they work
- The majority of the tests are just calling a function and checking the response, e.g.
test_contract_call_response!( test_bitwise_and, "bit-and", "assert", |response: ResponseData| { assert!(response.committed); assert_eq!(*response.data, Value::Int(3)); } );
- In the above test, the contract
bit-and.clar
is loaded, compiled, and initialized, then we call theassert
function - The result is expected to be
(ok 3)
, so theassert!(response.committed);
checks forok
and theassert_eq!(*response.data, Value::Int(3));
checks for the3
- In the above test, the contract
- These are simple unit tests, each testing one specific expression and validating that the contract runs as expected
- You can try out these contracts in clarinet to verify that the test contract is written correctly
- If you go to the home page of the wiki, you can see the list of expressions that are implemented and the ones that are remaining
- All of the expressions that are implemented have at least the basic unit test in place
- All of the not-yet-implemented expressions need unit tests
- This will greatly speed up development on those new implementations and would be my #1 request
- All of the implemented tests could use more thorough testing
- It would be great to define a set of contracts written in a way that we could use clarity contract property testing like @moodmosaic has implemented here