hirosystems / clarinet

Write, test and deploy high-quality smart contracts to the Stacks blockchain and Bitcoin.
https://hiro.so/clarinet
GNU General Public License v3.0
307 stars 141 forks source link

To support real integration tests in clarinet cli #212

Closed playerx closed 2 years ago

playerx commented 2 years ago

Do you plan to support integration tests in clarinet cli tool? My goal is to run tests against testnet or devnet (clarinet integrate). As I can see now only pseudo integration tests are supported. Just to have --networkApi parameter and to pass the url of the stacks node api. Please share your vision and plans about it. ✌🏻

playerx commented 2 years ago

Btw, It's really cool that you use Deno for testing. Respect!

lgalabru commented 2 years ago

Hey @playerx, thank you for opening this issue. Could you unpack what you mean by:

As I can see now only pseudo integration tests are supported ?

Thank you!

playerx commented 2 years ago

In pseudo-integrations I mean that it's not a real simulation. To simulate real case scenario we need to start bitcoin node, Stacks node and build blocks after some period of time automatically and next run tests against this environment. You have clarinet integrate to start both nodes but there is no way to run integration tests against that environment.

The way I see is like Truffle or Hardhat, to pass the url of real environment.

I think Stacks team means the same here (that only pseudo-integration tests are supported): https://github.com/hirosystems/clarinet#execute-a-test-suite

playerx commented 2 years ago

So my question is if you plan to support real integration tests, to have the ability to run against real environments? it can be main net or custom test net

lgalabru commented 2 years ago

Running integration tests in environments like Testnet or Mainnet would be pretty tedious, I personally don't think this is an approach we can / will support in Clarinet. Clarinet is focused on unit tests. If testing your contracts on Mainnet / Testnet is a methodology that you'd like to experiment, you could just create a node project, pull stacks.js or micro stacks, submit transactions and assert results. Just prepare yourself for a flaky test suite, you'll be constrained by bitcoin block time (10m average, but could be 1m or 45m), miner inclusion / exclusion and so on.