-
Notifications
You must be signed in to change notification settings - Fork 47
fix: ci integration tests chopsticks #839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
114 commits
Select commit
Hold shift + click to select a range
74b2fa5
first mvp
Ad96el 12eae01
revert
Ad96el 6dc7a5c
v3
Ad96el 3e22e27
withdraw assets
Ad96el dc5428b
check validation
Ad96el bba0541
fix validateBalanceWithPrecision
Ad96el 85e936f
fix withdraw assets
Ad96el 3f1fbfe
update snapshots
Ad96el b3b1c83
passing tests
Ad96el 1e0d171
passing tests
Ad96el 91cc0e1
update readme
Ad96el e2df711
update comments
Ad96el 5caf948
update comments
Ad96el 447c412
Merge branch 'develop' into ag_chopsticks_design
Ad96el 7c34af7
update CI
Ad96el 58227db
Merge branch 'ag_chopsticks_design' of github.com:KILTprotocol/kilt-n…
Ad96el 2dcafff
update CI
Ad96el 69ab715
ci-skip-rust
Ad96el 117b290
ci-skip-rust
Ad96el 9fcf36e
start refactor
Ad96el c5ec5d4
first draft for full
Ad96el 469617a
commit basic changes
Ad96el cc75667
Pr comments
Ad96el e0cf9ec
Merge branch 'develop' into ag_chopsticks_design_switch
Ad96el b66f6e5
Merge branch 'develop' into ag_chopsticks_design
Ad96el 8443203
revert ci
Ad96el dc0eebf
Merge branch 'ag_chopsticks_design' into ag_chopsticks_design_switch
Ad96el e5eb568
recert chopsticks
Ad96el fdbcd26
test running
Ad96el b378738
lock file
Ad96el 1bc2936
update events
Ad96el fd9463f
fixed events + invariant
Ad96el 1285e5d
draft
Ad96el c031618
tx executing
Ad96el 9b63285
fix dev wasm
Ad96el f3a9238
add test to switch eKilts
Ad96el ea8f0a5
switch kilts vs eKilts
Ad96el 30b23f6
fmt
Ad96el 1f8f7ed
send relay token paused switch
Ad96el 47d14c9
switch kilts
Ad96el 1e469ff
no switch tests
Ad96el 9a608e7
no handling on receiver
Ad96el ca13358
other reserve location
Ad96el cf8e9e4
withdraw paused
Ad96el c1455f8
rename folders
Ad96el 773f0fd
dust user
Ad96el bbb42b8
reclaim assets
Ad96el 25cd688
refactor all test cases
Ad96el 0277a87
random db
Ad96el 7d80602
spelling error
Ad96el f0d5176
change configs
Ad96el 5124cc3
intermediate
Ad96el 9aa75c7
intermediate
Ad96el 73c7471
intermediate
Ad96el 06bd588
add invariant checks
Ad96el eb9986a
update events
Ad96el 57253e6
ci-skip-rust
Ad96el 073fbf9
ci-skip-rust lint
Ad96el 12080e1
ci-skip-rust lint
Ad96el 2a255a6
ci-skip-rust path
Ad96el 34d9b55
no default exports
Ad96el 9fec62a
alter types
Ad96el e5008ea
import type
Ad96el 380099b
ci-skip-rust change timeout
Ad96el cf07fd0
ci-skip-rust change events
Ad96el 9aaacd8
ci-skip-rust type for setup configs
Ad96el 335e7e2
ci-skip-rust type update events
Ad96el ca5ee1e
ci-skip-rust increase timeout
Ad96el f31672b
ci-skip-rust remove wasm
Ad96el dc4fa42
update envs
Ad96el 51945d2
rename hydration
Ad96el 35f6f28
ci-skip-rust add docs
Ad96el 12b8e54
ci-skip-rust revert script file
Ad96el 25b723f
Merge branch 'develop' into ag_chopsticks_design
Ad96el 39a9ba7
Merge branch 'ag_chopsticks_design' into ag_chopsticks_design_switch
Ad96el b939960
Merge branch 'develop' into ag_chopsticks_design
Ad96el 43e6467
Merge branch 'ag_chopsticks_design' into ag_chopsticks_design_switch
Ad96el 1338c96
ci-skip-rust revert did
Ad96el c49bc1f
ci-skip-rust rupdate events
Ad96el 5306394
ci-skip-rust update ci
Ad96el e4b4339
ci-skip-rust update ci
Ad96el 6b24332
ci-skip-rust update ci
Ad96el 83369ab
rename interface
Ad96el 62abac6
update full flow
Ad96el f145049
add utils test file
Ad96el 8d1aa8c
change spinUp
Ad96el 0eb45b2
ci-skip-rust update interface
Ad96el bd6916e
ci-skip-rust add comments
Ad96el 1b237a5
ci-skip-rust update ci
Ad96el 0b98fa7
chore: chopsticks utils (#857)
Ad96el f05f814
Merge branch 'develop' into ag_chopsticks_design_switch
Ad96el f3bb203
Merge branch 'develop' into ag_chopsticks_design_switch
Ad96el 1b3dfbe
bigint
Ad96el 914c8b4
replace filter with find
Ad96el 76071c6
getPaidXcmFees
Ad96el 0460f85
getReceivedNativeTokens
Ad96el d6aa9b8
rename timeout
Ad96el 7e0a639
connect vertically in parallel
Ad96el 712827f
no async describes
Ad96el 5c0108a
check if event
Ad96el 9b285ca
isPaused
Ad96el d9fd351
switchPair error
Ad96el 83b19cb
afterEach closures
Ad96el f8c09dc
fix token queries
Ad96el 93a9e23
falsy at
Ad96el 6e71bf1
await
Ad96el dd4e24d
-balance
Ad96el fa32868
event
Ad96el 423616b
less anys
Ad96el 4eedb91
ci-skip-rust fix
Ad96el 10c59f3
fix event filter
Ad96el 753148d
ci-skip-rust change type
Ad96el ec881b6
ci-skip-rust expect to be true
Ad96el ddc0049
Merge branch 'develop' into ag_chopsticks_design_switch
Ad96el File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,38 @@ | ||
| HYDRADX_WS= | ||
| HYDRADX_PORT= | ||
| POLKADOT_WS= | ||
| POLKADOT_PORT= | ||
| # These env variables are mandatory for the tests to work. | ||
|
|
||
| # The Spiritnet block number to be used in the tests | ||
| SPIRITNET_BLOCK_NUMBER= | ||
| # The Hydration block number to be used in the tests | ||
| HYDRATION_BLOCK_NUMBER= | ||
| # The Polkadot block number to be used in the tests | ||
| POLKADOT_BLOCK_NUMBER= | ||
| # Directory path to the new WASM blob | ||
| SPIRITNET_WASM_OVERRIDE= | ||
| # The AssetHub block number to be used in the tests | ||
| ASSETHUB_BLOCK_NUMBER= | ||
|
|
||
|
|
||
| # Optional env variables | ||
| HYDRATION_TEST_WS= | ||
| HYDRATION_TEST_PORT= | ||
|
|
||
| HYDRATION_WS= | ||
| HYDRATION_PORT= | ||
|
|
||
| ASSETHUB_WSS= | ||
| ASSETHUB_MAIN_PORT= | ||
|
|
||
| ASSETHUB_TEST_WSS= | ||
| ASSETHUB_TEST_PORT= | ||
|
|
||
| SPIRITNET_WS= | ||
| SPIRITNET_PORT= | ||
|
|
||
| PEREGRINE_WS= | ||
| PEREGRINE_PORT= | ||
|
|
||
| POLKADOT_WS= | ||
| POLKADOT_PORT= | ||
|
|
||
| PASEO_WS= | ||
| PASEO_PORT= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| # e2e Chopsticks tests | ||
|
|
||
| This project is a set of end-to-end tests for the KILT protocol against other parachains. | ||
| Other functionalities such as a creation of DID can be easily added. | ||
|
|
||
| ## Getting Started | ||
|
|
||
| These instructions will allow you to run the tests on your local machine for development and testing purposes. | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| - Node.js v20.11.0 (as specified in the [`.nvmrc`](https://github.com/nvm-sh/nvm)). With `nvm use` the right node version will be installed. | ||
| - npm (comes with Node.js) | ||
|
|
||
| ### Installing | ||
|
|
||
| To install the node modules call: | ||
|
|
||
| ```sh | ||
| yarn | ||
| ``` | ||
|
|
||
| ### Running the tests | ||
|
|
||
| In the package.json a script is provided. | ||
|
|
||
| By calling the command below, the test will be executed: | ||
|
|
||
| ```sh | ||
| yarn test | ||
| ``` | ||
|
|
||
| Please make sure an appropriate env is set. | ||
|
|
||
| ### Env | ||
|
|
||
| The project uses environment variables for configuration. | ||
| You can find an example in the `.env-example` file. Copy this file to | ||
| .env and fill in the appropriate values. | ||
| Explanation for the values are in the `.env-example` file provided. | ||
|
|
||
| ## Code Style | ||
|
|
||
| This project uses Prettier and ESLint for code formatting and linting. | ||
| The configuration for these tools can be found in the `.prettierrc` and `.eslintrc.json` files respectively. | ||
|
|
||
| To check your code for style issues, run: | ||
|
|
||
| ```sh | ||
| yarn lint | ||
| ``` | ||
|
|
||
| To automatically fix style issues, run: | ||
|
|
||
| ```sh | ||
| yarn lint:fix | ||
| ``` | ||
|
|
||
| ## Adding a new test case | ||
|
|
||
| To add a new test case, you need to insert a new object into the list of test cases. | ||
| For example, if you want to add a new instance of `LimitedReserveTestConfiguration`, you would insert it into the `testPairsLimitedReserveTransfers` list. | ||
|
|
||
| The tests are configuration-driven, meaning they can be easily customized for different scenarios. | ||
| The test framework doesn't make assumptions about which parachain is sending which coin to which destination over which relay chain. | ||
| Fundamental events such as the moving of coins or the creation of a new account should be emitted during the test. | ||
|
|
||
| The test cases live in the tests folder and use mocks from the network directory. | ||
| The network directory contains helper functions to set the blockchain state and provides an abstraction over the chopsticks functionalities, such as creating a network. | ||
|
|
||
| For Adding a new test case scenario, a template folder is provided. | ||
|
|
||
| ## Debugging Existence Tests | ||
|
|
||
| Each test case should have a unique ID. To execute a specific test case, run: | ||
|
|
||
| ```sh | ||
| yarn test -t "REGULAR_EXPRESSION" | ||
| ``` | ||
|
|
||
| ## UI | ||
|
|
||
| Vitest supports a UI to manage the test cases. To spin up the UI, call: | ||
|
|
||
| ```sh | ||
| yarn ui | ||
| ``` | ||
|
|
||
| ## CLI | ||
|
|
||
| The project provides a CLI to interact with the test framework. | ||
| To execute the cli run: | ||
|
|
||
| ```sh | ||
| yarn cli [COMMAND] | ||
| ``` | ||
|
|
||
| Below are the available commands and their descriptions: | ||
|
|
||
| `spinUp` | ||
|
|
||
| Spins up the network using the definition in `./src/command/network.ts`. | ||
| The network configuration can be adjusted as needed. | ||
| A detailed step-by-step explanation of how to modify the network to a specific state is provided in the `network.ts` file. | ||
|
|
||
| ```sh | ||
| yarn cli spinUp | ||
| ``` | ||
|
|
||
| `scheduleTx` | ||
|
|
||
| Executes a transaction on the network, creating a new Chopsticks instance. | ||
|
|
||
| ```sh | ||
| yarn cli scheduleTx endpoint rawTx [options] | ||
| ``` | ||
|
|
||
| - endpoint: The endpoint of the network. | ||
| - rawTx: The raw transaction to execute. | ||
| - --origin: The origin of the transaction (default: Root). | ||
| - --port: The RPC port (default: 8888). | ||
|
|
||
| `stateTransition` | ||
|
|
||
| Shows the state transition of the network based on the latest block. | ||
| The command creates a preview folder containing an HTML file, which can be opened in a browser to inspect the state transition. | ||
|
|
||
| ```sh | ||
| yarn cli stateTransition endpoint [option] | ||
| ``` | ||
|
|
||
| - endpoint: The endpoint of the network. | ||
| - --block: The block to do the state transition | ||
|
|
||
|
|
||
| ## Recommended VS Code Extensions | ||
|
|
||
| - [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint): Integrates ESLint into VS Code, a tool for identifying and reporting on patterns in JavaScript. | ||
| - [Prettier - Code formatter](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode): An opinionated code formatter that supports many languages. | ||
| - [TypeScript Hero](https://marketplace.visualstudio.com/items?itemName=rbbit.typescript-hero): Provides additional features for TypeScript development, such as import management and code navigation. | ||
| - [Live Server](https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer): Renders HTML files, useful for state transition HTML. | ||
| - [GitLens](https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens): Supercharges the built-in Git capabilities of VS Code. | ||
|
|
||
| ## Built With | ||
|
|
||
| [TypeScript](https://www.typescriptlang.org/) | ||
| [Chopsticks](https://github.com/AcalaNetwork/chopsticks) | ||
| [Polkadot API](https://github.com/polkadot-js/api) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import { Command } from 'commander' | ||
|
|
||
| import { createTestNetwork, scheduleTxCommand, stateTransition } from './command/index.js' | ||
|
|
||
| const program = new Command() | ||
|
|
||
| program.name('chopsticks utils').description('CLI to mange some chopsticks instances').version('0.0.1') | ||
|
|
||
| program | ||
| .command('spinUp') | ||
| .description('Spin up the network') | ||
| .action(async () => { | ||
| await createTestNetwork() | ||
| }) | ||
|
|
||
| program | ||
| .command('scheduleTx') | ||
| .description('Executes a transaction on the network') | ||
| .argument('<endpoint>', 'The endpoint of the network') | ||
| .argument('<rawTx>', 'The raw transaction to execute') | ||
| .option( | ||
| '--origin, <origin>', | ||
| 'The origin of the transaction Either "Root" or "Signed""', | ||
| (value) => { | ||
| if (value !== 'Root' && value !== 'Signed') { | ||
| throw new Error('Invalid origin. Must be either "Root" or "Signed"') | ||
| } | ||
| return value | ||
| }, | ||
| 'Root' | ||
| ) | ||
| .option('--port <port>', 'The RPC port', '8888') | ||
| .action(async (endpoint, rawTx, options) => { | ||
| const { origin, port } = options | ||
|
|
||
| await scheduleTxCommand(endpoint, rawTx, origin, +port) | ||
| }) | ||
|
|
||
| program | ||
| .command('stateTransition') | ||
| .description('Shows the state transition of the network by the latest block') | ||
| .argument('<endpoint>', 'The endpoint of the network') | ||
| .option('--block', 'The block number to do the state transition', 'undefined') | ||
| .action(async (endpoint, options) => { | ||
| const { block } = options | ||
| const blockNumber = block === 'undefined' ? undefined : +block | ||
| await stateTransition(endpoint, blockNumber) | ||
| }) | ||
|
|
||
| program.parse() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { createTestNetwork } from './network.js' | ||
| import { scheduleTxCommand } from './scheduleTx.js' | ||
| import { stateTransition } from './stateTransition.js' | ||
|
|
||
| export { createTestNetwork, scheduleTxCommand, stateTransition } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { mainChains } from '../network/index.js' | ||
| import { setStorage, setupNetwork } from '../network/utils.js' | ||
|
|
||
| export async function createTestNetwork() { | ||
| const relayConfig = mainChains.polkadot.getConfig({}) | ||
|
|
||
| // 1. Create the network specific state | ||
| const kiltStorage = mainChains.kilt.storage.assignNativeTokensToAccounts([ | ||
| '4pF5Y2Eo6doQHPLQj5AkndZwtomVB8ab2sRftRS2D9JDdELr', | ||
| ]) | ||
|
|
||
| // 2. Create the network specific config | ||
| const kiltConfig = mainChains.kilt.getConfig({}) | ||
|
|
||
| // 2. Add the different parachainContexts here. The order of parachainContexts and parachainStorage should match. | ||
| const parachainOptions = [kiltConfig] | ||
| const parachainStorage = [kiltStorage] | ||
|
|
||
| const { relayChainContext, parachainContexts } = await setupNetwork(relayConfig, parachainOptions) | ||
|
|
||
| await Promise.all(parachainStorage.map((storage, index) => setStorage(parachainContexts[index], storage))) | ||
|
|
||
| await Promise.all([...parachainContexts, relayChainContext].map((context) => context.pause())) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.