Skip to content
This repository has been archived by the owner on Dec 8, 2023. It is now read-only.
/ ink-waterfall Public archive

End-to-end tests for ink! ➜ cargo-contract ➜ canvas-ui || polkadot-js ➜ substrate-contracts-node.

License

Notifications You must be signed in to change notification settings

paritytech/ink-waterfall

Repository files navigation

Readme

This project has been deprecated. We hope it can serve as inspiration for other End-to-End testing projects!

ci-result ci-duration

This project contains end-to-end tests for this pipeline:

ink! ➜
   cargo-contract ➜
             canvas-ui || polkadot-js ➜
                                substrate-contracts-node

How the tests in this repository work

  • They build the ink! examples using cargo-contract.
  • The resulting .contract file is deployed on a local blockchain instance of substrate-contracts-node.
  • The deployment is done using either the canvas-ui or polkadot-js.
  • This is done by emulating browser interactions in Firefox (clicking, uploading, …).
  • After successful deployment more browser interactions with the contract are conducted, in order to assert that the contract behaves as expected.
  • The master branch of all these components is used.

Required dependencies

For the UI either the canvas-ui or the polkadot-js UI is an optional requirement. By default the published versions of those projects are used (https://paritytech.github.io/canvas-ui, https://polkadot.js.org/apps/#/).

Run it locally

# Create a link to ink! in the local examples of the `ink-waterfall`.
ln -s /path/to/ink/ ./examples/ink

export INK_EXAMPLES_PATH=/path/to/ink/integration-tests/
substrate-contracts-node > /tmp/substrate-contracts-node.log 2>&1 &

# By default you will see the Firefox GUI and the
# tests interacting with it.
cargo test 

# …you can also start the tests headless though, then
# you won't see anything.
cargo test --features headless

# Handy for debugging:

# You can prevent the test suite from closing the browser
# window. Then you can still interact with the browser after
# the test failed/succeeded. 
export WATERFALL_CLOSE_BROWSER=false

# Setting the number of parallel jobs to `1` makes it easier
# to follow the tests interacting with the browser.
cargo test --jobs 1

By default, the canvas-ui published at https://paritytech.github.io/canvas-ui (i.e. the gh-pages branch) will be used. But you can also use a local instance:

git clone --depth 1 https://github.com/paritytech/canvas-ui.git
cd canvas-ui/
yarn install
yarn start > /tmp/canvas-ui.log 2>&1 &
cd ..

# Check that the UI is ready and a `200 OK` is returned.
curl -I http://localhost:3000/

export UI_URL="http://localhost:3000"
cargo test

If you want to use the polkadot-js UI instead you need to supply --features polkadot-js-ui to cargo test.

Environment variables

  • INK_EXAMPLES_PATH ‒ Path to the ink! examples folder. Must be set.
  • UI_URL ‒ URL of the UI to use. Defaults to the live interface for the chosen UI.
  • WATERFALL_CLOSE_BROWSER ‒ Close browser window at the end of a test run. Defaults to true. Set it to false to prevent closing.
  • WATERFALL_SKIP_CONTRACT_BUILD ‒ Do not build the contracts, re-use existing artifacts from their target folder. Defaults to false. Set it to true to skip building.
  • NODE_PORT ‒ Port under which the substrate-contracts-node is running. Defaults to 9944.
  • RUST_LOG ‒ Use RUST_LOG=info to get output on what the tests are doing.

Known issue

The tooltips which show the result of a contract upload or contract transaction (ExtrinsicSuccess, …) disappear after some time. When too many UI tests are run at the same time the tooltips might disappear before the test is finished processing them.

The test will then fail with a NoSucheElement error, indicating that the DOM element is no longer available. The easiest fix for this is to limit the number of concurrent test threads via e.g. cargo test --jobs 4.

About

End-to-end tests for ink! ➜ cargo-contract ➜ canvas-ui || polkadot-js ➜ substrate-contracts-node.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published