Skip to content

Commit c4f7d4b

Browse files
authored
chore: e2e tests setup via ink node & contracts node (#271)
* add e2e tests setup * fix path * move tests
1 parent af3edea commit c4f7d4b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+3693
-1
lines changed

.github/workflows/create-typink-template-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ name: Create-Typink Template Tests
22

33
on:
44
push:
5+
branches: [ main ]
56
workflow_dispatch:
67
merge_group:
8+
pull_request:
79

810
env:
911
TYPINK_TEMPLATE_BRANCH: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }}

.github/workflows/demo-build-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ name: Demo Build Tests
55

66
on:
77
push:
8+
branches: [ main ]
89
workflow_dispatch:
910
merge_group:
11+
pull_request:
1012

1113
jobs:
1214
unit-tests:

.github/workflows/e2e-tests.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: E2E Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
workflow_dispatch:
7+
merge_group:
8+
pull_request:
9+
10+
jobs:
11+
e2e-tests:
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
node-version: [18.x]
17+
18+
steps:
19+
- uses: actions/checkout@v3
20+
- name: Use Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v3
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
cache: 'yarn'
25+
- run: yarn install --immutable
26+
- run: yarn build
27+
- name: Download executables
28+
run: |
29+
curl -L -O https://github.com/paritytech/substrate-contracts-node/releases/download/v0.42.0/substrate-contracts-node-linux.tar.gz
30+
tar -xzf substrate-contracts-node-linux.tar.gz
31+
mv ./substrate-contracts-node-linux/substrate-contracts-node ./substrate-contracts-node
32+
chmod +x substrate-contracts-node
33+
34+
curl -L -O https://github.com/use-ink/ink-node/releases/download/v0.45.1/ink-node-linux.tar.gz
35+
tar -xzf ink-node-linux.tar.gz
36+
mv ./ink-node-linux/ink-node ./ink-node
37+
chmod +x ink-node
38+
39+
- name: Spawn networks
40+
run: |
41+
export PATH=$(pwd):$PATH
42+
export RUST_BACKTRACE=full
43+
./ink-node --rpc-port=9955 --state-pruning=archive --blocks-pruning=archive &
44+
./substrate-contracts-node --dev &
45+
46+
chmod +x ./e2e/nodes/wait-for-port.sh
47+
./e2e/nodes/wait-for-port.sh 9944 30 &
48+
./e2e/nodes/wait-for-port.sh 9955 30
49+
50+
- name: Run tests
51+
run: yarn workspace e2e-nodes e2e:test

.github/workflows/run-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ name: Run Unit Tests
55

66
on:
77
push:
8+
branches: [ main ]
89
workflow_dispatch:
910
merge_group:
11+
pull_request:
1012

1113
jobs:
1214
unit-tests:

.github/workflows/zombienet-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ name: E2E Zombienet Tests
22

33
on:
44
push:
5+
branches: [ main ]
56
workflow_dispatch:
67
merge_group:
8+
pull_request:
79

810
jobs:
911
zombienet-tests:

e2e/nodes/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# e2e-nodes
2+
3+
### Download the node binaries
4+
5+
Download the both `ink-node` and `substrate-contract-node` to your local environment:
6+
- [ink-node](https://github.com/use-ink/ink-node/releases/tag/v0.43.3)
7+
- [substrate-contracts-node](https://github.com/paritytech/substrate-contracts-node/releases/tag/v0.42.0)
8+
9+
### Run both nodes at 2 different port
10+
11+
```shell
12+
# cd to the download folder
13+
14+
# run ink-node at port 9955
15+
./ink-node --rpc-port=9955 --state-pruning=archive --blocks-pruning=archive
16+
17+
# run substrate-contracts-node at port 9944
18+
./substrate-contracts-node --dev --rpc-port=9944
19+
```
20+
21+
### Run the tests
22+
23+
After getting both node running, we can run the e2e tests by running the following command:
24+
25+
```shell
26+
yarn workspace e2e-nodes e2e:test
27+
```

e2e/nodes/package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "e2e-nodes",
3+
"author": "Thang Vu <thang@dedot.dev>",
4+
"private": true,
5+
"type": "module",
6+
"scripts": {
7+
"e2e:test": "npx vitest --watch=false --no-file-parallelism"
8+
},
9+
"dependencies": {
10+
"@dedot/chaintypes": "^0.155.0",
11+
"@polkadot/keyring": "^13.5.6",
12+
"dedot": "^0.17.0",
13+
"typink": "workspace:*"
14+
},
15+
"license": "MIT"
16+
}

e2e/nodes/src/contracts/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Contracts
2+
3+
### Generate types for `flipper` contracts
4+
```shell
5+
# Run from project's root folder
6+
yarn cli typink -m ./e2e/contracts/src/contracts/flipper_v5.json -o ./e2e/contracts/src/contracts/
7+
```
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Generated by dedot cli
2+
3+
import type { Hash, Result } from 'dedot/codecs';
4+
import type {
5+
ConstructorCallOptions,
6+
ContractInstantiateResult,
7+
GenericConstructorCallResult,
8+
GenericConstructorQuery,
9+
GenericConstructorQueryCall,
10+
} from 'dedot/contracts';
11+
import type { GenericSubstrateApi } from 'dedot/types';
12+
import type { FlipperFlipperError } from './types.js';
13+
14+
export interface ConstructorQuery<ChainApi extends GenericSubstrateApi> extends GenericConstructorQuery<ChainApi> {
15+
/**
16+
* Creates a new flipper smart contract initialized with the given value.
17+
*
18+
* @param {boolean} initValue
19+
* @param {ConstructorCallOptions} options
20+
*
21+
* @selector 0x9bae9d5e
22+
**/
23+
new: GenericConstructorQueryCall<
24+
ChainApi,
25+
(
26+
initValue: boolean,
27+
options?: ConstructorCallOptions,
28+
) => Promise<GenericConstructorCallResult<[], ContractInstantiateResult<ChainApi>>>
29+
>;
30+
31+
/**
32+
* Creates a new flipper smart contract initialized to `false`.
33+
*
34+
* @param {ConstructorCallOptions} options
35+
*
36+
* @selector 0x61ef7e3e
37+
**/
38+
newDefault: GenericConstructorQueryCall<
39+
ChainApi,
40+
(options?: ConstructorCallOptions) => Promise<GenericConstructorCallResult<[], ContractInstantiateResult<ChainApi>>>
41+
>;
42+
43+
/**
44+
* Creates a new flipper smart contract with the value being calculate using provided seed.
45+
*
46+
* @param {Hash} seed
47+
* @param {ConstructorCallOptions} options
48+
*
49+
* @selector 0x6d4cae81
50+
**/
51+
fromSeed: GenericConstructorQueryCall<
52+
ChainApi,
53+
(
54+
seed: Hash,
55+
options?: ConstructorCallOptions,
56+
) => Promise<GenericConstructorCallResult<Result<[], FlipperFlipperError>, ContractInstantiateResult<ChainApi>>>
57+
>;
58+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Generated by dedot cli
2+
3+
import type { Hash } from 'dedot/codecs';
4+
import type {
5+
ConstructorTxOptions,
6+
GenericConstructorTx,
7+
GenericConstructorTxCall,
8+
GenericContractApi,
9+
GenericInstantiateSubmittableExtrinsic,
10+
} from 'dedot/contracts';
11+
import type { GenericSubstrateApi } from 'dedot/types';
12+
13+
export interface ConstructorTx<
14+
ChainApi extends GenericSubstrateApi,
15+
ContractApi extends GenericContractApi = GenericContractApi,
16+
> extends GenericConstructorTx<ChainApi> {
17+
/**
18+
* Creates a new flipper smart contract initialized with the given value.
19+
*
20+
* @param {boolean} initValue
21+
* @param {ConstructorTxOptions} options
22+
*
23+
* @selector 0x9bae9d5e
24+
**/
25+
new: GenericConstructorTxCall<
26+
ChainApi,
27+
(
28+
initValue: boolean,
29+
options?: ConstructorTxOptions,
30+
) => GenericInstantiateSubmittableExtrinsic<ChainApi, ContractApi>
31+
>;
32+
33+
/**
34+
* Creates a new flipper smart contract initialized to `false`.
35+
*
36+
* @param {ConstructorTxOptions} options
37+
*
38+
* @selector 0x61ef7e3e
39+
**/
40+
newDefault: GenericConstructorTxCall<
41+
ChainApi,
42+
(options?: ConstructorTxOptions) => GenericInstantiateSubmittableExtrinsic<ChainApi, ContractApi>
43+
>;
44+
45+
/**
46+
* Creates a new flipper smart contract with the value being calculate using provided seed.
47+
*
48+
* @param {Hash} seed
49+
* @param {ConstructorTxOptions} options
50+
*
51+
* @selector 0x6d4cae81
52+
**/
53+
fromSeed: GenericConstructorTxCall<
54+
ChainApi,
55+
(seed: Hash, options?: ConstructorTxOptions) => GenericInstantiateSubmittableExtrinsic<ChainApi, ContractApi>
56+
>;
57+
}

0 commit comments

Comments
 (0)