Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pop DRink!
Forked version of inkdevhub/drink for E2E testing smart contract using Pop API with Pop Network runtimes.
Overview
About the repository folder structure:
Getting Started
Add
pop-drink
crate to your contractCargo.toml
:Setup a testing environment
Please see "Quick start with DRink!" for a detailed explanation.
Add the below code at the top of your contract test file to setup Sandbox for the Pop Network Devnet runtime.
Writing tests
Writing tests
Your typical test module will look like (See "Quick start with DRink!" example tests):
So, firstly, you declare a bundle provider like:
It will take care of building all contract dependencies in the compilation phase and gather all contract bundles into a single registry.
Then, you will be able to get a contract bundle by calling:
We mark each testcase with
#[drink::test]
attribute and declare return type asResult
so that we can use the?
operator:Then, we can use the
Session
API to interact with both contracts and the whole runtime.For details, check out testcases in lib.rs.
Writing tests for methods using Pop API
Pop DRink! also provides utilitiy methods that you can use to test your contracts. This example interacts with a PSP22 example contract that uses Pop API. The contract method returns
PSP22Error
custom error which is provided by Pop API library.Asserts the returned error to an
Error
type usingassert_err!
to test errors of a runtime call.We need to specify the sandbox of Pop Network runtime for a testcase if the contract is using Pop API.
#[drink::test(sandbox = Pop)]
Development Guide
To run the
examples
contracts for DRink!Support
Polkadot Stack Exchange.