inkdevhub / swanky-cli

The all-in-one developer environment for Parity pallet-contracts based smart contracts!
https://docs.astar.network/docs/build/wasm/swanky-suite/cli/
MIT License
70 stars 29 forks source link

Rust e2e tests for ink contracts #127

Closed kziemianek closed 3 months ago

kziemianek commented 1 year ago

Overview

With the release of ink 4.0 developers have possibility to write e2e tests in Rust link. The process looks similar to what is right now in swanky: developer need to run substrate node locally and run e2e tests against it. The idea is to init ink smart contracts with e2e tests written in Rust and change contract test command to run these tests while keeping actual nodejs e2e tests for ask smart contracts. In both scenarios tests could be run against local swanky node.

If the idea sounds reasonable I would be more than happy to make required changes.

shunsukew commented 1 year ago

Sorry for being late to reply. I think it is good idea to support both swanky e2e tests written in TS and ink! native e2e test written in Rust as an alternative option. Having optional flag to execute Rust e2e tests or invoking both TS and Rust at the same time is possible, and the former one is legitimate in my opinion. One thing we need to consider is this only applies to ink! contracts not for Ask! contracts, command should emit some errors in case of ask!. What do you think @codespool

codespool commented 1 year ago

I agree it could be a great option to have. A big plus would also be not having to use polkadot.js, minimising dependencies and getting rid of those warnings.. In fact, I suggest in the init phase, if ink! is selected, only bootstrap ink! e2e, and mocha for ask!. Probably needs a bit more investigation though. ~I'll create an issue in the "ideas" section, we can discuss in the sprint planning.~ added this one to the project instead

shunsukew commented 1 year ago

But being able to write tests in TS is great option for especially frontend engineers. So, we'd like to have it as it is.

codespool commented 1 year ago

I'd argue that if a developer is writing a smart contract using ink! already, they'd be more comfortable writing tests in it too, instead of context/language switching. (and tooling/environment too)

codespool commented 1 year ago

In the end, we can make it optional - add another prompt in the init.

kziemianek commented 1 year ago

I also doubt people will choose mocha tests over ink_e2e, but making it optional as long as swanky still supports mocha tests for ask! contracts and probably existing ink! contracts sounds like a low cost overall.

codespool commented 1 year ago

For e2e support:

niklabh commented 1 year ago

What is the command to run e2e tests?

codespool commented 1 year ago

swanky contract test it's implemented in: https://github.com/AstarNetwork/swanky-cli/blob/master/packages/cli/src/commands/contract/test.ts