Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Example Parachain Integration tests #87

Merged
merged 6 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions integration-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[`parachains-integration-tests`](https://github.com/paritytech/parachains-integration-tests) is a tool designed to test interactions between Substrate based blockchains.

Is used here to develop tests rapidly describing them in a YAML file.

# Setup

Install `parachains-integration-tests` into your system:
```
$ yarn global add ts-node

$ yarn global add @parity/parachains-integration-tests
```

Review the [Run a local network](https://github.com/paritytech/extended-parachain-template#%EF%B8%8F-run-a-local-network) to set up Zombienet in your system.

Create a `bin` directory into the root of this repository and place the following binaries inside of it:
- `polkadot` (which you can download from [the releases](https://github.com/paritytech/polkadot/releases))
AlexD10S marked this conversation as resolved.
Show resolved Hide resolved
- `polkadot-parachain` (which you will build from [cumulus](https://github.com/paritytech/cumulus))

Use the following command in the root of this repository to build the node:

```sh
cargo build --release
```

# Usage

Please refer to the [project's `README.md`](https://github.com/paritytech/parachains-integration-tests#how-to-use) for an extensive description of how to write YAML test files and how to execute tests.

In `integration-tests/force_hrmp_open_channels.yml` you can find a test to open a HRMP channel between this parachain and an asset-hub local network.

Run zombienet and wait until both parachains are propertly onboarded (producing blocks):
```
$ zombienet-macos spawn zombienet-config/integration-tests-config.toml -p native
```

Run the tests:
```
$ parachains-integration-tests -m test -t integration-tests/force_hrmp_open_channels.yml
```
122 changes: 122 additions & 0 deletions integration-tests/force_hrmp_open_channels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
---
settings:
chains:
relay_chain: &relay_chain
wsPort: 9900
assets_parachain:
wsPort: 9910
paraId: &ap_id 1000
local_parachain:
wsPort: 9920
paraId: &lp_id 2000
variables:
common:
amount: &amount 2000000000000
hrmp_channels:
proposed_max_capacity: &max_capacity 8
proposed_max_message_size: &max_message_size 8192
channel: &channel {
Copy link
Contributor

@weezy20 weezy20 Oct 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we are using this (&channel) variable binding anywhere. Okay to omit it?

maxCapacity: *max_capacity,
maxTotalSize: *max_message_size,
maxMessageSize: *max_message_size,
msgCount: 0,
totalSize: 0,
mqcHead: null,
senderDeposit: 0,
recipientDeposit: 0
}
chains:
relay_chain:
signer: &rc_signer //Alice
assets_parachain_account:
sovereign_account: &ap_sovereign F7fq1jSNVTPfJmaHaXCMtatT1EZefCUsa7rRiQVNR5efcah
local_parachain:
sovereign_account: &lp_sovereign F7fq1jMZkfuCuoMTyiEVAP2DMpMt18WopgBqTJznLihLNbZ

tests:
- name: HRMP
beforeEach:
- name: DEPENDENCY | Local Parachain Sovereign account in the Relay Chain needs to be funded
actions:
- extrinsics:
- chain: *relay_chain
signer: *rc_signer
pallet: balances
call: transferAllowDeath
args: [
*lp_sovereign, # destination
*amount, # value
]
events:
- name: balances.Transfer

- name: DEPENDENCY | Assets Parachain Sovereign account in the Relay Chain needs to be funded
actions:
- extrinsics:
- chain: *relay_chain
signer: *rc_signer
pallet: balances
call: transferAllowDeath
args: [
*ap_sovereign, # destination
*amount, # value
]
events:
- name: balances.Transfer
describes:
- name: hrmp.forceOpenHrmpChannel (Local Parachain → Assets Parachain)
its:
- name: Open Local Parachain to Assets Parachain
actions:
- extrinsics:
- chain: *relay_chain
signer: *rc_signer
sudo: true
pallet: hrmp
call: forceOpenHrmpChannel
args: [
*lp_id,
*ap_id,
*max_capacity,
*max_message_size
]
events:
- name: sudo.Sudid
result: { sudoResult: Ok }
- name: hrmp.HrmpChannelForceOpened

- name: hrmp.forceOpenHrmpChannel (Assets Parachain → Local Parachain)
its:
- name: Open Assets Parachain to Local Parachain
actions:
- extrinsics:
- chain: *relay_chain
signer: *rc_signer
sudo: true
pallet: hrmp
call: forceOpenHrmpChannel
args: [
*ap_id,
*lp_id,
*max_capacity,
*max_message_size
]
events:
- name: sudo.Sudid
result: { sudoResult: Ok }
- name: hrmp.HrmpChannelForceOpened

- name: hrmp.forceProcessHrmpOpen (make sure all the channels are open)
its:
- name: Make sure all the pending channels are open
actions:
- extrinsics:
- chain: *relay_chain
signer: *rc_signer
sudo: true
pallet: hrmp
call: forceProcessHrmpOpen
args: [ 2 ]
events:
- name: sudo.Sudid
result: { sudoResult: Ok }
79 changes: 79 additions & 0 deletions zombienet-config/integration-tests-config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
[settings]
timeout = 1000

[relaychain]
chain = "rococo-local"
default_command = "./bin/polkadot"

[[relaychain.nodes]]
name = "alice"
validator = true
ws_port = 9900
extra_args = [ "-lparachain=debug" ]

[[relaychain.nodes]]
name = "bob"
validator = true
extra_args = [ "-lparachain=debug" ]

[[relaychain.nodes]]
name = "charlie"
validator = true
extra_args = [ "-lparachain=debug" ]

[[relaychain.nodes]]
name = "dave"
validator = true
extra_args = [ "-lparachain=debug" ]

[[parachains]]
id = 1000
add_to_genesis = true
cumulus_based = true
chain = "statemine-local"
stiiifff marked this conversation as resolved.
Show resolved Hide resolved

[[parachains.collators]]
name = "statemine-collator01"
stiiifff marked this conversation as resolved.
Show resolved Hide resolved
command = "./bin/polkadot-parachain"
ws_port = 9910
args = ["--log=xcm=trace,pallet-assets=trace"]

[[parachains.collators]]
name = "statemine-collator02"
command = "./bin/polkadot-parachain"
ws_port = 9911
args = ["--log=xcm=trace,pallet-assets=trace"]

[[parachains]]
id = 2000
addToGenesis = true
cumulus_based = true

[[parachains.collators]]
name = "parachain-collator01"
command = "./target/release/parachain-template-node"
ws_port = 9920
args = ["--log=xcm=trace,pallet-assets=trace"]

[[parachains.collators]]
name = "parachain-collator02"
command = "./target/release/parachain-template-node"
ws_port = 9921
args = ["--log=xcm=trace,pallet-assets=trace"]

[types.Header]
number = "u64"
parent_hash = "Hash"
post_state = "Hash"

# [[hrmp_channels]]
# sender = 1000
# recipient = 2000
# max_capacity = 8
# max_message_size = 512

# [[hrmp_channels]]
# sender = 2000
# recipient = 1000
# max_capacity = 8
# max_message_size = 512