Skip to content

Commit

Permalink
lockfile update (#3)
Browse files Browse the repository at this point in the history
* lockfile update

* Upgrade deps

* Package-lock.json

* Updating e2e tests readme (paritytech#375)

* Fixing e2e readme link

* Adding runtimeRestarter (paritytech#376)

Fixes paritytech#223

+ Adding prom-client dependency, because it was removed from
@eng-automation/js (rightfully so)

* Updating zombinenet verion in e2e docs (paritytech#378)

@josepot has reported an error with `@zombienet/cli@1.3.43`, while the
latest version worked

* Using PAPI for e2e tests (paritytech#379)

* Currently, e2e types are generated on postinstall and prebuild steps,
which requires metadata to be available in Docker image, even though
it's not technically used in the application code. I think separating
things would make things more complicated, but it's possible.
* Couldn't undestand the reason for having two different COPY
instructions
in Dockerfile, but that doesn't live well with generating types in
postinstall, so merging those two
* .scale metadata files from Zombienet hosts saved in the codebase,
in order to be able to compile the code separately from running
Zombienet

* Update dependencies

* yarn.lock

* Bump the npm_and_yarn group across 2 directories with 2 updates (paritytech#381)

* removed base url (paritytech#382)

This removes the base url, making the website work on the root of the
domain.

Also, by doing this change, and having set up the dns, this resolves
paritytech#348

* Update deps

* Update API calls

* Silence polkadot API type errors

* Update captcha type to image and set width of captcha container

* remove grid class

* switch back to PJS. change port number

* remove prettier deps

* update port

* set procaptcha details

* fix dropdown z-index

* Fix z-indexes

* Change mock provider version

* remove console.errors

---------

Co-authored-by: Yuri Volkov <0@mcornholio.ru>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Javier Bullrich <javier@bullrich.dev>
  • Loading branch information
4 people authored Mar 26, 2024
1 parent c12b078 commit b397ef5
Show file tree
Hide file tree
Showing 24 changed files with 2,370 additions and 487 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
!tsconfig.json
!env.*.config.json
!src

/src/**/*.e2e.ts
/src/**/*.spec.ts
25 changes: 20 additions & 5 deletions .github/workflows/E2E.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,42 @@ jobs:
- run: yarn install --frozen-lockfile
- name: Download Polkadot and parachain binaries
run: |
wget --no-verbose https://github.com/paritytech/cumulus/releases/download/v0.9.420/polkadot-parachain
wget --no-verbose https://github.com/paritytech/polkadot/releases/download/v0.9.42/polkadot
wget --no-verbose https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-v1.8.0/polkadot
wget --no-verbose https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-v1.8.0/polkadot-parachain
wget --no-verbose https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-v1.8.0/polkadot-prepare-worker
wget --no-verbose https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-v1.8.0/polkadot-execute-worker
chmod +x ./polkadot*
working-directory: e2e
- name: Run a local relaychain with a parachain using zombienet
run: |
export PATH=$(pwd):$PATH
npx --yes @zombienet/cli@1.3.86 -l text \
--provider native spawn zombienet.native.toml \
npx --yes @zombienet/cli@1.3.93 \
--provider native \
--dir zombienet_logs \
spawn zombienet.native.toml \
> polkadot.txt 2>&1 &
source wait_until.sh 'curl -s "127.0.0.1:9923"'
source wait_until.sh 'curl -s "127.0.0.1:9934"'
source wait_until.sh 'curl -s "127.0.0.1:9988"'
working-directory: e2e
- name: Build e2e types
run: yarn generate:papi:e2e
- name: Build faucet
run: yarn build:docker
- name: Run the E2E tests
run: yarn test:e2e
- name: Debug Polkadot logs
- name: Debug Zombienet host logs
if: failure()
run: cat e2e/polkadot.txt
- name: Debug Zombienet alice node logs
if: failure()
run: cat e2e/zombienet_logs/alice.log
- name: Debug Zombienet bob node logs
if: failure()
run: cat e2e/zombienet_logs/bob.log
- name: Debug Zombienet alice-1 node logs
if: failure()
run: cat e2e/zombienet_logs/alice-1.log
- name: Debug Matrix logs
if: failure()
run: cat e2e/containter_logs/faucet-test-matrix.log
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/deploy-site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ jobs:
PUBLIC_CAPTCHA_KEY: 6LcgFI4nAAAAAATrEMoJ6zBacsx5udc1UhGFXemH
GITHUB_PAGES: "/${{ github.event.repository.name }}"
STATIC: true
BASE: "/polkadot-testnet-faucet"
- uses: actions/upload-artifact@master
with:
name: faucet
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ storage.db
sqlite.db
build
e2e/containter_logs
e2e/zombienet_logs

# Autogenerated
env.*.config.json.d.ts
!.env.example

/data
/src/test/codegen
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ check-linting:
<<: *kubernetes-env
script:
- yarn --frozen-lockfile
- yarn generate:papi:e2e
- cd client && yarn --frozen-lockfile && cd ..
- yarn typecheck && yarn format && yarn lint

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ $ cp example.env .env

## End-to-end tests

Please refer to the [E2E Readme](./E2E/README.md).
Please refer to the [E2E Readme](./e2e/README.md).

Example requests:

Expand Down
2 changes: 0 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
"autoprefixer": "^10.4.16",
"daisyui": "^4.4.4",
"postcss": "^8.4.31",
"prettier": "^3.0.3",
"prettier-plugin-svelte": "^3.0.3",
"svelte": "^4.2.7",
"svelte-check": "^3.6.1",
"svelte-markdown": "^0.4.0",
Expand Down
1 change: 1 addition & 0 deletions client/src/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ interface Procaptcha {
callback?: string;
theme?: "light" | "dark";
"chalexpired-callback"?: string;
captchaType?: "image";
},
) => void;
default: (callback: () => void) => void;
Expand Down
3 changes: 2 additions & 1 deletion client/src/lib/components/CaptchaV2.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
theme: colorTheme,
callback: "onToken",
"chalexpired-callback": "onExpiredToken",
captchaType: "image",
});
} else if (captchaProvider === CaptchaProvider.recaptcha) {
if (!window.grecaptcha) {
Expand Down Expand Up @@ -95,4 +96,4 @@
</div>
</div>
{/if}
<div id={captchaId} />
<div id={captchaId} class="z-0" />
2 changes: 1 addition & 1 deletion client/src/lib/components/Form.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
/>
</div>
{#if !webRequest}
<div class="grid place-items-center">
<div class="place-items-center">
<CaptchaV2
captchaKey={PUBLIC_CAPTCHA_PROVIDER === CaptchaProvider.procaptcha
? PUBLIC_PROSOPO_SITE_KEY
Expand Down
2 changes: 1 addition & 1 deletion client/src/lib/components/NetworkDropdown.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<Chevron />
</div>
</div>
<ul tabindex="-1" class="dropdown-content menu p-2 shadow bg-base-100 rounded-box w-full text-white">
<ul tabindex="-1" class="dropdown-content menu p-2 shadow bg-base-100 rounded-box w-full text-white z-10">
{#each Networks as { network, url }}
<li class:selected={network.networkName === currentNetwork.networkName}>
<a data-testid={`network-${network.networkName}`} href={url}>{network.networkName} </a>
Expand Down
2 changes: 1 addition & 1 deletion client/src/lib/components/NetworkInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<Chevron />
</div>
</div>
<ul tabindex="0" class="dropdown-content menu p-2 shadow bg-base-100 rounded-box w-full text-white">
<ul tabindex="0" class="dropdown-content menu p-2 shadow bg-base-100 rounded-box w-full text-white z-10">
{#each $testnet.chains as chain, i}
<li class:selected={network === chain.id} data-testid={`network-${i}`}>
<a on:click={() => selectChain(chain.id)}>{chain.name}</a>
Expand Down
6 changes: 3 additions & 3 deletions client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4139,9 +4139,9 @@ yaml@^1.10.0:
integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==

yaml@^2.3.4:
version "2.3.4"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.3.4.tgz#53fc1d514be80aabf386dc6001eb29bf3b7523b2"
integrity sha512-8aAvwVUSHpfEqTQ4w/KMlf3HcRdt50E5ODIQJBw1fQ5RL34xabzxtUlzTXVqc4rkZsPbvrXKWnABCD7kWSmocA==
version "2.4.1"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.4.1.tgz#2e57e0b5e995292c25c75d2658f0664765210eed"
integrity sha512-pIXzoImaqmfOrL7teGUBt/T7ZDnyeGBWyXQBvOVhLkWLN37GXv8NMLK406UY6dS51JfcQHsmcW5cJ441bHg6Lg==

yargs-parser@^21.1.1:
version "21.1.1"
Expand Down
72 changes: 36 additions & 36 deletions e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,55 +27,46 @@ A number of Jest test cases cover the external API of the faucet and the matrix-

1. Prepare the blockchain executables

We need two executables - one for Polkadot relay chain, and one for Cumulus based parachain.
We need several executables - `polkadot`, `polkadot-prepare-worker` and `polkadot-execute-worker`
for Polkadot relay chain, and `polkadot-parachain` for Cumulus based parachain.
It is recommended to use released versions of those (as opposed to code from `master`)

**Note:** The 1.0 release of Polkadot has NOT been tested yet.

For example, to download a `v0.9.38` release of `polkadot` and a corresponding version of a parachain:

Decide, where to put the binaries (replace `<bin_path>` with it, for all examples) and add it to `PATH`,
so that `zombienet` will be able to find them:
```bash
wget https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-v1.5.0/polkadot
wget https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-v1.5.0/polkadot-execute-worker.asc
wget https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-v1.5.0/polkadot-prepare-worker
wget https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-v1.5.0/polkadot-parachain
chmod +x ./polkadot*
export PATH="<bin_path>:$PATH"
```

Next, add the binaries to `PATH` so that `zombienet` will be able to find them:
**Linux**:

For example, to download a `v1.8.0` release of `polkadot` and a corresponding version of a parachain:

```bash
export PATH="${PWD}:$PATH"
cd <bin_path>
wget https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-v1.8.0/polkadot
wget https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-v1.8.0/polkadot-prepare-worker
wget https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-v1.8.0/polkadot-execute-worker
wget https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-v1.8.0/polkadot-parachain
chmod +x ./polkadot*
```

**M1 Macs**:
**Apple Silicon Macs**:

There are no pre-built binaries, so we need to build the binaries from source.
Starting from cloning the code of Polkadot, we switch to a released version of code and compile the required package:
There are no pre-built binaries, so we need to build the binaries from source:

```bash
git clone https://github.com/paritytech/polkadot.git
cd polkadot
git checkout v1.5.0
cargo build --release --locked -p polkadot
cd -
```

Similarly for Cumulus:
git clone https://github.com/paritytech/polkadot-sdk.git
git checkout polkadot-v1.8.0

```bash
git clone https://github.com/paritytech/cumulus.git
cd cumulus/polkadot-parachain
git checkout v1.5.0
cd polkadot-sdk/polkadot
cargo build --release --locked
cd -
```
cp ../target/release/polkadot <bin_path>/
cp ../target/release/polkadot-execute-worker <bin_path>/
cp ../target/release/polkadot-prepare-worker <bin_path>/

Next, add the binaries to `PATH` so that `zombienet` will be able to find them:

```bash
export PATH="${PWD}/polkadot/target/release:$PATH"
export PATH="${PWD}/cumulus/target/release:$PATH"
cd ../cumulus/polkadot-parachain
cargo build --release --locked
cp ../../target/release/polkadot-parachain <bin_path>/
```

2. Run zombienet
Expand All @@ -90,7 +81,7 @@ command -v polkadot-parachain || echo "No polkadot-parachain in PATH"
Next, in the root of this repository, start the Zombienet:

```bash
npx --yes @zombienet/cli@1.3.43 --provider native spawn e2e/zombienet.native.toml
npx --yes @zombienet/cli@1.3.93 --provider native --dir e2e/zombienet_logs spawn e2e/zombienet.native.toml
```

Verify that it's working correctly by opening the [relaychain](https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:9933#/explorer) and [parachain](https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:9934#/explorer) explorers,
Expand All @@ -112,14 +103,23 @@ curl localhost:9934
yarn build:docker
```

4. Run the tests
4. Generate PAPI types for e2e tests

```bash
yarn generate:papi:e2e
```

These types are generated based on `.scale` files in `e2e/` directory. To regenerate these files using live zombienet nodes, use `papi update --config e2e/polkadot-api-e2e.json` command.

5. Run the tests

```bash
yarn test:e2e
```

Logs of the application container will be avaiable at `e2e/containter_logs/faucet-test-app.log`
Logs of matrix container will be avaiable at `e2e/containter_logs/faucet-test-matrix.log`
Logs of zombienet nodes will be available at `e2e/zombienet_logs/`

The whole suite of tests can take tens of seconds,
because it depends on the blockchain to mine blocks and execute the XCM teleportation process.
Binary file added e2e/parachain.scale
Binary file not shown.
12 changes: 12 additions & 0 deletions e2e/polkadot-api-e2e.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"relaychain": {
"outputFolder": "src/test/codegen",
"wsUrl": "ws://127.0.0.1:9923",
"metadata": "e2e/relaychain.scale"
},
"parachain": {
"outputFolder": "src/test/codegen",
"wsUrl": "ws://127.0.0.1:9934",
"metadata": "e2e/parachain.scale"
}
}
Binary file added e2e/relaychain.scale
Binary file not shown.
40 changes: 23 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"format": "prettier ./src ./client/src ./client/tests --check",
"format:fix": "prettier ./src ./client/src ./client/tests --write",
"generate:types": "echo \"declare const schema: $(cat env.faucet.config.json); export default schema;\" > env.faucet.config.json.d.ts",
"generate:papi:e2e": "papi generate --config e2e/polkadot-api-e2e.json",
"lint": "eslint ./src/ ./client/src ./client/tests --ext .js,.ts,.svelte",
"lint:fix": "eslint ./src/ ./client/src ./client/tests --ext .js,.ts,.svelte --fix",
"migrations:generate": "typeorm-ts-node-commonjs migration:generate -d src/db/dataSource.ts",
Expand All @@ -21,7 +22,7 @@
"prepare": "ts-patch install -s",
"start": "node ./build/src/start.js",
"test": "jest",
"test:e2e": "NODE_OPTIONS='--experimental-vm-modules --es-module-specifier-resolution=node' jest -c jest.e2e.config.js --runInBand",
"test:e2e": "NODE_OPTIONS='--experimental-vm-modules --es-module-specifier-resolution=node' jest -c jest.e2e.config.js --runInBand --forceExit",
"typecheck": "tsc --noEmit"
},
"author": "",
Expand All @@ -48,16 +49,19 @@
"pre-commit": "yarn lint-staged"
},
"dependencies": {
"@eng-automation/js": "^1.0.0",
"@polkadot/api": "10.11.1",
"@polkadot/api-augment": "10.11.1",
"@polkadot/keyring": "12.6.1",
"@polkadot/util": "12.6.1",
"@polkadot/util-crypto": "12.6.1",
"@eng-automation/js": "^1.0.3",
"@polkadot-api/cli": "^0.0.1-0027dd301d1d5a078e9c770a18e27aed76a66f50.1.0",
"@polkadot-api/client": "^0.0.1-0027dd301d1d5a078e9c770a18e27aed76a66f50.1.0",
"@polkadot-api/node-polkadot-provider": "^0.0.1-0027dd301d1d5a078e9c770a18e27aed76a66f50.1.0",
"@polkadot-api/ws-provider": "^0.0.1-0027dd301d1d5a078e9c770a18e27aed76a66f50.1.0",
"@polkadot/api": "10.11.2",
"@polkadot/keyring": "12.6.2",
"@polkadot/util": "12.6.2",
"@polkadot/util-crypto": "12.6.2",
"@polkadot/wasm-crypto": "7.2.1",
"@polkadot/x-randomvalues": "12.6.1",
"@prosopo/server": "^0.2.39",
"@prosopo/types": "^0.2.39",
"@polkadot/x-randomvalues": "12.6.2",
"@prosopo/server": "0.3.5",
"@prosopo/types": "0.3.5",
"@types/cors": "^2.8.13",
"axios": "^1.6.0",
"bigfloat.js": "^3.0.1",
Expand All @@ -69,6 +73,7 @@
"matrix-js-sdk": "^26.1.0",
"pg": "^8.11.2",
"react": "^18.2.0",
"prom-client": "^14.2.0",
"reflect-metadata": "^0.1.13",
"request": "^2.88.2",
"typeorm": "^0.3.17"
Expand All @@ -88,6 +93,7 @@
"joi": "^17.6.4",
"lint-staged": "^12.3.8",
"nodemon": "^2.0.19",
"rxjs": "^7.8.1",
"simple-git-hooks": "^2.7.0",
"supertest": "^6.3.3",
"testcontainers": "^9.9.1",
Expand All @@ -103,12 +109,12 @@
}
},
"resolutions": {
"@polkadot/api": "10.11.1",
"@polkadot/api-augment": "10.11.1",
"@polkadot/keyring": "12.6.1",
"@polkadot/util": "12.6.1",
"@polkadot/util-crypto": "12.6.1",
"@polkadot/wasm-crypto": "7.2.1",
"@polkadot/x-randomvalues": "12.6.1"
"@polkadot/api": "10.11.2",
"@polkadot/api-augment": "10.11.2",
"@polkadot/keyring": "12.6.2",
"@polkadot/util": "12.6.2",
"@polkadot/util-crypto": "12.6.2",
"@polkadot/wasm-crypto": "7.3.2",
"@polkadot/x-randomvalues": "12.6.2"
}
}
Loading

0 comments on commit b397ef5

Please sign in to comment.