Hats-Protocol / hats-protocol

Core contracts for Hats Protocol v1.0
https://www.hatsprotocol.xyz
GNU Affero General Public License v3.0
78 stars 25 forks source link

Write contract tests #24

Closed spengrah closed 2 years ago

nintynick commented 2 years ago

I've been working on writing acceptance criteria / descriptive functional tests. Here's how I've been thinking about it:

Four sources of things to test:

From the Hat struct, there are several variables we will have to try different combinations of:

Roughly speaking, combinations of these variables will give us a list of Hats to test. Then we can run the same set of tests over each Hat, potentially with some additions.

My hope is that these will evolve into a test suite that includes unit tests as well as a manual testing flow.

List of Hats:

List of tests:

1. Create

2. Mint

3. View -> Public View Functions

4. Transfer

5. Oracle / Revoke

6. Renounce

7. Deactivate

8. Reactivate

TODO:

ninty questions

Notes

spengrah commented 2 years ago

write example oracle / conditions contracts for Hats F and G @nintynick see #27 for example conditions contracts

nintynick commented 2 years ago

documenting progress tonight, as of https://github.com/Hats-Protocol/hats-protocol/commit/a4c408073f6a0c8815df4e0ccb06a58d84fd9428:

  1. setUp() function abstracted into helper contract TestVariablesAndSetup for all the tests I wrote

  2. 6. Renounce tests done

  3. 5. Oracle / Revoke tests and 7. Deactivate & 8. Reactivate (i.e. Conditions) tests 50% done a. setHatStatus and setHatWearerStatus working great (except: testFailFunctionCallsOnDeactivatedHat(), see comment on line 453-454 (note we are not using HatNotActive() error in Hats.sol)) b. getHatStatus and getHatWearerStatus may have to hook into the sample Oracle and Conditions contracts for testing c. We might want to look at how getHatStatus and getHatWearerStatus fail if the function is not in the respective Oracle / Conditions contract (see lines 390, 494) (I think we talked about this but don't recall the verdict)

remaining:

getting there - so close!

nintynick commented 2 years ago
nintynick commented 2 years ago
nintynick commented 2 years ago

closing this, as we now have full coverage of the list of tests mentioned above, merged into mvp branch in #34. all tests are passing and functions are working on the testnet deployment.

for future testing, there's an opportunity to do more varied and robust TestSetups (see list of hats in comment above), such that we test more edge cases.