Skip to content

Commit

Permalink
test: add chopsticks e2e tests (#481)
Browse files Browse the repository at this point in the history
  • Loading branch information
marshacb authored Dec 12, 2024
1 parent af7f278 commit d735442
Show file tree
Hide file tree
Showing 46 changed files with 3,886 additions and 2,215 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,10 @@ jobs:
run: yarn install

- name: Unit tests.
run: yarn test
run: yarn test:unit

- name: Integration tests.
run: yarn test:integration

- name: E2E tests.
run: yarn test:e2e
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ zombienet/bin/*
# Binaries
/bin/*
!bin/README.md

# Chopsticks
db.sqlite
db.sqlite-*
38 changes: 4 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -397,40 +397,10 @@ api.claimAssets(

Note: claimAssets works when pallet-xcm is configured as the AssetTrap for the given runtime. This is true for all relay chains and system parachains but may not be for other chains.

## License

The source code in this repository is distributed under the Apache 2.0 license. See the [LICENSE](https://github.com/paritytech/asset-transfer-api/blob/main/LICENSE) file. This source code comes with absolutely no warranty. Use at your own risk.

## Zombienet Testing

Zombienet is used to launch a complete network including a relay chain, and two parachains. It will create HRMP channels betweens the launched parachains allowing the testing environment to send XCM messages and transfer assets.

### **Requirements**:

**Zombienet Binary**: You can download the appropriate binary from the zombienet repository [here](https://github.com/paritytech/zombienet/releases). Ensure that it is in the root of this directory. Note: For macos users if permission is denied to run the binary you can `chmod 755 <file_name>` to allow permissions.

**Test Network Binaries**: You will need the following binaries depending on whether you want to run a small or medium network:

- polkadot: You can find the releases [here](https://github.com/paritytech/polkadot-sdk/releases). (Needed for small, or medium network)
- trappist-collator: This binary is compiled along with polkadot above. You can find it [here](https://github.com/paritytech/trappist). (Needed for medium network)
- polkadot-parachain (ie: cumulus): You can find the releases [here](https://github.com/paritytech/polkadot-sdk/releases). (Needed for small, or medium network)

NOTES:

- When it comes to picking a version for both `cumulus` and `polkadot` ensure they are the same. Cumulus will have an extra 0 at the end though. Ex: v0.9.37 (polkadot) -> v0.9.370 (cumulus)

- You can retrieve the binaries via the release, or by compiling yourself. It's recommended to compile it yourself.

Copy each binary that is necessary into the root `<root>/bin` folder.

### Running Zombienet

From the root directory run `./<zombienet_binary_name> -p native spawn ./zombienet/<network_file>.toml | tee zombienet.log`

### Create an asset
## E2E Testing

From the root directory run `yarn start:zombienet-post-script`. You can run this right after running your zombienet network.
You can access the E2E tests and their documentation [here](./e2e-tests/).

## E2E Testing
## License

You can access the E2E tests and its documentation [here](./e2e-tests/).
The source code in this repository is distributed under the Apache 2.0 license. See the [LICENSE](https://github.com/paritytech/asset-transfer-api/blob/main/LICENSE) file. This source code comes with absolutely no warranty. Use at your own risk.
33 changes: 4 additions & 29 deletions e2e-tests/README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,15 @@
## E2E Tests

End-to-end tests that run on a zombienet testnet.
End-to-End tests that run using Chopsticks.

**NOTE: tested using polkadot v1.4.0**

### Setup

To setup the testing environment you need to first download the `polkadot`, `polkadot-execute-worker`, `polkadot-prepare-worker` and `polkadot-parachain` from the `polkadot-sdk` [release page](https://github.com/paritytech/polkadot-sdk/releases/latest), as well as the `trappist-node` from its [release page](https://github.com/paritytech/trappist/releases/latest), and place them in the `../zombienet/bin/` folder.

You also need to have the latest `zombienet` executable in the `../zombienet/` folder, which you can download from [here](https://github.com/paritytech/zombienet/releases/latest).

### Launching zombienet

To launch the zombienet run the following commands:
To run the end-to-end tests run the command:

```bash
$ yarn build && yarn e2e:build
$ yarn build && yarn build:e2e
```

Then run:

```bash
$ yarn e2e:zombienet
$ yarn test:e2e
```

And this will launch the zombienet using the config file located in the `../zombienet/` directory. Once it finished its setup, you can proceed to the following step.

### Launching the tests

For testing, we provide 4 options:

- Testing liquidity tokens transfers with the command `yarn e2e:liquidity-assets`.
- Testing foreign assets transfers with the command `yarn e2e:foreign-assets`.
- Testing local transferss with the command `yarn e2e:local`.
- Testing assets transfers with the command `yarn e2e:assets`.

Each of these commands will run the appropiate script to setup the basics, located in `../scripts/`. Wait for it to finish setting up the testing environment, and then go through the tests indicated in the `./tests/index.ts` file for the chosen option.

After each testing suite has been completed, it's recommended to restart the zombienet before running another test suite.
138 changes: 0 additions & 138 deletions e2e-tests/balance.ts

This file was deleted.

10 changes: 0 additions & 10 deletions e2e-tests/consts.ts

This file was deleted.

Loading

0 comments on commit d735442

Please sign in to comment.