Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
fe7cef6
feat(e2e): init typescript for e2e tests
clearloop May 20, 2021
ae83906
ci(build): build and test with release binary
clearloop May 21, 2021
6aaf424
feat(e2e): abstract pint command
clearloop May 23, 2021
7dc726e
ci(docker): move docker config into folder docker
clearloop May 26, 2021
f7d782e
ci(docker): type of the path of Dockerfile
clearloop May 26, 2021
aeb9746
fead(docker): add Dockerfile for launching PINT
clearloop May 26, 2021
4d86b9c
feat(e2e): use test binaries served by clearloop
clearloop May 26, 2021
1b64ca9
ci(e2e): save binaires into scratch image
clearloop May 26, 2021
cd483d6
ci(docker): fetch binaries from dockerhub
clearloop May 26, 2021
a9b081c
ci(e2e): build e2e image in CI
clearloop May 27, 2021
640fad8
ci(e2e): add e2e to workflow jobs
clearloop May 27, 2021
72609b8
feat(e2e): init javascript workspace
clearloop May 27, 2021
33e4326
ci(e2e): checkout before building e2e image
clearloop May 27, 2021
a3d42a4
feat(e2e): init tester
clearloop May 27, 2021
9afcae3
feat(e2e): abstract result type
clearloop May 27, 2021
c480ddc
feat(e2e): define types for pallets
clearloop May 27, 2021
741883b
chore(js): move js packages into js folder
clearloop May 27, 2021
1a51004
feat(js): add polkadot-launch as submodule
clearloop May 27, 2021
78e1fc7
feat(js): package launch
clearloop May 27, 2021
174c519
feat(e2e): traverse APIs
clearloop May 27, 2021
b5b2c9a
feat(e2e): remove launch and api
clearloop May 27, 2021
5d1d8da
ci(e2e): squash commands in e2e
clearloop May 27, 2021
8bbdb16
feat(e2e): add e2e runner
clearloop May 28, 2021
21f4e80
chore(e2e): reinit polkadot-launch
clearloop May 28, 2021
62b1e7e
feat(e2e): launch pint as child_process
clearloop May 28, 2021
f8983ac
feat(e2e): add kill signal to fork process
clearloop Jun 11, 2021
c11c7d0
feat(e2e): complete tests process
clearloop Jun 12, 2021
442f5bf
ci(e2e): add e2e scripts
clearloop Jun 12, 2021
8b7af68
ci(e2e): prefix sudo command
clearloop Jun 12, 2021
65ce0e5
feat(e2e): update commands and recheck permission
clearloop Jun 12, 2021
cbd5370
feat(e2e): use node 16
clearloop Jun 12, 2021
0d482d1
ci(e2e): sudo bash
clearloop Jun 12, 2021
c4fe9fa
ci(e2e): use yarn
clearloop Jun 13, 2021
1ad0e74
ci(e2e): yarn install
clearloop Jun 13, 2021
779035d
ci(e2e): install yarn use apt
clearloop Jun 13, 2021
b3208ae
ci(e2e): remove previous nodejs
clearloop Jun 13, 2021
06a291c
ci(e2e): remove node togethor
clearloop Jun 13, 2021
6c74ec1
ci(e2e): install node with nvm
clearloop Jun 13, 2021
5866278
ci(e2e): use nvm install node
clearloop Jun 13, 2021
f891c50
ci(e2e): use yarn start
clearloop Jun 13, 2021
3ee63e6
ci(e2e): yarn start
clearloop Jun 13, 2021
3c6a307
ci(e2e): use v15.9.0
clearloop Jun 13, 2021
70e909d
ci(e2e): install and use 15.9.0
clearloop Jun 13, 2021
9c62829
ci(e2e): force ps.send
clearloop Jun 13, 2021
6d05f08
ci(e2e): check fork process
clearloop Jun 13, 2021
7be11f1
ci(e2e): remove signal in SpawnOption
clearloop Jun 13, 2021
1c76270
ci(e2e): log chunks
clearloop Jun 14, 2021
6a0f206
ci(e2e): use inherit instead of pipe
clearloop Jun 14, 2021
c76bb9f
ci(e2e): prints stderr
clearloop Jun 14, 2021
b2aa952
ci(e2e): mark stdout to string
clearloop Jun 14, 2021
91e7e1a
ci(e2e): buffer to string by hand
clearloop Jun 14, 2021
37b1947
ci(e2e): remove -it in docker arguments
clearloop Jun 14, 2021
f7e118a
ci(e2e): use 0.0.0.0 as host
clearloop Jun 14, 2021
13904ad
ci(e2e): expose ports
clearloop Jun 14, 2021
90b02a6
ci(e2e): use 127.0.0.1 as host
clearloop Jun 14, 2021
86ebf07
ci(e2e): use 127.0.0.1 as host, again
clearloop Jun 14, 2021
ec76071
ci(e2e): try set docker ip
clearloop Jun 14, 2021
c34969d
ci(e2e): add debug tail
clearloop Jun 14, 2021
0f6ca61
ci(git): force replace paritytech//
clearloop Jun 14, 2021
a33cff2
ci(e2e): listen to 0.0.0.0 in docker
clearloop Jun 15, 2021
d049bcf
ci(e2e): correct listen-addr
clearloop Jun 15, 2021
15767dd
ci(e2e): ws-external
clearloop Jun 15, 2021
a4d0554
ci(e2e): unsafe-ws-external
clearloop Jun 15, 2021
961cbeb
ci(e2e): fix the fucking docker command
clearloop Jun 15, 2021
e2c7b40
ci(e2e): exit 0
clearloop Jun 15, 2021
e2c1356
ci(e2e): kill all subprocesses
clearloop Jun 15, 2021
3419ec0
chore(git): clean cargo.lock
clearloop Jun 15, 2021
70d5b62
Merge branch 'main' into cl/e2e
clearloop Jun 15, 2021
68748dc
Merge branch 'main' into cl/e2e
clearloop Jun 15, 2021
354899f
chore(runtime): fix typo in runtime
clearloop Jun 15, 2021
35dbddd
ci(e2e): handle EPERM
clearloop Jun 15, 2021
700b4f6
chore(js): use symlink type for LICNESE
clearloop Jun 15, 2021
f8a0e47
feat(js/e2e): try require polkadot-launch as a dependency
clearloop Jun 15, 2021
610d795
ci(e2e): clone polkadot-launch in container
clearloop Jun 15, 2021
ea817b6
chore(js): copy license
clearloop Jun 15, 2021
6a9cb98
Revert "chore(js): copy license"
clearloop Jun 16, 2021
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
38 changes: 34 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,21 +128,48 @@ jobs:
- run:
name: Check for known security issues in dependencies
command: cargo audit
docker-build:
docker-build-release:
executor: test-executor
description: Build Docker Image
steps:
- checkout
- run:
name: Build docker image
command: BUILDKIT_PROGRESS=plain DOCKER_BUILDKIT=1 docker build -t $IMAGE_NAME:latest .
command: BUILDKIT_PROGRESS=plain DOCKER_BUILDKIT=1 docker build -f docker/release.Dockerfile -t $IMAGE_NAME:latest .
- run:
name: Archive Docker image
command: docker save -o image.tar $IMAGE_NAME
- persist_to_workspace:
root: .
paths:
- ./image.tar
docker-run-e2e:
executor: test-executor
description: Build and run e2e tests
steps:
- attach_workspace:
at: /tmp/workspace
- run:
name: Load Archived Docker Image
command: docker load -i /tmp/workspace/image.tar
- checkout
- run:
name: Build PINT launch Image
command: |
git submodule update --init
docker build -f docker/launch.Dockerfile -t launch .
- run:
name: Run e2e tests
command: |
sudo curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | sudo bash \
&& source ~/.bashrc \
&& nvm install v15.9.0 \
&& nvm use v15.9.0 \
&& npm install yarn -g \
&& cd js/e2e \
&& yarn \
&& yarn start

docker-publish-latest:
executor: test-executor
description: Publish latest Docker Image
Expand Down Expand Up @@ -185,10 +212,13 @@ workflows:
- security
docker:
jobs:
- docker-build
- docker-build-release
- docker-run-e2e:
requires:
- docker-build-release
- docker-publish-latest:
requires:
- docker-build
- docker-build-release
filters:
branches:
only: main
Expand Down
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.cargo/config.toml
/target
/Dockerfile
/launch/bin
19 changes: 18 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,26 @@
# These are backup files generated by rustfmt
**/*.rs.bk

# node deps for e2e
node_modules

# The directory caches for osx
.DS_Store

# typescript language server logs
.log

# The cache for docker container dependency
.cargo

# The cache for chain data in container
.local

local-test
# Binaries for launching PINT with polkadot
bin

# Libraries of js output
js/**/*/lib

# Unknown
local-test
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "js/polkadot-launch"]
path = js/polkadot-launch
url = https://github.com/paritytech/polkadot-launch.git
Comment on lines +1 to +3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this as a submodule?

Comment on lines +1 to +3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is obsolete now, right? since we checkout during build?

Copy link
Contributor Author

@clearloop clearloop Jun 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still exists QAQ,

#83 (comment)

We could not avoid using the submodule in the current state I think, because the CI can not fetch this repo as well

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, guess we'd have to live with it for now.

Copy link
Contributor Author

@clearloop clearloop Jun 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is obsolete now, right? since we checkout during build?

OO, This will not be loaded into our directory unless we git submodule update --init

36 changes: 20 additions & 16 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,38 @@
},
"parachains": [
{
"bin": "./target/target/pint",
"bin": "./bin/pint",
"chain": "pint-dev",
"id": "1",
"wsPort": 9988,
"port": 31200,
"balance": "1000000000000000000000",
"flags": [
"-lruntime=debug",
"--",
"--execution=wasm"
"nodes": [
{
"wsPort": 9988,
"port": 31200,
"flags": [
"-lruntime=debug",
"--unsafe-ws-external",
"--",
"--execution=wasm"
]
}
]
},
{
"bin": "./bin/statemint",
"chain": "statemint-dev",
"id": "300",
"wsPort": 9999,
"port": 31300,
"balance": "1000000000000000000000",
"flags": [
"-lruntime=debug",
"--",
"--execution=wasm"
"nodes": [
{
"wsPort": 9999,
"port": 31300,
"flags": ["-lruntime=debug", "--", "--execution=wasm"]
}
]
}
],
"simpleParachains": [
],
"simpleParachains": [],
"hrmpChannels": [
{
"sender": 1,
Expand All @@ -60,4 +64,4 @@
],
"types": {},
"finalization": false
}
}
24 changes: 24 additions & 0 deletions docker/launch.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# syntax=docker/dockerfile:experimental
#
# Copyright 2021 ChainSafe Systems
# SPDX-License-Identifier: LGPL-3.0-only
#
# This Dockerfile builds the environment of e2e tests
FROM debian:buster-slim
COPY config.json config.json
COPY js/polkadot-launch polkadot-launch
COPY --from=chainsafe/pint /usr/local/bin/pint bin/
COPY --from=clearloop/rococo-v1 /polkadot bin/
COPY --from=clearloop/statemint /statemint bin/
ENV CARGO_TERM_COLOR=always
RUN apt-get update -y \
&& apt-get install openssl curl git -y \
&& curl -sL https://deb.nodesource.com/setup_15.x | bash - \
&& apt-get -qqy --no-install-recommends install nodejs -y \
&& rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb \
&& rm -f /var/cache/apt/*.bin \
&& cd polkadot-launch \
&& npm install \
&& npm run build
EXPOSE 9988
ENTRYPOINT [ "node", "polkadot-launch/dist/index.js", "config.json" ]
File renamed without changes.
20 changes: 20 additions & 0 deletions docker/rococo.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# syntax=docker/dockerfile:experimental
#
# Copyright 2021 ChainSafe Systems
# SPDX-License-Identifier: LGPL-3.0-only
#
# rococo-v1
FROM paritytech/ci-linux:production as builder
COPY . .
ENV CARGO_TERM_COLOR=always
RUN --mount=type=cache,target=/usr/local/cargo/git \
--mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,sharing=private,target=target \
git clone https://github.com/paritytech/polkadot.git -b rococo-v1 --depth=1 \
&& cd polkadot \
&& cargo build --release \
&& mv target/release/polkadot /polkadot

# Only a binary for debian
FROM scratch
COPY --from=builder /polkadot /
20 changes: 20 additions & 0 deletions docker/statemint.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# syntax=docker/dockerfile:experimental
#
# Copyright 2021 ChainSafe Systems
# SPDX-License-Identifier: LGPL-3.0-only
#
# statemint
FROM paritytech/ci-linux:production as builder
COPY . .
ENV CARGO_TERM_COLOR=always
RUN --mount=type=cache,target=/usr/local/cargo/git \
--mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,sharing=private,target=target \
git clone https://github.com/paritytech/statemint.git --depth=1 \
&& cd statemint \
&& cargo build --release \
&& mv target/release/statemilnt /statemint

# Only a binary for debian
FROM scratch
COPY --from=builder /statemint /
17 changes: 17 additions & 0 deletions js/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"tabWidth": 4,
"overrides": [
{
"files": "*.json",
"options": {
"tabWidth": 2
}
},
{
"files": ".prettierrc",
"options": {
"tabWidth": 2
}
}
]
}
10 changes: 10 additions & 0 deletions js/e2e/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# E2E

E2E tests for PINT

This package will traverse all APIs provided written in the config


## LICENSE

GNU-v3
24 changes: 24 additions & 0 deletions js/e2e/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* E2E tests for PINT
*/
import { Runner, Extrinsic } from "./src";
import { ApiPromise } from "@polkadot/api";

// Tests
const TESTS = (api: ApiPromise): Extrinsic[] => [
{
pallet: "assetIndex",
call: "addAsset",
args: [
42,
1000000,
api.createType("AssetAvailability" as any),
1000000,
],
},
];
Comment on lines +7 to +19
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can configure our api tests here in the future


// main
(async () => {
await Runner.run(TESTS);
})();
28 changes: 28 additions & 0 deletions js/e2e/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "@pint/e2e",
"version": "1.0.0",
"description": "E2E tests for PINT",
"main": "index.js",
"repository": "https://github.com/ChainSafe/PINT",
"author": "ChainSafe",
"license": "GNU-v3",
"private": true,
"devDependencies": {
"@polkadot/types": "^4.11.2",
"@types/node": "^15.3.1",
"ts-node": "^10.0.0",
"tslint": "^6.1.3",
"typescript": "^4.2.4"
},
"dependencies": {
"@pint/types": "^1.0.0",
"@polkadot/api": "^4.11.2",
"@polkadot/keyring": "^6.5.1",
"find-up": "^5.0.0"
},
"scripts": {
"start": "ts-node index.ts",
"build": "tsc --strict",
"lint": "tsc --noEmit --strict && tslint --project ./tsconfig.json"
}
}
25 changes: 25 additions & 0 deletions js/e2e/src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Config of E2E tests
*/
import { ApiPromise } from "@polkadot/api";
import { KeyringPair } from "@polkadot/keyring/types";

/**
* Extrinsic definition
*/
export interface Extrinsic {
pallet: string;
call: string;
args: any[];
block?: number;
timeout?: number;
}

/**
* The config of e2e tests
*/
export interface Config {
api: ApiPromise;
pair: KeyringPair;
exs: Extrinsic[];
}
8 changes: 8 additions & 0 deletions js/e2e/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* E2E tests for PINT
*/
import Runner from "./runner";
import { Config, Extrinsic } from "./config";
import * as Launch from "./launch";

export { Config, Runner, Launch, Extrinsic };
Loading