Browse Source

Reduce blocktime for test node to 1s

Leszek Wiesner 3 years ago
parent
commit
f63c672d69

+ 2 - 2
.github/workflows/run-integration-tests.yml

@@ -30,7 +30,7 @@ jobs:
       - id: compute_shasum
         name: Compute runtime code shasum
         env:
-          PROPOSALS_PARAMETERS_PATH: ./tests/integration-tests/proposal-parameters.json
+          TEST_NODE: true
         run: |
           export RUNTIME_CODE_SHASUM=`scripts/runtime-code-shasum.sh`
           echo "::set-output name=shasum::${RUNTIME_CODE_SHASUM}"
@@ -71,7 +71,7 @@ jobs:
             docker build .\
               --file joystream-node.Dockerfile\
               --tag joystream/node\
-              --build-arg PROPOSALS_PARAMETERS="$(cat ./tests/integration-tests/proposal-parameters.json)"
+              --build-arg TEST_NODE=true
             docker save --output joystream-node-docker-image.tar joystream/node
             gzip joystream-node-docker-image.tar
             cp joystream-node-docker-image.tar.gz ~/docker-images/

+ 6 - 3
joystream-node.Dockerfile

@@ -13,9 +13,12 @@ COPY . /joystream
 # Build all cargo crates
 # Ensure our tests and linter pass before actual build
 ENV WASM_BUILD_TOOLCHAIN=nightly-2020-10-06
-ARG PROPOSALS_PARAMETERS
-ENV ALL_PROPOSALS_PARAMETERS_JSON=$PROPOSALS_PARAMETERS
-RUN BUILD_DUMMY_WASM_BINARY=1 cargo clippy --release --all -- -D warnings && \
+ARG TEST_NODE
+RUN echo "TEST_NODE=$TEST_NODE"
+RUN test -n "$TEST_NODE" && sed -i 's/MILLISECS_PER_BLOCK: Moment = 6000/MILLISECS_PER_BLOCK: Moment = 1000/' ./runtime/src/constants.rs
+RUN test -n "$TEST_NODE" && sed -i 's/SLOT_DURATION: Moment = 6000/SLOT_DURATION: Moment = 1000/' ./runtime/src/constants.rs
+RUN export ALL_PROPOSALS_PARAMETERS_JSON="$(test -n "$TEST_NODE" && cat ./tests/integration-tests/proposal-parameters.json)" &&\
+    BUILD_DUMMY_WASM_BINARY=1 cargo clippy --release --all -- -D warnings && \
     cargo test --release --all && \
     cargo build --release
 

+ 7 - 1
scripts/runtime-code-shasum.sh

@@ -12,6 +12,9 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
 	TAR=gtar
 fi
 
+export TEST_NODE_BLOCKTIME=1000
+export TEST_PROPOSALS_PARAMETERS_PATH="./tests/integration-tests/proposal-parameters.json"
+
 # sort/owner/group/mtime arguments only work with gnu version of tar!
 ${TAR} -c --sort=name --owner=root:0 --group=root:0 --mtime='UTC 2020-01-01' \
     Cargo.lock \
@@ -20,4 +23,7 @@ ${TAR} -c --sort=name --owner=root:0 --group=root:0 --mtime='UTC 2020-01-01' \
     runtime-modules \
     utils/chain-spec-builder \
     joystream-node.Dockerfile \
-    $(echo "$PROPOSALS_PARAMETERS_PATH") | shasum | cut -d " " -f 1
+    $(test -n "$TEST_NODE" && echo "$TEST_PROPOSALS_PARAMETERS_PATH") \
+    | if [[ -n "$TEST_NODE" ]]; then sed '$a'"$TEST_NODE_BLOCKTIME"; else tee; fi \
+    | shasum \
+    | cut -d " " -f 1

+ 1 - 1
tests/integration-tests/src/consts.ts

@@ -7,7 +7,7 @@ import { ProposalType, WorkingGroupModuleName } from './types'
 export const validateType = <T>(obj: T) => obj
 
 // Test chain blocktime
-export const BLOCKTIME = 6000
+export const BLOCKTIME = 1000
 
 export const MINIMUM_STAKING_ACCOUNT_BALANCE = 200
 export const MIN_APPLICATION_STAKE = new BN(2000)