2

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 1

2

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
  • 1
    there is also tutorial on how to write ink_e2e tests for cross contract calls. Here
    – Maario
    Commented Aug 1, 2023 at 8:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.