Skip to content

Commit

Permalink
Add mantapay rpc tests to manta runtime (#1207)
Browse files Browse the repository at this point in the history
* Add mantapay rpc tests to manta runtiem

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Add avg block time test to mocha tests

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Fix avg block test|
|

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Add logs

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Update average block time test

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Don't await in lambda

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Update stress_benchmark_test.ts

Signed-off-by: Georgi Zlatarev <45011053+ghzlatarev@users.noreply.github.com>

---------

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Signed-off-by: Georgi Zlatarev <45011053+ghzlatarev@users.noreply.github.com>
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
  • Loading branch information
ghzlatarev committed Jul 14, 2023
1 parent 36eabee commit cc77eaf
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 59 deletions.
11 changes: 0 additions & 11 deletions .github/workflows/integration_test_calamari.yml
Original file line number Diff line number Diff line change
Expand Up @@ -338,17 +338,6 @@ jobs:
with:
name: block-time-rococo-relay-for-${{ matrix.chain-spec.id }}.json
path: ${{ github.workspace }}/block-time-rococo.json
# - if: always()
# - name: parse calamari block times
# run: |
# grep '#.*' ${{ github.workspace }}/measure-block-time-${{ matrix.chain-spec.id }}-stdout.log | while read -r line; do words=($line); echo ${words[6]},${words[10]} | tee ${{ github.workspace }}/block-time-${{ matrix.chain-spec.id }}.csv; done
# if [ ! -f ${{ github.workspace }}/block-time-${{ matrix.chain-spec.id }}.csv ]; then echo "block times not detected"; exit 1; fi
# jq -s -R '[split("\n") | .[] | select(length > 0) | split(",") | {block:.[0]|tonumber, time:.[1]|tonumber} ]' ${{ github.workspace }}/block-time-${{ matrix.chain-spec.id }}.csv > ${{ github.workspace }}/block-time-${{ matrix.chain-spec.id }}.json
# - if: always()
# uses: actions/upload-artifact@v2
# with:
# name: block-time-${{ matrix.chain-spec.id }}.json
# path: ${{ github.workspace }}/block-time-${{ matrix.chain-spec.id }}.json
- if: always()
name: test - rococo alice peered successfully
run: |
Expand Down
85 changes: 37 additions & 48 deletions .github/workflows/integration_test_manta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -338,17 +338,6 @@ jobs:
with:
name: block-time-rococo-relay-for-${{ matrix.chain-spec.id }}.json
path: ${{ github.workspace }}/block-time-rococo.json
# - if: always()
# - name: parse manta block times
# run: |
# grep '#.*' ${{ github.workspace }}/measure-block-time-${{ matrix.chain-spec.id }}-stdout.log | while read -r line; do words=($line); echo ${words[6]},${words[10]} | tee ${{ github.workspace }}/block-time-${{ matrix.chain-spec.id }}.csv; done
# if [ ! -f ${{ github.workspace }}/block-time-${{ matrix.chain-spec.id }}.csv ]; then echo "block times not detected"; exit 1; fi
# jq -s -R '[split("\n") | .[] | select(length > 0) | split(",") | {block:.[0]|tonumber, time:.[1]|tonumber} ]' ${{ github.workspace }}/block-time-${{ matrix.chain-spec.id }}.csv > ${{ github.workspace }}/block-time-${{ matrix.chain-spec.id }}.json
# - if: always()
# uses: actions/upload-artifact@v2
# with:
# name: block-time-${{ matrix.chain-spec.id }}.json
# path: ${{ github.workspace }}/block-time-${{ matrix.chain-spec.id }}.json
- if: always()
name: test - rococo alice peered successfully
run: |
Expand All @@ -361,43 +350,43 @@ jobs:
name: test - manta alice peered successfully
run: |
grep '\[Parachain\] 💤 Idle (${{ matrix.chain-spec.expected.peer-count.para }} peers)' ${{ github.workspace }}/polkadot-launch/9921.log
# - name: append manta-pay storage
# run: |
# wget -P ${{ github.workspace }}/Manta/tests/data https://manta-ops.s3.amazonaws.com/integration-tests-data/storage.json
# mv $HOME/.local/share/calamari-pc/${{ matrix.chain-spec.id }}-${GITHUB_SHA:0:7}-spec.json ${{ github.workspace }}/Manta/tests/data/fork.json
# cd ${{ github.workspace }}/Manta/tests
# yarn install
# yarn
# node append_storage.js
# cd ../../
# mv ${{ github.workspace }}/Manta/tests/data/fork.json $HOME/.local/share/calamari-pc/${{ matrix.chain-spec.id }}-${GITHUB_SHA:0:7}-spec.json
# - name: launch testnet
# run: |
# cd ${{ github.workspace }}/polkadot-launch
# yarn install
# yarn build
# pm2 start dist/cli.js \
# --name polkadot-launch \
# --output ${{ github.workspace }}/polkadot-launch-for-${{ matrix.chain-spec.id }}-stdout.log \
# --error ${{ github.workspace }}/polkadot-launch-for-${{ matrix.chain-spec.id }}-stderr.log \
# --no-autorestart \
# -- $HOME/.local/share/calamari-pc/${{ matrix.chain-spec.id }}-${GITHUB_SHA:0:7}-launch-config.json
# - name: run stress test
# run: |
# sleep 720
# cd ${{ github.workspace }}/Manta/tests
# yarn install
# yarn
# yarn stress_benchmark_test --address=ws://127.0.0.1:9921 --exit
# - name: stop testnet
# run: |
# cd ${{ github.workspace }}/polkadot-launch
# pm2 stop polkadot-launch
# - if: always()
# uses: actions/upload-artifact@v2
# with:
# name: ${{ matrix.chain-spec.id }}-alice-stress.log
# path: ${{ github.workspace }}/polkadot-launch/9921.log
- name: append manta-pay storage
run: |
wget -P ${{ github.workspace }}/Manta/tests/data https://manta-ops.s3.amazonaws.com/integration-tests-data/storage.json
mv $HOME/.local/share/calamari-pc/${{ matrix.chain-spec.id }}-${GITHUB_SHA:0:7}-spec.json ${{ github.workspace }}/Manta/tests/data/fork.json
cd ${{ github.workspace }}/Manta/tests
yarn install
yarn
node append_storage.js
cd ../../
mv ${{ github.workspace }}/Manta/tests/data/fork.json $HOME/.local/share/calamari-pc/${{ matrix.chain-spec.id }}-${GITHUB_SHA:0:7}-spec.json
- name: launch testnet
run: |
cd ${{ github.workspace }}/polkadot-launch
yarn install
yarn build
pm2 start dist/cli.js \
--name polkadot-launch \
--output ${{ github.workspace }}/polkadot-launch-for-${{ matrix.chain-spec.id }}-stdout.log \
--error ${{ github.workspace }}/polkadot-launch-for-${{ matrix.chain-spec.id }}-stderr.log \
--no-autorestart \
-- $HOME/.local/share/calamari-pc/${{ matrix.chain-spec.id }}-${GITHUB_SHA:0:7}-launch-config.json
- name: run stress test
run: |
sleep 720
cd ${{ github.workspace }}/Manta/tests
yarn install
yarn
yarn stress_benchmark_test --address=ws://127.0.0.1:9921 --exit
- name: stop testnet
run: |
cd ${{ github.workspace }}/polkadot-launch
pm2 stop polkadot-launch
- if: always()
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.chain-spec.id }}-alice-stress.log
path: ${{ github.workspace }}/polkadot-launch/9921.log
docker-image-test:
timeout-minutes: 120
if: contains(github.event.pull_request.labels.*.name, 'A-manta' || github.ref == 'refs/heads/manta')
Expand Down
14 changes: 14 additions & 0 deletions tests/stress_benchmark_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const test_config = {
transfer_size: 1291,
reclaim_size: 1001,
expected_tps: 0.5,
expected_average_block_time: 13000
};

describe("Node RPC Test", () => {
Expand Down Expand Up @@ -67,7 +68,11 @@ describe("Node RPC Test", () => {
let txsCount = 0;
let startTime = performance.now();
let totalTime = 0;
let lastBlock = 0;

const firstHeader = await api.rpc.chain.getHeader();
const firstBlock = firstHeader.number.toNumber();

for (
let i = test_config.start_iteration;
i < test_config.start_iteration + test_config.tests_iterations;
Expand Down Expand Up @@ -266,6 +271,15 @@ describe("Node RPC Test", () => {
let tps = (test_config.tests_iterations * 7) / totalTime;
console.log("Tps is: ", tps);
assert(tps >= test_config.expected_tps);

const lastHeader = await api.rpc.chain.getHeader();
lastBlock = lastHeader.number.toNumber();
const averageBlockTime = totalTime / (lastBlock - firstBlock);
console.log("Total time: ", totalTime);
console.log("Number of blocks: ", (lastBlock - firstBlock));
console.log("Average block time: ", averageBlockTime);
assert(averageBlockTime < test_config.expected_average_block_time);

break;
}
}
Expand Down

0 comments on commit cc77eaf

Please sign in to comment.