Original Contract Tests
The current testing structure in citycoins/contracts contains a large amount of redundant code, and as the project goes each set of tests is becoming more complex.
While unit testing can be powerful, it might be worth taking a look at other approaches, especially given this new repo is using a vanilla Clarinet setup instead of the custom one used before.
Some related issues and backstory:
Current Protocol Tests
Starting with the contracts for CCIP-012 Phase 2, the current protocol testing structure is similar to the original one with some basic improvements.
- dspec library is removed and tests are run in default Clarinet formatting
- utils folder contains general items used by all tests
- a single reference for dependencies (easier to update across all tests)
- contains references to common contract names, organized by category
e.g. EXTENSIONS.CCD001_DIRECT_EXECUTE
- contracts are organized by categories related to the DAO structure
- extensions: once enabled, can be used until disabled
- proposals: changes that are executed one time
- traits: trait definitions for DAO operations
- models exist for each type of extension or contract, and are extended for naming (or other customization) within the same file
- also organized by extensions, proposals, traits
- includes the error codes for the contract for easy access/readability
e.g. BaseDao.ErrCode.ERR_INVALID_EXTENSION
- includes the public and read only contract functions used by tests
e.g. baseDao.construct(sender, PROPOSALS.CCIP_012)
- unit tests are run against each contract, verifying the error and success paths of each function
- also organized by extensions, proposals, traits
Ideal Scenario
Given the CityCoins protocol functions are going to be managed by single contracts instead of one per city, this could be a chance to not only simplify but revise the testing structure to take advantage of more advanced techniques such as model-based testing or fuzzing.
Goals
- abstract, simplify, and reduce redundant code
- expand amount of properties tested for
- find better ways to handle complex scenarios
Original Contract Tests
The current testing structure in citycoins/contracts contains a large amount of redundant code, and as the project goes each set of tests is becoming more complex.
While unit testing can be powerful, it might be worth taking a look at other approaches, especially given this new repo is using a vanilla Clarinet setup instead of the custom one used before.
Some related issues and backstory:
Current Protocol Tests
Starting with the contracts for CCIP-012 Phase 2, the current protocol testing structure is similar to the original one with some basic improvements.
e.g.
EXTENSIONS.CCD001_DIRECT_EXECUTEe.g.
BaseDao.ErrCode.ERR_INVALID_EXTENSIONe.g.
baseDao.construct(sender, PROPOSALS.CCIP_012)Ideal Scenario
Given the CityCoins protocol functions are going to be managed by single contracts instead of one per city, this could be a chance to not only simplify but revise the testing structure to take advantage of more advanced techniques such as model-based testing or fuzzing.
Goals