difftreelog
ci fix js-packages paths
in: master
18 files changed
.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:
.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 }}
.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 }}
.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:
.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: |
.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/
.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}
.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/
.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}
.github/workflows/yarn-dev.ymldiffbeforeafterboth--- a/.github/workflows/yarn-dev.yml
+++ b/.github/workflows/yarn-dev.yml
@@ -66,7 +66,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 test --reporter mochawesome --reporter-options reportFilename=test-${NOW}
env:
@@ -90,13 +90,13 @@
working-directory: js-packages/scripts
run: |
yarn install
- npx ts-node --esm ./src/benchmarks/mintFee/index.ts
+ npx ts-node --esm ./benchmarks/mintFee/index.ts
- name: Run benchmark opsFee tests
working-directory: js-packages/scripts
run: |
yarn install
- npx ts-node --esm ./src/benchmarks/opsFee/index.ts
+ npx ts-node --esm ./benchmarks/opsFee/index.ts
- name: Stop running containers
if: always() # run this step always
Makefilediffbeforeafterboth--- 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
doc/separate_rpc.mddiffbeforeafterboth11. Create, in the `primitives` folder, a crate with a trait for RPC generation.2 ```rust3 sp_api::decl_runtime_apis! {4 #[api_version(2)]5 pub trait ModuleNameApi<CrossAccountId> 6 where7 CrossAccountId: pallet_evm::account::CrossAccountId<AccountId>,8 {9 fn method_name(user: Option<CrossAccountId>) -> Result<u128, DispatchError>;10 }11 }12 ```13142. client/rpc/src/lib.rs15 * Add a trait with the required methods. Mark it with `#[rpc(server)]` and `#[async_trait]` directives.16 ```rust17 #[rpc(server)]18 #[async_trait]19 pub trait ModuleNameApi<BlockHash, CrossAccountId> {20 #[method(name = "moduleName_methodName")]21 fn method_name(&self, user: Option<CrossAccountId>, at: Option<BlockHash>)22 -> Result<String>;23 }24 ```25 * Don't forget to write the correct method identifier in the form `moduleName_methodName`.26 * Add a structure for which the server API interface will be implemented.27 ```rust28 define_struct_for_server_api!(ModuleName);29 ```30 * Define a macro to be used in the implementation of the server API interface.31 ```rust32 macro_rules! module_api {33 () => {34 dyn ModuleNameRuntimeApi<BlockHash, CrossAccountId>35 };36 }37 ```38 * Implement a server API interface.39 ```rust40 impl<C, Block, CrossAccountId> 41 ModuleNameApiServer<<Block as BlockT>::Hash, CrossAccountId> for ModuleName<C, Block>42 where43 Block: BlockT,44 C: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block>,45 C::Api: AppPromotionRuntimeApi<Block, BlockNumber, CrossAccountId, AccountId>,46 CrossAccountId: pallet_evm::account::CrossAccountId<AccountId>,47 {48 pass_method!(method_name(user: Option<CrossAccountId>) -> String => |v| v.to_string(), app_promotion_api);49 }50 ```51523. runtime/common/runtime_apis.rs53 * Implement the `ModuleNameApi` interface for `Runtime`. Optionally, you can mark a feature flag to disable the functionality.54 ```rust55 impl MethodApi<Block, BlockNumber, CrossAccountId, AccountId> for Runtime {56 fn method_name(user: Option<CrossAccountId>) -> Result<u128, DispatchError> {57 #[cfg(not(feature = "module"))]58 return unsupported!();5960 #[cfg(feature = "module")]61 return Ok(0);62 }63 }64 ```65664. node/cli/src/service.rs67 * Set the `MethodApi<Block, Runtime::CrossAccountId>` bound in the `start_node_impl`, `start_node`, `start_dev_node` methods.68695. node/rpc/src/lib.rs70 * Add `MethodApi<Block, Runtime::CrossAccountId>` bound to `create_full` method.71 * Enable RPC in the `create_full` method by adding `io.merge(ModuleName::new(client.clone()).into_rpc())?;`72736. Add a new crate (see point 1) into dependencies.74 * client/rpc/Cargo.toml75 * node/rpc/Cargo.toml76 * runtime/opal/Cargo.toml77 * runtime/quartz/Cargo.toml78 * runtime/unique/Cargo.toml79807. Create tests/src/interfaces/ModuleName/definitions.ts and describe the necessary methods in it.81 ```ts82 type RpcParam = {83 name: string;84 type: string;85 isOptional?: true;86 };8788 const CROSS_ACCOUNT_ID_TYPE = 'PalletEvmAccountBasicCrossAccountIdRepr';8990 const fun = (description: string, params: RpcParam[], type: string) => ({91 description,92 params: [...params, atParam],93 type,94 });9596 export default {97 types: {},98 rpc: {99 methodName: fun(100 'Documentation for method',101 [{name: 'user', type: CROSS_ACCOUNT_ID_TYPE, isOptional: true}],102 'u128',103 ),104 },105 };106 ```1071088. Describe definitions from paragraph 7 in tests/src/interfaces/definitions.ts.109 ```ts110 export {default as ModuleName} from './module/definitions';111 ```1121139. tests/src/substrate/substrate-api.ts114 * Set the RPC interface in the `defaultApiOptions` function, add an entry in the `rpc` parameter115 ```ts116 module: defs.module.rpc,117 ```11811910. tests/src/util/playgrounds/unique.dev.ts120 * Specify RPC interface in `connect` function, add entry in `rpc` parameter121 ```ts122 module: defs.module.rpc,123 ```js-packages/.dockerignorediffbeforeafterboth--- a/js-packages/.dockerignore
+++ b/js-packages/.dockerignore
@@ -1,2 +1 @@
node_modules/
-Dockerfile-tests
js-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}
js-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',
},
];
js-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"
}
}
js-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!"
js-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'"
}
}