I have two ink! contracts, one being a simple staking contract, and the other being an ERC20. Now, I can write unit tests for ERC20 simply in the contract file itself but to write unit tests for my staking contract I need to make it interact with my erc20 so that general requirements of transfer of the token are met. How can I do that, can I possibly put both contracts in one file and then write their unit tests? or can I import both contracts into another one and then write the test cases? Guide me.
1 Answer
The scenario you are described can not be covered by an unit test. Unit tests are intended for testing one piece (unit, class) of code, e.g. single smart contract. If you want to test interaction between two smart contracts contracts you need to write end to end test.
Check ink! documentation for details.
e2e tests samples you can find here
-
1