ink
ink copied to clipboard
Separate tests from implementation in example contracts
Currently when viewing the source code of our example contracts they might look overwhelming at first for people that are not experienced with Rust with many hundreds of lines of code.
However, with many of the examples most of that overwhelmingly looking code is actually just test code.
Therefore in my opinion we should put all of that into another module tests.rs
so that the lib.rs
where the actual contract code sits is kept as clean and shallow as possible.
An example of how bad this gets is our ERC-20 example contract where the first 190 lines of code represent the actual smart contract followed by a monstrosity of over 600 lines of very rough looking test code.
ERC-20: https://github.com/paritytech/ink/blob/764a44a98a36e8466f386d96d46ed633e33f72bd/examples/erc20/lib.rs
@Robbepop is this still something currently actionable? Seems straightforward enough.
The only issue is if I first run the .scripts
I get the following error:
./scripts/check-examples.sh: line 47: examples/delegator/: division by 0 (error token is "/") ./scripts/check-examples.sh: line 57: pushd: examples/delegator/: No such file or directory error: Found argument 'generate-metadata' which wasn't expected, or isn't valid in this context