From 77fc84b750023372c42ab76bb2f6ff23f0ad67b6 Mon Sep 17 00:00:00 2001 From: ndk Date: Thu, 24 Oct 2024 21:00:10 +0300 Subject: [PATCH 01/11] an initial version of chopsticks tests documentation --- .../integration-tests/chopsticks/README.md | 10 +++++++ .../chopsticks/configs/README.md | 6 +++++ .../configs/westend-asset-hub-override.yaml | 19 +++++++++++++ .../chopsticks/configs/westend-override.yaml | 27 +++++++++++++++++++ .../chopsticks/tests/README.md | 13 +++++++++ .../chopsticks/wasm/README.md | 9 +++++++ 6 files changed, 84 insertions(+) create mode 100644 cumulus/parachains/integration-tests/chopsticks/README.md create mode 100644 cumulus/parachains/integration-tests/chopsticks/configs/README.md create mode 100644 cumulus/parachains/integration-tests/chopsticks/configs/westend-asset-hub-override.yaml create mode 100644 cumulus/parachains/integration-tests/chopsticks/configs/westend-override.yaml create mode 100644 cumulus/parachains/integration-tests/chopsticks/tests/README.md create mode 100644 cumulus/parachains/integration-tests/chopsticks/wasm/README.md diff --git a/cumulus/parachains/integration-tests/chopsticks/README.md b/cumulus/parachains/integration-tests/chopsticks/README.md new file mode 100644 index 0000000000000..977b7cf1e2abe --- /dev/null +++ b/cumulus/parachains/integration-tests/chopsticks/README.md @@ -0,0 +1,10 @@ +Chopsticks tests introduce a way of sending real-world API requests to Substrate-based networks, which are built and run on your local computer. +Imagine you're adding a new API and want to make sure that it works as intended before deploying it to any of the testnets, chopsticks is the way to go. +TODO: improve introduction before proceeding to the set of commands. + +1. Before executing any of the commands below, please, read README at the `wasms` folder. +2. Once you have your WASM BLOBs in place, you can run a node using the following command: +- `npx @acala-network/chopsticks@latest xcm -r configs/westend-override.yaml -p configs/westend-asset-hub-override.yaml` +This particular command should span up two RPC servers (you can specify as many parachains as needed by chaining `-p configs/another-parachain-config.yaml`) and +output the ports they reserved for themselves. +3. Once relay (and parachains) are up and running you can proceed to sending RPCs with the help of bun. diff --git a/cumulus/parachains/integration-tests/chopsticks/configs/README.md b/cumulus/parachains/integration-tests/chopsticks/configs/README.md new file mode 100644 index 0000000000000..5b74d9afca86e --- /dev/null +++ b/cumulus/parachains/integration-tests/chopsticks/configs/README.md @@ -0,0 +1,6 @@ +This folder serves as a crucial reference for chopstick tests and the Parity-owned ecosystems, +providing a working set of configuration files specifically for the Westend ecosystem. +For additional resources and original Acala configurations, including documentation, refer to the [Acala repository](https://github.com/AcalaNetwork/chopsticks/tree/master/configs) + +Config files, especially `wasm-override:` fields there, assume that there is a `wasm` folder within the same parent directory, and it contains pre-built WASM BLOBs of the +ecosystem under tests. diff --git a/cumulus/parachains/integration-tests/chopsticks/configs/westend-asset-hub-override.yaml b/cumulus/parachains/integration-tests/chopsticks/configs/westend-asset-hub-override.yaml new file mode 100644 index 0000000000000..666e1ee0aa90d --- /dev/null +++ b/cumulus/parachains/integration-tests/chopsticks/configs/westend-asset-hub-override.yaml @@ -0,0 +1,19 @@ +endpoint: + - wss://westend-rpc.dwellir.com +mock-signature-host: true +block: ${env.WESTEND_BLOCK_NUMBER} +db: ./db.sqlite +runtime-log-level: 5 +wasm-override: ../wasm/westend_runtime.compact.compressed.wasm + +import-storage: + System: + Account: + - + - + - 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY + - providers: 1 + data: + free: '10000000000000000000' + ParasDisputes: + $removePrefix: ['disputes'] \ No newline at end of file diff --git a/cumulus/parachains/integration-tests/chopsticks/configs/westend-override.yaml b/cumulus/parachains/integration-tests/chopsticks/configs/westend-override.yaml new file mode 100644 index 0000000000000..7959e877cd8c8 --- /dev/null +++ b/cumulus/parachains/integration-tests/chopsticks/configs/westend-override.yaml @@ -0,0 +1,27 @@ + +endpoint: wss://asset-hub-polkadot-rpc.dwellir.com +mock-signature-host: true +block: ${env.WESTEND_ASSET_HUB_BLOCK_NUMBER} +db: ./db.sqlite +runtime-log-level: 5 +wasm-override: ../wasm/asset_hub_westend_runtime.compact.compressed.wasm + +import-storage: + System: + Account: + - + - + - 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY + - providers: 1 + data: + free: 1000000000000000 + - + - + - 5Eg2fntQqFi3EvFWAf71G66Ecjjah26bmFzoANAeHFgj9Lia + - providers: 1 + data: + free: 1000000000000000 + Assets: + Account: + - [[1984, 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY], { balance: 1000000000 }] + - [[1984, 5Eg2fntQqFi3EvFWAf71G66Ecjjah26bmFzoANAeHFgj9Lia], { balance: 1000000000 }] diff --git a/cumulus/parachains/integration-tests/chopsticks/tests/README.md b/cumulus/parachains/integration-tests/chopsticks/tests/README.md new file mode 100644 index 0000000000000..6067f892fd496 --- /dev/null +++ b/cumulus/parachains/integration-tests/chopsticks/tests/README.md @@ -0,0 +1,13 @@ +1. Please, create a separate folder for your decentralized APP or chopstick tests. +2. TODO: add the documentation how to install bun +- curl -fsSL https://bun.sh/install | bash +- export BUN_INSTALL="$HOME/.bun" +- export PATH="$BUN_INSTALL/bin:$PATH" +2. Once you have your folder you can run `bun init` and it will create a default set-up for running a bun node. +3. Now you need to add polkadot-api or papi: `bun add polkadot-api` +4. Add your ecosystem (`westend` or `wnd` in this case): +- `bun papi add wnd -w ws://localhost:8001` +- you can find the port as the output of running `npx` command in the folder above +- TODO: understand what exactly `npx` command does and then refactor this guide +5. Once it's done you can implement your tests. Feel free to use other's tests as code reference. +6. To run the tests execute `bun test ./index.ts` \ No newline at end of file diff --git a/cumulus/parachains/integration-tests/chopsticks/wasm/README.md b/cumulus/parachains/integration-tests/chopsticks/wasm/README.md new file mode 100644 index 0000000000000..4e99ae90d698f --- /dev/null +++ b/cumulus/parachains/integration-tests/chopsticks/wasm/README.md @@ -0,0 +1,9 @@ +This folder contains WASM BLOBs which are supposed to be used by chopstick tests. +To populate this folder with the required files you need to: +1. BUILD relevant runtimes: usually relay and parachain(s). +- `cargo build --release -p westend-runtime ` +- `cargo build --release -p asset-hub-westend-runtime ` +2. Copy compressed wasms from target folder into the current one: +- `WBUILD_PATH=../../../../../target/release/wbuild` +- `cp $WBUILD_PATH/asset-hub-westend-runtime/asset_hub_westend_runtime.compact.compressed.wasm .` +- `cp $WBUILD_PATH/westend-runtime/westend_runtime.compact.compressed.wasm .` From 6a82a86d025da2a02822082f62772dd5301582fc Mon Sep 17 00:00:00 2001 From: ndk Date: Mon, 28 Oct 2024 15:16:08 +0300 Subject: [PATCH 02/11] fixed yaml configs and improved README documentation --- .../integration-tests/chopsticks/README.md | 15 ++++++++----- .../chopsticks/configs/README.md | 8 +++---- .../configs/westend-asset-hub-override.yaml | 22 +++++++++++++------ .../chopsticks/configs/westend-override.yaml | 22 ++++++------------- .../chopsticks/tests/README.md | 13 +++++------ .../chopsticks/{wasm => wasms}/README.md | 2 +- 6 files changed, 42 insertions(+), 40 deletions(-) rename cumulus/parachains/integration-tests/chopsticks/{wasm => wasms}/README.md (89%) diff --git a/cumulus/parachains/integration-tests/chopsticks/README.md b/cumulus/parachains/integration-tests/chopsticks/README.md index 977b7cf1e2abe..0b95aae96c8a4 100644 --- a/cumulus/parachains/integration-tests/chopsticks/README.md +++ b/cumulus/parachains/integration-tests/chopsticks/README.md @@ -1,10 +1,13 @@ -Chopsticks tests introduce a way of sending real-world API requests to Substrate-based networks, which are built and run on your local computer. -Imagine you're adding a new API and want to make sure that it works as intended before deploying it to any of the testnets, chopsticks is the way to go. -TODO: improve introduction before proceeding to the set of commands. +Chopsticks tests introduce a way of sending real-world API requests to Substrate-based networks, which are built and run locally, on your computer. +For now, we use it to test new APIs locally, before deploying it to any of the testnets. You can find comprehensive documentation under [this link](https://papermoonio.github.io/polkadot-ecosystem-docs-draft/dev-tools/chopsticks/overview/) -1. Before executing any of the commands below, please, read README at the `wasms` folder. -2. Once you have your WASM BLOBs in place, you can run a node using the following command: +To get started with chopsticks: +1. Make sure you have [Node.js](https://nodejs.org/en/) installed +2. (mb optional) To be able to run chopsticks command from you terminal install the required node module: +`npm i -g @acala-network/chopsticks@0.13.1` +2. Go through the instructions inside the `wasms` folder. +3. Once you have your WASM BLOBs in place, you can run a node using the following command: - `npx @acala-network/chopsticks@latest xcm -r configs/westend-override.yaml -p configs/westend-asset-hub-override.yaml` This particular command should span up two RPC servers (you can specify as many parachains as needed by chaining `-p configs/another-parachain-config.yaml`) and output the ports they reserved for themselves. -3. Once relay (and parachains) are up and running you can proceed to sending RPCs with the help of bun. +3. Once relay (and parachains) are up and running you can proceed to sending RPCs with the help of bun (see `tests` folder). diff --git a/cumulus/parachains/integration-tests/chopsticks/configs/README.md b/cumulus/parachains/integration-tests/chopsticks/configs/README.md index 5b74d9afca86e..aeb89ba283e7d 100644 --- a/cumulus/parachains/integration-tests/chopsticks/configs/README.md +++ b/cumulus/parachains/integration-tests/chopsticks/configs/README.md @@ -1,6 +1,6 @@ -This folder serves as a crucial reference for chopstick tests and the Parity-owned ecosystems, -providing a working set of configuration files specifically for the Westend ecosystem. -For additional resources and original Acala configurations, including documentation, refer to the [Acala repository](https://github.com/AcalaNetwork/chopsticks/tree/master/configs) +This folder serves as a reference documentation for chopstick tests and the Parity-owned ecosystems, +providing a working set of configuration files together with the WASM BLOBs, specifically for the Westend ecosystem. +For additional resources and original Acala configurations, including documentation, refer to the [Acala repository](https://github.com/AcalaNetwork/chopsticks/tree/master/configs) or [Papermoon chopsticks overview](https://papermoonio.github.io/polkadot-ecosystem-docs-draft/dev-tools/chopsticks/overview/#using-a-configuration-file) Config files, especially `wasm-override:` fields there, assume that there is a `wasm` folder within the same parent directory, and it contains pre-built WASM BLOBs of the -ecosystem under tests. +ecosystem under tests. diff --git a/cumulus/parachains/integration-tests/chopsticks/configs/westend-asset-hub-override.yaml b/cumulus/parachains/integration-tests/chopsticks/configs/westend-asset-hub-override.yaml index 666e1ee0aa90d..6e53629fdfb5e 100644 --- a/cumulus/parachains/integration-tests/chopsticks/configs/westend-asset-hub-override.yaml +++ b/cumulus/parachains/integration-tests/chopsticks/configs/westend-asset-hub-override.yaml @@ -1,10 +1,10 @@ -endpoint: - - wss://westend-rpc.dwellir.com + +endpoint: wss://asset-hub-polkadot-rpc.dwellir.com mock-signature-host: true -block: ${env.WESTEND_BLOCK_NUMBER} +block: ${env.WESTEND_ASSET_HUB_BLOCK_NUMBER} db: ./db.sqlite runtime-log-level: 5 -wasm-override: ../wasm/westend_runtime.compact.compressed.wasm +wasm-override: wasms/asset_hub_westend_runtime.compact.compressed.wasm import-storage: System: @@ -14,6 +14,14 @@ import-storage: - 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY - providers: 1 data: - free: '10000000000000000000' - ParasDisputes: - $removePrefix: ['disputes'] \ No newline at end of file + free: 1000000000000000 + - + - + - 5Eg2fntQqFi3EvFWAf71G66Ecjjah26bmFzoANAeHFgj9Lia + - providers: 1 + data: + free: 1000000000000000 + Assets: + Account: + - [[1984, 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY], { balance: 1000000000 }] + - [[1984, 5Eg2fntQqFi3EvFWAf71G66Ecjjah26bmFzoANAeHFgj9Lia], { balance: 1000000000 }] diff --git a/cumulus/parachains/integration-tests/chopsticks/configs/westend-override.yaml b/cumulus/parachains/integration-tests/chopsticks/configs/westend-override.yaml index 7959e877cd8c8..bf0bb57db8341 100644 --- a/cumulus/parachains/integration-tests/chopsticks/configs/westend-override.yaml +++ b/cumulus/parachains/integration-tests/chopsticks/configs/westend-override.yaml @@ -1,10 +1,10 @@ - -endpoint: wss://asset-hub-polkadot-rpc.dwellir.com +endpoint: + - wss://westend-rpc.dwellir.com mock-signature-host: true -block: ${env.WESTEND_ASSET_HUB_BLOCK_NUMBER} +block: ${env.WESTEND_BLOCK_NUMBER} db: ./db.sqlite runtime-log-level: 5 -wasm-override: ../wasm/asset_hub_westend_runtime.compact.compressed.wasm +wasm-override: wasms/westend_runtime.compact.compressed.wasm import-storage: System: @@ -14,14 +14,6 @@ import-storage: - 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY - providers: 1 data: - free: 1000000000000000 - - - - - - 5Eg2fntQqFi3EvFWAf71G66Ecjjah26bmFzoANAeHFgj9Lia - - providers: 1 - data: - free: 1000000000000000 - Assets: - Account: - - [[1984, 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY], { balance: 1000000000 }] - - [[1984, 5Eg2fntQqFi3EvFWAf71G66Ecjjah26bmFzoANAeHFgj9Lia], { balance: 1000000000 }] + free: '10000000000000000000' + ParasDisputes: + $removePrefix: ['disputes'] diff --git a/cumulus/parachains/integration-tests/chopsticks/tests/README.md b/cumulus/parachains/integration-tests/chopsticks/tests/README.md index 6067f892fd496..189acd3d11979 100644 --- a/cumulus/parachains/integration-tests/chopsticks/tests/README.md +++ b/cumulus/parachains/integration-tests/chopsticks/tests/README.md @@ -1,13 +1,12 @@ 1. Please, create a separate folder for your decentralized APP or chopstick tests. -2. TODO: add the documentation how to install bun +2. Use the following commands to install `bun`: - curl -fsSL https://bun.sh/install | bash - export BUN_INSTALL="$HOME/.bun" - export PATH="$BUN_INSTALL/bin:$PATH" -2. Once you have your folder you can run `bun init` and it will create a default set-up for running a bun node. -3. Now you need to add polkadot-api or papi: `bun add polkadot-api` -4. Add your ecosystem (`westend` or `wnd` in this case): +3. Once you have your folder you can run `bun init` inside of it, and it will create a default set-up for you. Click enter twice to choose the default options. +4. Now you need to add polkadot-api or papi: `bun add polkadot-api` +5. Add your ecosystem (`westend` or `wnd` in this case): - `bun papi add wnd -w ws://localhost:8001` - you can find the port as the output of running `npx` command in the folder above -- TODO: understand what exactly `npx` command does and then refactor this guide -5. Once it's done you can implement your tests. Feel free to use other's tests as code reference. -6. To run the tests execute `bun test ./index.ts` \ No newline at end of file +6. Once it's done you can implement your tests. Feel free to use other's tests as code reference. +7. To run the tests execute `bun test ./index.ts` \ No newline at end of file diff --git a/cumulus/parachains/integration-tests/chopsticks/wasm/README.md b/cumulus/parachains/integration-tests/chopsticks/wasms/README.md similarity index 89% rename from cumulus/parachains/integration-tests/chopsticks/wasm/README.md rename to cumulus/parachains/integration-tests/chopsticks/wasms/README.md index 4e99ae90d698f..80d7f273ef60f 100644 --- a/cumulus/parachains/integration-tests/chopsticks/wasm/README.md +++ b/cumulus/parachains/integration-tests/chopsticks/wasms/README.md @@ -1,6 +1,6 @@ This folder contains WASM BLOBs which are supposed to be used by chopstick tests. To populate this folder with the required files you need to: -1. BUILD relevant runtimes: usually relay and parachain(s). +1. BUILD relevant runtimes: usually relay and parachain(s). - `cargo build --release -p westend-runtime ` - `cargo build --release -p asset-hub-westend-runtime ` 2. Copy compressed wasms from target folder into the current one: From 32b64ebb8eb4695990c523f3b33cf8f953a05c55 Mon Sep 17 00:00:00 2001 From: ndk Date: Mon, 28 Oct 2024 15:37:02 +0300 Subject: [PATCH 03/11] fixed commands in README --- .../parachains/integration-tests/chopsticks/tests/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cumulus/parachains/integration-tests/chopsticks/tests/README.md b/cumulus/parachains/integration-tests/chopsticks/tests/README.md index 189acd3d11979..a249f7a87eefc 100644 --- a/cumulus/parachains/integration-tests/chopsticks/tests/README.md +++ b/cumulus/parachains/integration-tests/chopsticks/tests/README.md @@ -1,8 +1,8 @@ 1. Please, create a separate folder for your decentralized APP or chopstick tests. 2. Use the following commands to install `bun`: -- curl -fsSL https://bun.sh/install | bash -- export BUN_INSTALL="$HOME/.bun" -- export PATH="$BUN_INSTALL/bin:$PATH" +- `curl -fsSL https://bun.sh/install | bash` +- `export BUN_INSTALL="$HOME/.bun"` +- `export PATH="$BUN_INSTALL/bin:$PATH"` 3. Once you have your folder you can run `bun init` inside of it, and it will create a default set-up for you. Click enter twice to choose the default options. 4. Now you need to add polkadot-api or papi: `bun add polkadot-api` 5. Add your ecosystem (`westend` or `wnd` in this case): From f861995a66756f838daefb8379da1680391947da Mon Sep 17 00:00:00 2001 From: ndk Date: Mon, 28 Oct 2024 16:03:45 +0300 Subject: [PATCH 04/11] made command more straight-forward to see --- .../parachains/integration-tests/chopsticks/tests/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cumulus/parachains/integration-tests/chopsticks/tests/README.md b/cumulus/parachains/integration-tests/chopsticks/tests/README.md index a249f7a87eefc..3825f39fafc08 100644 --- a/cumulus/parachains/integration-tests/chopsticks/tests/README.md +++ b/cumulus/parachains/integration-tests/chopsticks/tests/README.md @@ -4,7 +4,8 @@ - `export BUN_INSTALL="$HOME/.bun"` - `export PATH="$BUN_INSTALL/bin:$PATH"` 3. Once you have your folder you can run `bun init` inside of it, and it will create a default set-up for you. Click enter twice to choose the default options. -4. Now you need to add polkadot-api or papi: `bun add polkadot-api` +4. Now you need to add polkadot-api or papi: +- `bun add polkadot-api` 5. Add your ecosystem (`westend` or `wnd` in this case): - `bun papi add wnd -w ws://localhost:8001` - you can find the port as the output of running `npx` command in the folder above From 8ae7f80eb2c4e7cf046cb6162e84b35ee91eb7d8 Mon Sep 17 00:00:00 2001 From: ndk Date: Mon, 28 Oct 2024 17:18:38 +0300 Subject: [PATCH 05/11] added reference typescript file --- .../chopsticks/tests/trusted_query/index.ts | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 cumulus/parachains/integration-tests/chopsticks/tests/trusted_query/index.ts diff --git a/cumulus/parachains/integration-tests/chopsticks/tests/trusted_query/index.ts b/cumulus/parachains/integration-tests/chopsticks/tests/trusted_query/index.ts new file mode 100644 index 0000000000000..427bd0adaa605 --- /dev/null +++ b/cumulus/parachains/integration-tests/chopsticks/tests/trusted_query/index.ts @@ -0,0 +1,63 @@ +import { test, expect } from "bun:test"; +import { wnd, XcmV3Junctions, XcmV3Junction, XcmV3MultiassetFungibility } from "@polkadot-api/descriptors"; +import { Enum, createClient } from "polkadot-api"; +import { getWsProvider } from "polkadot-api/ws-provider/web"; +import { withPolkadotSdkCompat } from "polkadot-api/polkadot-sdk-compat"; + +// Initialize client and dotApi globally +let client = createClient( + withPolkadotSdkCompat( + getWsProvider("ws://localhost:8001") + ) +); +let dotApi = client.getTypedApi(wnd); + +// Define test cases using a table-driven approach +const testCases = [ + { + description: 'Test with parachain ID 1000, fungibility 1, want true', + asset: Enum('V4', { + id: { + parents: 0, + interior: XcmV3Junctions.Here(), + }, + fun: XcmV3MultiassetFungibility.Fungible(1n), + }), + location: Enum('V4', { + parents: 0, + interior: XcmV3Junctions.X1(XcmV3Junction.Parachain(1000)) + }), + want: true + }, + { + description: 'Test with parachain ID 2000, fungibility 2, want false', + asset: Enum('V4', { + id: { + parents: 0, + interior: XcmV3Junctions.Here(), + }, + fun: XcmV3MultiassetFungibility.Fungible(2n), + }), + location: Enum('V4', { + parents: 0, + interior: XcmV3Junctions.X1(XcmV3Junction.Parachain(2000)) + }), + want: false + }, + // Add more test cases as necessary +]; + +// Iterate over the test cases +testCases.forEach(({ description, asset, location, want }) => { + test(description, async () => { + const resp = await dotApi.apis.TrustedQueryApi.is_trusted_teleporter(asset, location); + + // Assert success + expect(resp.success).toBe(true); + + // Assert value + expect(resp.value).toBe(want); + + console.log(`Test: ${description}, want: ${want}, got: ${resp.value}`); + }); +}); From da47cf96e1923e9d16d54812a081c8cde8a99580 Mon Sep 17 00:00:00 2001 From: ndk Date: Mon, 28 Oct 2024 17:21:28 +0300 Subject: [PATCH 06/11] removed optional step --- cumulus/parachains/integration-tests/chopsticks/README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cumulus/parachains/integration-tests/chopsticks/README.md b/cumulus/parachains/integration-tests/chopsticks/README.md index 0b95aae96c8a4..e397af0a948b1 100644 --- a/cumulus/parachains/integration-tests/chopsticks/README.md +++ b/cumulus/parachains/integration-tests/chopsticks/README.md @@ -3,11 +3,9 @@ For now, we use it to test new APIs locally, before deploying it to any of the t To get started with chopsticks: 1. Make sure you have [Node.js](https://nodejs.org/en/) installed -2. (mb optional) To be able to run chopsticks command from you terminal install the required node module: -`npm i -g @acala-network/chopsticks@0.13.1` 2. Go through the instructions inside the `wasms` folder. 3. Once you have your WASM BLOBs in place, you can run a node using the following command: - `npx @acala-network/chopsticks@latest xcm -r configs/westend-override.yaml -p configs/westend-asset-hub-override.yaml` This particular command should span up two RPC servers (you can specify as many parachains as needed by chaining `-p configs/another-parachain-config.yaml`) and output the ports they reserved for themselves. -3. Once relay (and parachains) are up and running you can proceed to sending RPCs with the help of bun (see `tests` folder). +4. Once relay (and parachains) are up and running you can proceed to sending RPCs with the help of bun (see `tests` folder). From 82c6a9a23812279f1018a9c09ad47ced874837bb Mon Sep 17 00:00:00 2001 From: ndk Date: Mon, 28 Oct 2024 17:22:27 +0300 Subject: [PATCH 07/11] improved doc --- cumulus/parachains/integration-tests/chopsticks/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cumulus/parachains/integration-tests/chopsticks/README.md b/cumulus/parachains/integration-tests/chopsticks/README.md index e397af0a948b1..8fb9022bfbf18 100644 --- a/cumulus/parachains/integration-tests/chopsticks/README.md +++ b/cumulus/parachains/integration-tests/chopsticks/README.md @@ -8,4 +8,4 @@ To get started with chopsticks: - `npx @acala-network/chopsticks@latest xcm -r configs/westend-override.yaml -p configs/westend-asset-hub-override.yaml` This particular command should span up two RPC servers (you can specify as many parachains as needed by chaining `-p configs/another-parachain-config.yaml`) and output the ports they reserved for themselves. -4. Once relay (and parachains) are up and running you can proceed to sending RPCs with the help of bun (see `tests` folder). +4. Once relay (and parachains) are up and running you can proceed with sending RPCs with the help of bun (see `tests` folder). From 07c27811d1e34611e94d1ce3e14da8e55196ac08 Mon Sep 17 00:00:00 2001 From: ndk Date: Mon, 28 Oct 2024 17:23:54 +0300 Subject: [PATCH 08/11] improved tests --- .../chopsticks/tests/trusted_query/index.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/cumulus/parachains/integration-tests/chopsticks/tests/trusted_query/index.ts b/cumulus/parachains/integration-tests/chopsticks/tests/trusted_query/index.ts index 427bd0adaa605..2d145afe2c2f0 100644 --- a/cumulus/parachains/integration-tests/chopsticks/tests/trusted_query/index.ts +++ b/cumulus/parachains/integration-tests/chopsticks/tests/trusted_query/index.ts @@ -4,7 +4,6 @@ import { Enum, createClient } from "polkadot-api"; import { getWsProvider } from "polkadot-api/ws-provider/web"; import { withPolkadotSdkCompat } from "polkadot-api/polkadot-sdk-compat"; -// Initialize client and dotApi globally let client = createClient( withPolkadotSdkCompat( getWsProvider("ws://localhost:8001") @@ -12,10 +11,9 @@ let client = createClient( ); let dotApi = client.getTypedApi(wnd); -// Define test cases using a table-driven approach const testCases = [ { - description: 'Test with parachain ID 1000, fungibility 1, want true', + description: 'Test with trusted location', asset: Enum('V4', { id: { parents: 0, @@ -30,7 +28,7 @@ const testCases = [ want: true }, { - description: 'Test with parachain ID 2000, fungibility 2, want false', + description: 'Test with untrusted location', asset: Enum('V4', { id: { parents: 0, @@ -44,18 +42,13 @@ const testCases = [ }), want: false }, - // Add more test cases as necessary ]; -// Iterate over the test cases testCases.forEach(({ description, asset, location, want }) => { test(description, async () => { const resp = await dotApi.apis.TrustedQueryApi.is_trusted_teleporter(asset, location); - // Assert success expect(resp.success).toBe(true); - - // Assert value expect(resp.value).toBe(want); console.log(`Test: ${description}, want: ${want}, got: ${resp.value}`); From 4aafbbc3c910211e9164c5e1a3bb350c4cae7345 Mon Sep 17 00:00:00 2001 From: ndk Date: Mon, 28 Oct 2024 17:42:23 +0300 Subject: [PATCH 09/11] removed an extra newline --- .../chopsticks/configs/westend-asset-hub-override.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/cumulus/parachains/integration-tests/chopsticks/configs/westend-asset-hub-override.yaml b/cumulus/parachains/integration-tests/chopsticks/configs/westend-asset-hub-override.yaml index 6e53629fdfb5e..928982442b4d4 100644 --- a/cumulus/parachains/integration-tests/chopsticks/configs/westend-asset-hub-override.yaml +++ b/cumulus/parachains/integration-tests/chopsticks/configs/westend-asset-hub-override.yaml @@ -1,4 +1,3 @@ - endpoint: wss://asset-hub-polkadot-rpc.dwellir.com mock-signature-host: true block: ${env.WESTEND_ASSET_HUB_BLOCK_NUMBER} From 6821358068aa7b4181d64b68c1019054339f33da Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 29 Oct 2024 13:19:07 +0300 Subject: [PATCH 10/11] Replaced Node related commands with Bun commands to make set-up easier --- .../integration-tests/chopsticks/README.md | 12 +++++++++--- .../chopsticks/configs/README.md | 8 ++++---- .../integration-tests/chopsticks/tests/README.md | 9 +++------ .../chopsticks/tests/trusted_query/README.md | 15 +++++++++++++++ 4 files changed, 31 insertions(+), 13 deletions(-) create mode 100644 cumulus/parachains/integration-tests/chopsticks/tests/trusted_query/README.md diff --git a/cumulus/parachains/integration-tests/chopsticks/README.md b/cumulus/parachains/integration-tests/chopsticks/README.md index 8fb9022bfbf18..26d580b7129e9 100644 --- a/cumulus/parachains/integration-tests/chopsticks/README.md +++ b/cumulus/parachains/integration-tests/chopsticks/README.md @@ -1,11 +1,17 @@ Chopsticks tests introduce a way of sending real-world API requests to Substrate-based networks, which are built and run locally, on your computer. -For now, we use it to test new APIs locally, before deploying it to any of the testnets. You can find comprehensive documentation under [this link](https://papermoonio.github.io/polkadot-ecosystem-docs-draft/dev-tools/chopsticks/overview/) +For now, we use it to test new APIs locally, before deploying it to any of the testnets. You can find comprehensive documentation under [this link](https://papermoonio.github.io/polkadot-ecosystem-docs-draft/dev-tools/chopsticks/overview/) + +***NOTE***: this guide uses [Bun](https://bun.sh/) instead of [Node](nodejs.org). +If you are willing to use Node, please, refer to [Papermoon docs](https://papermoonio.github.io/polkadot-ecosystem-docs-draft/dev-tools/chopsticks/overview/). To get started with chopsticks: -1. Make sure you have [Node.js](https://nodejs.org/en/) installed +1. Make sure you have [Bun](https://bun.sh/docs/installation) installed, or you can use the following commands: +- `curl -fsSL https://bun.sh/install | bash` +- `export BUN_INSTALL="$HOME/.bun"` +- `export PATH="$BUN_INSTALL/bin:$PATH"` 2. Go through the instructions inside the `wasms` folder. 3. Once you have your WASM BLOBs in place, you can run a node using the following command: -- `npx @acala-network/chopsticks@latest xcm -r configs/westend-override.yaml -p configs/westend-asset-hub-override.yaml` +- `bunx @acala-network/chopsticks@latest xcm -r configs/westend-override.yaml -p configs/westend-asset-hub-override.yaml` This particular command should span up two RPC servers (you can specify as many parachains as needed by chaining `-p configs/another-parachain-config.yaml`) and output the ports they reserved for themselves. 4. Once relay (and parachains) are up and running you can proceed with sending RPCs with the help of bun (see `tests` folder). diff --git a/cumulus/parachains/integration-tests/chopsticks/configs/README.md b/cumulus/parachains/integration-tests/chopsticks/configs/README.md index aeb89ba283e7d..12baa4ee25591 100644 --- a/cumulus/parachains/integration-tests/chopsticks/configs/README.md +++ b/cumulus/parachains/integration-tests/chopsticks/configs/README.md @@ -1,6 +1,6 @@ -This folder serves as a reference documentation for chopstick tests and the Parity-owned ecosystems, -providing a working set of configuration files together with the WASM BLOBs, specifically for the Westend ecosystem. -For additional resources and original Acala configurations, including documentation, refer to the [Acala repository](https://github.com/AcalaNetwork/chopsticks/tree/master/configs) or [Papermoon chopsticks overview](https://papermoonio.github.io/polkadot-ecosystem-docs-draft/dev-tools/chopsticks/overview/#using-a-configuration-file) +This folder serves as a reference documentation for chopstick tests and the Parity-owned ecosystems. +It provides a working set of configuration files together with the WASM BLOBs, specifically for the Westend ecosystem. +For additional resources and original Acala configuration files, including documentation, refer to the [Acala repository](https://github.com/AcalaNetwork/chopsticks/tree/master/configs) or [Papermoon chopsticks overview](https://papermoonio.github.io/polkadot-ecosystem-docs-draft/dev-tools/chopsticks/overview/#using-a-configuration-file) -Config files, especially `wasm-override:` fields there, assume that there is a `wasm` folder within the same parent directory, and it contains pre-built WASM BLOBs of the +Config files, especially `wasm-override:` fields there, assume that there is a `wasms` folder within the same parent directory, and it contains pre-built WASM BLOBs of the ecosystem under tests. diff --git a/cumulus/parachains/integration-tests/chopsticks/tests/README.md b/cumulus/parachains/integration-tests/chopsticks/tests/README.md index 3825f39fafc08..ecf4b154e9a04 100644 --- a/cumulus/parachains/integration-tests/chopsticks/tests/README.md +++ b/cumulus/parachains/integration-tests/chopsticks/tests/README.md @@ -1,13 +1,10 @@ 1. Please, create a separate folder for your decentralized APP or chopstick tests. -2. Use the following commands to install `bun`: -- `curl -fsSL https://bun.sh/install | bash` -- `export BUN_INSTALL="$HOME/.bun"` -- `export PATH="$BUN_INSTALL/bin:$PATH"` -3. Once you have your folder you can run `bun init` inside of it, and it will create a default set-up for you. Click enter twice to choose the default options. +2. Make sure you have [Bun](https://bun.sh/docs/installation) installed: +3. Once you have your folder you can run `bun init` inside of it, and it will create a default set-up for you. Hit enter twice to choose the default options. 4. Now you need to add polkadot-api or papi: - `bun add polkadot-api` 5. Add your ecosystem (`westend` or `wnd` in this case): - `bun papi add wnd -w ws://localhost:8001` -- you can find the port as the output of running `npx` command in the folder above +- you can find the port as the output of running `bunx` command in the folder above 6. Once it's done you can implement your tests. Feel free to use other's tests as code reference. 7. To run the tests execute `bun test ./index.ts` \ No newline at end of file diff --git a/cumulus/parachains/integration-tests/chopsticks/tests/trusted_query/README.md b/cumulus/parachains/integration-tests/chopsticks/tests/trusted_query/README.md new file mode 100644 index 0000000000000..a4881a2ae2d7b --- /dev/null +++ b/cumulus/parachains/integration-tests/chopsticks/tests/trusted_query/README.md @@ -0,0 +1,15 @@ +# trusted_query + +To install dependencies: + +```bash +bun install +``` + +To run: + +```bash +bun run index.ts +``` + +This project was created using `bun init` in bun v1.1.33. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime. From 2a94a0e00f46ba032b0ecfd38e09d9c5bc7c4488 Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 29 Oct 2024 13:20:22 +0300 Subject: [PATCH 11/11] removed auto-generated README --- .../chopsticks/tests/trusted_query/README.md | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 cumulus/parachains/integration-tests/chopsticks/tests/trusted_query/README.md diff --git a/cumulus/parachains/integration-tests/chopsticks/tests/trusted_query/README.md b/cumulus/parachains/integration-tests/chopsticks/tests/trusted_query/README.md deleted file mode 100644 index a4881a2ae2d7b..0000000000000 --- a/cumulus/parachains/integration-tests/chopsticks/tests/trusted_query/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# trusted_query - -To install dependencies: - -```bash -bun install -``` - -To run: - -```bash -bun run index.ts -``` - -This project was created using `bun init` in bun v1.1.33. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.