Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
154 changes: 154 additions & 0 deletions .github/workflows/typescript-e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
name: Typescript E2E Tests

on:
pull_request:

env:
CARGO_TERM_COLOR: always

permissions:
contents: read

jobs:
typescript-formatting:
runs-on: ubuntu-latest
steps:
- name: Check-out repository
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: ts-tests/.nvmrc

- name: Install system dependencies
run: |
sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get update
sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get install -y --no-install-recommends \
-o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \
build-essential clang curl git make libssl-dev llvm libudev-dev protobuf-compiler pkg-config

- name: Install e2e dependencies
working-directory: ts-tests
run: pnpm install --frozen-lockfile

- name: Formatting check
run: |
cd ts-tests
pnpm run fmt

# Build the node binary in both variants and share as artifacts.
build:
runs-on: [self-hosted, type-ccx33]
needs: [typescript-formatting]
timeout-minutes: 60
strategy:
matrix:
include:
- variant: release
flags: ""
- variant: fast
flags: "--features fast-runtime"
env:
RUST_BACKTRACE: full
steps:
- name: Check-out repository
uses: actions/checkout@v4

- name: Install system dependencies
run: |
sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get update
sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get install -y --no-install-recommends \
-o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \
build-essential clang curl git make libssl-dev llvm libudev-dev protobuf-compiler pkg-config

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable

- name: Utilize Shared Rust Cache
uses: Swatinem/rust-cache@v2
with:
key: e2e-${{ matrix.variant }}
cache-on-failure: true

- name: Build node-subtensor (${{ matrix.variant }})
run: cargo build --profile release ${{ matrix.flags }} -p node-subtensor

- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: node-subtensor-${{ matrix.variant }}
path: target/release/node-subtensor
if-no-files-found: error

run-e2e-tests:
needs: [build]
runs-on: [self-hosted, type-ccx33]
timeout-minutes: 30

strategy:
fail-fast: false
matrix:
include:
- test: dev
binary: release
- test: zombienet_shield
binary: release
- test: zombienet_staking
binary: fast

name: "typescript-e2e-${{ matrix.test }}"

steps:
- name: Check-out repository
uses: actions/checkout@v4

- name: Download release binary
uses: actions/download-artifact@v4
with:
name: node-subtensor-release
path: target/release

- name: Download fast binary
uses: actions/download-artifact@v4
with:
name: node-subtensor-fast
path: target/fast

- name: Make binaries executable
run: chmod +x target/release/node-subtensor target/fast/node-subtensor

# Replace binary to fast if needed
- name: Select binary for test
run: |
if [ "${{ matrix.binary }}" = "fast" ]; then
echo "Using FAST runtime binary"
cp target/fast/node-subtensor target/release/node-subtensor
else
echo "Using RELEASE runtime binary"
fi

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: ts-tests/.nvmrc

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10

- name: Install e2e dependencies
working-directory: ts-tests
run: pnpm install --frozen-lockfile

- name: Run tests
working-directory: ts-tests
run: pnpm moonwall test ${{ matrix.test }}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,10 @@ by appending your own. A few useful ones are as follow.
```
-->

## Testing

Check [testing section](./docs/testing.md).

## License
The MIT License (MIT)
Copyright © 2021 Yuma Rao
Expand Down
39 changes: 39 additions & 0 deletions docs/testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Testing

Typescript tests are run with [Moonwall](https://github.com/Moonsong-Labs/moonwall). To run these you will need to have pnpm installed:

```
# Use the correct Node version
nvm use

# Install moonwall
sudo npm i -g pnpm

# Change directory to test
cd ts-tests

# Install dependencies
pnpm i

# Run manual seal dev tests
pnpm moonwall test dev

# Run zombienet tests
sudo pnpm moonwall test zombienet

# If you have MacOS, you might need to run zombinet test with sudo, because tmp folder
sudo sudo pnpm moonwall test zombienet

# Run smoke tests
sudo pnpm moonwall test smoke_mainnet
```

Moonwall lets you also run the testing environment without performing any tests on it, as a method for you to manually test certain things:

```
# Dev tests in run mode
sudo pnpm moonwall run dev

# Zombinet test with run mode
sudo pnpm moonwall run zombienet
```
7 changes: 5 additions & 2 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ fn run_manual_seal_authorship(
TIMESTAMP.with(|x| {
let mut x_ref = x.borrow_mut();
*x_ref = x_ref.saturating_add(subtensor_runtime_common::time::SLOT_DURATION);
inherent_data.put_data(sp_timestamp::INHERENT_IDENTIFIER, &*x.borrow())
inherent_data.put_data(sp_timestamp::INHERENT_IDENTIFIER, &*x_ref)
})
}

Expand All @@ -765,6 +765,9 @@ fn run_manual_seal_authorship(
let create_inherent_data_providers =
move |_, ()| async move { Ok(MockTimestampInherentDataProvider) };

let aura_data_provider =
sc_consensus_manual_seal::consensus::aura::AuraConsensusDataProvider::new(client.clone());

let manual_seal = match sealing {
Sealing::Manual => future::Either::Left(sc_consensus_manual_seal::run_manual_seal(
sc_consensus_manual_seal::ManualSealParams {
Expand All @@ -774,7 +777,7 @@ fn run_manual_seal_authorship(
pool: transaction_pool,
commands_stream,
select_chain,
consensus_data_provider: None,
consensus_data_provider: Some(Box::new(aura_data_provider)),
create_inherent_data_providers,
},
)),
Expand Down
3 changes: 3 additions & 0 deletions ts-tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tmp
specs
html
1 change: 1 addition & 0 deletions ts-tests/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24
60 changes: 60 additions & 0 deletions ts-tests/biome.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": false,
},
"files": {
"ignoreUnknown": false,
"ignore": [
"**/html/**",
"**/build/**",
"**/target/**",
"**/scripts/tmp/**",
"**/node_modules/**",
"**/.yarn/**",
"test/tsconfig.json",
"tmp",
"**/tmp/",
]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"lineWidth": 120,
"indentWidth": 4,
},
"organizeImports": {
"enabled": true,
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"suspicious": {
"noExplicitAny": "off",
"noShadowRestrictedNames": "off",
},
"correctness": {
"noUnusedImports": "error",
},
},
"ignore": [],
},
"javascript": {
"formatter": {
"quoteStyle": "double",
"semicolons": "always",
"trailingCommas": "es5",
},
},
"json": {
"formatter": {
"enabled": false,
},
"linter": {
"enabled": false,
},
},
}
55 changes: 55 additions & 0 deletions ts-tests/configs/zombie_extended.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"settings": {
"timeout": 1000,
"provider": "native"
},
"relaychain": {
"chain_spec_path": "specs/chain-spec.json",
"default_command": "../target/release/node-subtensor",
"default_args": [
],
"genesis": {
"runtimeGenesis": {
"patch": {
"configuration": {
"config": {

}
}
}
}
},
"nodes": [
{
"name": "one",
"rpc_port": "9947",
"validator": true
},
{
"name": "two",
"rpc_port": "9948",
"validator": true
},
{
"name": "three",
"validator": true
},
{
"name": "four"
},
{
"name": "five"
},
{
"name": "six"
}
]
},
"types": {
"Header": {
"number": "u64",
"parent_hash": "Hash",
"post_state": "Hash"
}
}
}
Loading
Loading