git.delta.rocks / unique-network / refs/commits / 6d1c84661df9

difftreelog

ci fix js-packages paths

Yaroslav Bolyukin2023-11-15parent: #4a84b64.patch.diff
in: master

18 files changed

modified.github/workflows/collator-selection.ymldiffbeforeafterboth
--- a/.github/workflows/collator-selection.yml
+++ b/.github/workflows/collator-selection.yml
@@ -181,7 +181,7 @@
           yarn add mochawesome
           # Wanted by both wait_for_first_block
           # export RPC_URL="${RELAY_SAPPHIRE_HTTP_URL:-${RELAY_OPAL_HTTP_URL:-${RELAY_QUARTZ_HTTP_URL:-${RELAY_UNIQUE_HTTP_URL:-}}}}"
-          ../scripts/src/generate_types/wait_for_first_block.sh
+          ../scripts/wait_for_first_block.sh
           echo "Ready to start tests"
           NOW=$(date +%s) && yarn testCollators --reporter mochawesome --reporter-options reportFilename=test-collators-${NOW}
         env:
modified.github/workflows/forkless-update-data.ymldiffbeforeafterboth
--- a/.github/workflows/forkless-update-data.yml
+++ b/.github/workflows/forkless-update-data.yml
@@ -146,19 +146,19 @@
             snippet:(import 'baedeker-library/ops/rewrites.libsonnet').rewriteNodePaths({'bin/unique':{dockerImage:'${{ steps.latest.outputs.name }}'}})
 
       - name: "Reconcile: runtime is upgraded"
-        working-directory: tests
+        working-directory: js-packages/tests
         run: |
           yarn
-          ./scripts/wait_for_first_block.sh
+          ../scripts/wait_for_first_block.sh
           echo "Executing upgrade"
-          yarn ts-node --esm src/util/authorizeEnactUpgrade.ts ${{ steps.wasms.outputs.dir }}/${{ matrix.wasm_name }}-runtime/${{ matrix.wasm_name }}_runtime.compact.compressed.wasm
+          yarn ts-node --esm util/authorizeEnactUpgrade.ts ${{ steps.wasms.outputs.dir }}/${{ matrix.wasm_name }}-runtime/${{ matrix.wasm_name }}_runtime.compact.compressed.wasm
         env:
           RPC_URL: ${{ env.RELAY_UNIQUE_HTTP_URL }}
 
       - name: Run Parallel tests after forkless upgrade
-        working-directory: tests
+        working-directory: js-packages/tests
         run: |
-          ./scripts/wait_for_first_block.sh
+          ../scripts/wait_for_first_block.sh
           echo "Ready to start tests"
           NOW=$(date +%s) && yarn testParallel --reporter mochawesome --reporter-options reportFilename=test-parallel-${NOW}
         env:
@@ -166,7 +166,7 @@
 
       - name: Run Sequential tests after forkless upgrade
         if: success() || failure()
-        working-directory: tests
+        working-directory: js-packages/tests
         run: NOW=$(date +%s) && yarn testSequential --reporter mochawesome --reporter-options reportFilename=test-sequential-${NOW}
         env:
           RPC_URL: ${{ env.RELAY_UNIQUE_HTTP_URL }}
modified.github/workflows/forkless-update-nodata.ymldiffbeforeafterboth
--- a/.github/workflows/forkless-update-nodata.yml
+++ b/.github/workflows/forkless-update-nodata.yml
@@ -161,19 +161,19 @@
             snippet:(import 'baedeker-library/ops/rewrites.libsonnet').rewriteNodePaths({'bin/unique':{dockerImage:'${{ steps.mainnet.outputs.name }}'}})
 
       - name: "Reconcile: runtime is upgraded"
-        working-directory: tests
+        working-directory: js-packages/tests
         run: |
           yarn
-          ./scripts/wait_for_first_block.sh
+          ../scripts/wait_for_first_block.sh
           echo "Executing upgrade"
-          yarn ts-node --esm src/util/authorizeEnactUpgrade.ts ${{ steps.wasms.outputs.dir }}/${{ matrix.wasm_name }}-runtime/${{ matrix.wasm_name }}_runtime.compact.compressed.wasm
+          yarn ts-node --esm util/authorizeEnactUpgrade.ts ${{ steps.wasms.outputs.dir }}/${{ matrix.wasm_name }}-runtime/${{ matrix.wasm_name }}_runtime.compact.compressed.wasm
         env:
           RPC_URL: ${{ env.RELAY_UNIQUE_HTTP_URL }}
 
       - name: Run Parallel tests after forkless upgrade
-        working-directory: tests
+        working-directory: js-packages/tests
         run: |
-          ./scripts/wait_for_first_block.sh
+          ../scripts/wait_for_first_block.sh
           echo "Ready to start tests"
           NOW=$(date +%s) && yarn testParallel --reporter mochawesome --reporter-options reportFilename=test-parallel-${NOW}
         env:
@@ -181,7 +181,7 @@
 
       - name: Run Sequential tests after forkless upgrade
         if: success() || failure()
-        working-directory: tests
+        working-directory: js-packages/tests
         run: NOW=$(date +%s) && yarn testSequential --reporter mochawesome --reporter-options reportFilename=test-sequential-${NOW}
         env:
           RPC_URL: ${{ env.RELAY_UNIQUE_HTTP_URL }}
modified.github/workflows/governance.ymldiffbeforeafterboth
--- a/.github/workflows/governance.yml
+++ b/.github/workflows/governance.yml
@@ -86,7 +86,7 @@
         run: |
           yarn install
           yarn add mochawesome
-          ../scripts/src/generate_types/wait_for_first_block.sh
+          ../scripts/wait_for_first_block.sh
           echo "Ready to start tests"
           NOW=$(date +%s) && yarn testGovernance --reporter mochawesome --reporter-options reportFilename=test-${NOW}
         env:
modified.github/workflows/make-bench.ymldiffbeforeafterboth
--- a/.github/workflows/make-bench.yml
+++ b/.github/workflows/make-bench.yml
@@ -43,16 +43,15 @@
           time make bench
 
       - name: Run node dev mode in background
-        working-directory: ./
         run: |
           ./target/release/unique-collator --dev &
 
       - name: RUN Calibrate
-        working-directory: ./tests
+        working-directory: js-packages/scripts
         run: |
-          yarn install
-          yarn ts-node --esm src/calibrate.ts
-          yarn ts-node --esm src/calibrateApply.ts
+          yarn
+          yarn ts-node --esm calibrate.ts
+          yarn ts-node --esm calibrateApply.ts
           
       - name: show git diff
         run: |
modified.github/workflows/market-test.ymldiffbeforeafterboth
--- a/.github/workflows/market-test.yml
+++ b/.github/workflows/market-test.yml
@@ -119,10 +119,10 @@
 
 # Temporary disable node readyness check. Have to dig into the script logic.
 #      - name: Wait for chain up and running
-#        working-directory: tests
+#        working-directory: js-packages/tests
 #        run: |
 #          yarn install
-#          ./scripts/wait_for_first_block.sh
+#          ../scripts/wait_for_first_block.sh
 #          echo "Ready to start tests"
 #        env:
 #          RPC_URL: http://127.0.0.1:9944/
modified.github/workflows/node-only-update.ymldiffbeforeafterboth
--- a/.github/workflows/node-only-update.yml
+++ b/.github/workflows/node-only-update.yml
@@ -170,6 +170,7 @@
         run: |
           yarn
           yarn add mochawesome
+          # TODO: Update to new script structure after mainnet will have it
           ./scripts/wait_for_first_block.sh
           echo "Ready to start tests"
           NOW=$(date +%s) && yarn testParallel --reporter mochawesome --reporter-options reportFilename=test-parallel-${NOW}
@@ -197,7 +198,7 @@
       - name: Ensure network is alive
         if: success()
         run: |
-          ./tests/scripts/wait_for_first_block.sh
+          ./js-packages/scripts/wait_for_first_block.sh
         env:
           RPC_URL: ${{ env.RELAY_UNIQUE_HTTP_URL }}
 
@@ -217,6 +218,7 @@
         run: |
           yarn install
           yarn add mochawesome
+          # TODO: Update to new script structure after mainnet will have it
           ./scripts/wait_for_first_block.sh
           echo "Ready to start tests"
           NOW=$(date +%s) && yarn testParallel --reporter mochawesome --reporter-options reportFilename=test-parallel-${NOW}
modified.github/workflows/polkadot-types.ymldiffbeforeafterboth
--- a/.github/workflows/polkadot-types.yml
+++ b/.github/workflows/polkadot-types.yml
@@ -74,13 +74,13 @@
       #   run: sudo apt install jq -y
 
       - name: Run generate_types_package script
-        working-directory: tests
+        working-directory: js-packages
         run: |
           yarn install
-          /bin/bash ./scripts/generate_types/wait_for_first_block.sh
+          ./scripts/wait_for_first_block.sh
           git config --global user.name "Unique"
           git config --global user.email github-actions@usetech.com          
-          /bin/bash ./scripts/generate_types/generate_types_package.sh --release ${{ matrix.usage }} --push
+          ./scripts/generate_types/generate_types_package.sh --release ${{ matrix.usage }} --push
         env:
           RPC_URL: http://127.0.0.1:9944/
 
modified.github/workflows/xcm.ymldiffbeforeafterboth
--- a/.github/workflows/xcm.yml
+++ b/.github/workflows/xcm.yml
@@ -327,22 +327,22 @@
           retention-days: 2
 
       - name: Yarn install
-        working-directory: tests
+        working-directory: js-packages/tests
         run: |
           yarn install
           yarn add mochawesome
 
       - name: Call HRMP initialization
-        working-directory: tests
+        working-directory: js-packages/tests
         run: |
-          yarn ts-node --esm src/util/createHrmp.ts ${{matrix.network}}
+          yarn ts-node --esm util/createHrmp.ts ${{matrix.network}}
 
       - name: Run XCM tests
         working-directory: js-packages/tests
         run: |
           # Wanted by both wait_for_first_block
           export RPC_URL="${RELAY_OPAL_HTTP_URL:-${RELAY_QUARTZ_HTTP_URL:-${RELAY_UNIQUE_HTTP_URL:-}}}"
-          ../scripts/src/generate_types/wait_for_first_block.sh
+          ../scripts/wait_for_first_block.sh
           echo "Ready to start tests"
           NOW=$(date +%s) && yarn ${{ matrix.runtest }} --reporter mochawesome --reporter-options reportFilename=test-${NOW}
 
modified.github/workflows/yarn-dev.ymldiffbeforeafterboth
6363
64 - name: Run tests64 - name: Run tests
65 working-directory: js-packages/tests65 working-directory: js-packages/tests
66 run: |66 run: |
67 yarn install67 yarn install
68 yarn add mochawesome68 yarn add mochawesome
69 ../scripts/src/generate_types/wait_for_first_block.sh69 ../scripts/wait_for_first_block.sh
70 echo "Ready to start tests"70 echo "Ready to start tests"
71 NOW=$(date +%s) && yarn test --reporter mochawesome --reporter-options reportFilename=test-${NOW}71 NOW=$(date +%s) && yarn test --reporter mochawesome --reporter-options reportFilename=test-${NOW}
72 env:72 env:
73 RPC_URL: http://127.0.0.1:9944/73 RPC_URL: http://127.0.0.1:9944/
7474
8888
89 - name: Run benchmark mintFee tests89 - name: Run benchmark mintFee tests
90 working-directory: js-packages/scripts90 working-directory: js-packages/scripts
91 run: |91 run: |
92 yarn install92 yarn install
93 npx ts-node --esm ./src/benchmarks/mintFee/index.ts93 npx ts-node --esm ./benchmarks/mintFee/index.ts
9494
95 - name: Run benchmark opsFee tests95 - name: Run benchmark opsFee tests
96 working-directory: js-packages/scripts96 working-directory: js-packages/scripts
97 run: |97 run: |
98 yarn install98 yarn install
99 npx ts-node --esm ./src/benchmarks/opsFee/index.ts99 npx ts-node --esm ./benchmarks/opsFee/index.ts
100100
101 - name: Stop running containers101 - name: Stop running containers
102 if: always() # run this step always102 if: always() # run this step always
modifiedMakefilediffbeforeafterboth
--- a/Makefile
+++ b/Makefile
@@ -7,25 +7,25 @@
 	@echo "  bench-unique"
 
 NATIVE_FUNGIBLE_EVM_STUBS=./pallets/balances-adapter/src/stubs
-NATIVE_FUNGIBLE_EVM_ABI=./js-packages/tests/src/eth/abi/nativeFungible.json
+NATIVE_FUNGIBLE_EVM_ABI=./js-packages/tests/eth/abi/nativeFungible.json
 
 FUNGIBLE_EVM_STUBS=./pallets/fungible/src/stubs
-FUNGIBLE_EVM_ABI=./js-packages/tests/src/eth/abi/fungible.json
+FUNGIBLE_EVM_ABI=./js-packages/tests/eth/abi/fungible.json
 
 NONFUNGIBLE_EVM_STUBS=./pallets/nonfungible/src/stubs
-NONFUNGIBLE_EVM_ABI=./js-packages/tests/src/eth/abi/nonFungible.json
+NONFUNGIBLE_EVM_ABI=./js-packages/tests/eth/abi/nonFungible.json
 
 REFUNGIBLE_EVM_STUBS=./pallets/refungible/src/stubs
-REFUNGIBLE_EVM_ABI=./js-packages/tests/src/eth/abi/reFungible.json
-REFUNGIBLE_TOKEN_EVM_ABI=./js-packages/tests/src/eth/abi/reFungibleToken.json
+REFUNGIBLE_EVM_ABI=./js-packages/tests/eth/abi/reFungible.json
+REFUNGIBLE_TOKEN_EVM_ABI=./js-packages/tests/eth/abi/reFungibleToken.json
 
 CONTRACT_HELPERS_STUBS=./pallets/evm-contract-helpers/src/stubs/
-CONTRACT_HELPERS_ABI=./js-packages/tests/src/eth/abi/contractHelpers.json
+CONTRACT_HELPERS_ABI=./js-packages/tests/eth/abi/contractHelpers.json
 
 COLLECTION_HELPER_STUBS=./pallets/unique/src/eth/stubs/
-COLLECTION_HELPER_ABI=./js-packages/tests/src/eth/abi/collectionHelpers.json
+COLLECTION_HELPER_ABI=./js-packages/tests/eth/abi/collectionHelpers.json
 
-TESTS_API=./js-packages/tests/src/eth/api/
+TESTS_API=./js-packages/tests/eth/api/
 
 .PHONY: regenerate_solidity
 regenerate_solidity: UniqueFungible.sol UniqueNFT.sol UniqueRefungible.sol UniqueRefungibleToken.sol ContractHelpers.sol CollectionHelpers.sol
modifieddoc/separate_rpc.mddiffbeforeafterboth
--- a/doc/separate_rpc.md
+++ b/doc/separate_rpc.md
@@ -77,7 +77,7 @@
     * runtime/quartz/Cargo.toml
     * runtime/unique/Cargo.toml
 
-7. Create tests/src/interfaces/ModuleName/definitions.ts and describe the necessary methods in it.
+7. Create js-packages/types/ModuleName/definitions.ts and describe the necessary methods in it.
     ```ts
     type RpcParam = {
         name: string;
@@ -105,19 +105,19 @@
         };
     ```
 
-8. Describe definitions from paragraph 7 in tests/src/interfaces/definitions.ts.
+8. Describe definitions from paragraph 7 in js-packages/types/definitions.ts.
     ```ts
     export {default as ModuleName} from './module/definitions';
     ```
 
-9. tests/src/substrate/substrate-api.ts
+9. js-packages/tests/substrate/substrate-api.ts
     * Set the RPC interface in the `defaultApiOptions` function, add an entry in the `rpc` parameter
         ```ts
         module: defs.module.rpc,
         ```
 
-10. tests/src/util/playgrounds/unique.dev.ts
+10. js-packages/playgrounds/unique.dev.ts
     * Specify RPC interface in `connect` function, add entry in `rpc` parameter
         ```ts
         module: defs.module.rpc,
-        ```
\ No newline at end of file
+        ```
modifiedjs-packages/.dockerignorediffbeforeafterboth
--- a/js-packages/.dockerignore
+++ b/js-packages/.dockerignore
@@ -1,2 +1 @@
 node_modules/
-Dockerfile-tests
deletedjs-packages/Dockerfile-testsdiffbeforeafterboth
--- a/js-packages/Dockerfile-tests
+++ /dev/null
@@ -1,38 +0,0 @@
-# ===== Integration Tests ======
-
-
-FROM ubuntu:22.04
-LABEL maintainer="UniqueNetwork.io"
-
-RUN apt -y update; apt -y upgrade; apt -y install curl
-
-
-RUN mkdir unique_parachain
-WORKDIR /unique_parachain
-
-RUN apt-get -y update && \
-      apt-get -y upgrade && \
-      apt-get -y install curl jq && \
-      curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash && \
-      export NVM_DIR="$HOME/.nvm" && \
-      [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \
-      nvm install v16.2.0 && \
-      nvm alias default v16.2.0 && \
-      nvm use default
-
-ENV YARN_CACHE_FOLDER ~/.yarn
-
-COPY package.json yarn.lock ./
-
-RUN export NVM_DIR="$HOME/.nvm" && \
-    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \
-    npm install --global yarn && \
-    yarn add mochawesome && \
-    yarn --pure-lockfile
-
-COPY . .
-
-CMD export NVM_DIR="$HOME/.nvm" && \
-    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \
-    ./scripts/wait_for_first_block.sh && \
-    NOW=$(date +%s) && yarn test --reporter mochawesome --reporter-options reportFilename=test-${NOW}
modifiedjs-packages/scripts/benchmarks/mintFee/index.tsdiffbeforeafterboth
--- a/js-packages/scripts/benchmarks/mintFee/index.ts
+++ b/js-packages/scripts/benchmarks/mintFee/index.ts
@@ -14,23 +14,23 @@
 
 export const CONTRACT_IMPORT: ContractImports[] = [
   {
-    fsPath: `${dirname}/../../../../tests/eth/api/CollectionHelpers.sol`,
+    fsPath: `${dirname}/../../../tests/eth/api/CollectionHelpers.sol`,
     solPath: 'eth/api/CollectionHelpers.sol',
   },
   {
-    fsPath: `${dirname}/../../../../tests/eth/api/ContractHelpers.sol`,
+    fsPath: `${dirname}/../../../tests/eth/api/ContractHelpers.sol`,
     solPath: 'eth/api/ContractHelpers.sol',
   },
   {
-    fsPath: `${dirname}/../../../../tests/eth/api/UniqueRefungibleToken.sol`,
+    fsPath: `${dirname}/../../../tests/eth/api/UniqueRefungibleToken.sol`,
     solPath: 'eth/api/UniqueRefungibleToken.sol',
   },
   {
-    fsPath: `${dirname}/../../../../tests/eth/api/UniqueRefungible.sol`,
+    fsPath: `${dirname}/../../../tests/eth/api/UniqueRefungible.sol`,
     solPath: 'eth/api/UniqueRefungible.sol',
   },
   {
-    fsPath: `${dirname}/../../../../tests/eth/api/UniqueNFT.sol`,
+    fsPath: `${dirname}/../../../tests/eth/api/UniqueNFT.sol`,
     solPath: 'eth/api/UniqueNFT.sol',
   },
 ];
modifiedjs-packages/scripts/package.jsondiffbeforeafterboth
--- a/js-packages/scripts/package.json
+++ b/js-packages/scripts/package.json
@@ -14,10 +14,10 @@
     "tslib": "^2.6.2"
   },
   "scripts": {
-    "benchMintingFee": "ts-node src/benchmarks/mintFee/benchmark.ts",
-    "loadTransfer": "ts-node src/transfer.nload.ts",
-    "generateEnv": "ts-node --esm ./src/generateEnv.ts",
-    "propose-upgrade": "ts-node --esm ./src/proposeupgrade.ts",
-    "propose-fast-track": "ts-node --esm ./src/proposefasttrack.ts"
+    "benchMintingFee": "ts-node benchmarks/mintFee/benchmark.ts",
+    "loadTransfer": "ts-node transfer.nload.ts",
+    "generateEnv": "ts-node --esm ./generateEnv.ts",
+    "propose-upgrade": "ts-node --esm ./proposeupgrade.ts",
+    "propose-fast-track": "ts-node --esm ./proposefasttrack.ts"
   }
 }
addedjs-packages/scripts/wait_for_first_block.shdiffbeforeafterboth
--- /dev/null
+++ b/js-packages/scripts/wait_for_first_block.sh
@@ -0,0 +1,43 @@
+#!/usr/bin/env bash
+
+DIR=$(dirname "$0")
+
+. "$DIR/functions.sh"
+
+last_block_id=0
+block_id=0
+function get_block {
+	block_id_hex=$(do_rpc chain_getHeader | jq -r .result.number)
+	block_id=$((block_id_hex))
+	echo Id = $block_id
+}
+
+function had_new_block {
+	last_block_id=$block_id
+	get_block
+	if (( last_block_id != 0 && block_id > last_block_id )); then
+		return 0
+	fi
+	return 1
+}
+
+function reset_check {
+	last_block_id=0
+	block_id=0
+}
+
+while ! had_new_block; do
+	echo "Waiting for next block..."
+	sleep 12
+done
+reset_check
+
+echo "Chain is running, but lets wait for another block after a minute, to avoid startup flakiness."
+sleep 60
+
+while ! had_new_block; do
+	echo "Waiting for another block..."
+	sleep 12
+done
+
+echo "Chain is running!"
modifiedjs-packages/tests/package.jsondiffbeforeafterboth
--- a/js-packages/tests/package.json
+++ b/js-packages/tests/package.json
@@ -26,6 +26,10 @@
         "_test": "yarn setup && mocha --timeout 9999999 --loader=ts-node/esm.mjs",
         "_testParallel": "yarn setup && mocha --timeout 9999999 --parallel --loader=ts-node/esm.mjs",
         "test": "yarn _test './**/*.*test.ts'",
+        "testParallel": "yarn _testParallel './**/*.test.ts'",
+        "testSequential": "yarn _test './**/*.seqtest.ts'",
+        "testGovernance": "RUN_GOV_TESTS=1 yarn _test ./**/governance/*.*test.ts",
+        "testCollators": "RUN_COLLATOR_TESTS=1 yarn _test ./**/collator-selection/**.*test.ts --timeout 49999999",
         "load": "yarn _test './**/*.load.ts'"
     }
 }