This project has been deprecated. We hope it can serve as inspiration for other End-to-End testing projects!
This project contains end-to-end tests for this pipeline:
ink! ➜
cargo-contract ➜
canvas-ui || polkadot-js ➜
substrate-contracts-node
- They build the ink! examples
using
cargo-contract. - The resulting
.contractfile is deployed on a local blockchain instance ofsubstrate-contracts-node. - The deployment is done using either the
canvas-uiorpolkadot-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
masterbranch of all these components is used.
cargo-contractwith its dependenciesbinaryenandrust-src.geckodriver- is required for emulating interactions with a browser. Packages are available in some package managers, binary releases are available in the repository.substrate-contracts-node- The ink! repository
- Firefox
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/#/).
# 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 1By 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 testIf you want to use the polkadot-js UI instead you need to
supply --features polkadot-js-ui to cargo test.
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 totrue. Set it tofalseto prevent closing.WATERFALL_SKIP_CONTRACT_BUILD‒ Do not build the contracts, re-use existing artifacts from theirtargetfolder. Defaults tofalse. Set it totrueto skip building.NODE_PORT‒ Port under which thesubstrate-contracts-nodeis running. Defaults to9944.RUST_LOG‒ UseRUST_LOG=infoto get output on what the tests are doing.
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.