diff --git a/polkadot/.gitlab-ci.yml b/polkadot/.gitlab-ci.yml index 5b33eb2c9a..5bbba30f4e 100644 --- a/polkadot/.gitlab-ci.yml +++ b/polkadot/.gitlab-ci.yml @@ -785,6 +785,33 @@ zombienet-tests-malus-dispute-valid: tags: - zombienet-polkadot-integration-test +zombienet-tests-deregister-register-validator: + stage: stage3 + image: "docker.io/paritytech/zombienet:v1.2.47" + <<: *kubernetes-env + <<: *zombienet-refs + needs: + - job: publish-polkadot-debug-image + artifacts: true + variables: + GH_DIR: "https://github.com/paritytech/polkadot/tree/${CI_COMMIT_SHORT_SHA}/zombienet_tests/smoke" + before_script: + - echo "Zombie-net Tests Config" + - echo "${ZOMBIENET_IMAGE_NAME}" + - echo "${PARACHAINS_IMAGE_NAME} ${PARACHAINS_IMAGE_TAG}" + - echo "${GH_DIR}" + - export DEBUG=zombie* + - export ZOMBIENET_INTEGRATION_TEST_IMAGE=${PARACHAINS_IMAGE_NAME}:${PARACHAINS_IMAGE_TAG} + - export MALUS_IMAGE=${MALUS_IMAGE_NAME}:${MALUS_IMAGE_TAG} + script: + - /home/nonroot/zombie-net/scripts/ci/run-test-env-manager.sh + --github-remote-dir="${GH_DIR}" + --test="0003-deregister-register-validator-smoke.feature" + allow_failure: false + retry: 2 + tags: + - zombienet-polkadot-integration-test + #### stage: stage4 publish-rustdoc: diff --git a/polkadot/zombienet_tests/smoke/0003-deregister-register-validator-smoke.feature b/polkadot/zombienet_tests/smoke/0003-deregister-register-validator-smoke.feature new file mode 100644 index 0000000000..90fa4ef9d7 --- /dev/null +++ b/polkadot/zombienet_tests/smoke/0003-deregister-register-validator-smoke.feature @@ -0,0 +1,28 @@ +Description: Deregister / Register Validator Smoke +Network: ./0003-deregister-register-validator-smoke.toml +Creds: config + +alice: is up +bob: is up +charlie: is up +dave: is up + +# ensure is in the validator set +dave: reports polkadot_node_is_parachain_validator is 1 within 240 secs +dave: reports polkadot_node_is_active_validator is 1 within 240 secs + +# deregister and check +alice: js-script ./0003-deregister-register-validator.js with "deregister,dave" return is 0 within 30 secs + +# Wait 2 sessions. The authority set change is enacted at curent_session + 2. +sleep 120 seconds +dave: reports polkadot_node_is_parachain_validator is 0 within 180 secs +dave: reports polkadot_node_is_active_validator is 0 within 180 secs + +# register and check +alice: js-script ./0003-deregister-register-validator.js with "register,dave" return is 0 within 30 secs + +# Wait 2 sessions. The authority set change is enacted at curent_session + 2. +sleep 120 seconds +dave: reports polkadot_node_is_parachain_validator is 1 within 180 secs +dave: reports polkadot_node_is_active_validator is 1 within 180 secs diff --git a/polkadot/zombienet_tests/smoke/0003-deregister-register-validator-smoke.toml b/polkadot/zombienet_tests/smoke/0003-deregister-register-validator-smoke.toml new file mode 100644 index 0000000000..bc1dbe6d3e --- /dev/null +++ b/polkadot/zombienet_tests/smoke/0003-deregister-register-validator-smoke.toml @@ -0,0 +1,24 @@ +[settings] +timeout = 1000 + +[relaychain] +default_image = "{{ZOMBIENET_INTEGRATION_TEST_IMAGE}}" +chain = "rococo-local" +command = "polkadot" + + [[relaychain.nodes]] + name = "alice" + args = ["-lruntime=debug,parachain=trace" ] + + [[relaychain.nodes]] + name = "bob" + args = [ "-lruntime=debug,parachain=trace" ] + + [[relaychain.nodes]] + name = "charlie" + args = [ "-lruntime=debug,parachain=trace" ] + + [[relaychain.nodes]] + name = "dave" + args = [ "-lruntime=debug,parachain=trace" ] + \ No newline at end of file diff --git a/polkadot/zombienet_tests/smoke/0003-deregister-register-validator.js b/polkadot/zombienet_tests/smoke/0003-deregister-register-validator.js new file mode 100644 index 0000000000..9963ce74d6 --- /dev/null +++ b/polkadot/zombienet_tests/smoke/0003-deregister-register-validator.js @@ -0,0 +1,46 @@ +const assert = require("assert"); + +function nameCase(string) { + return string.charAt(0).toUpperCase() + string.slice(1); +} + +async function run(nodeName, networkInfo, jsArgs) { + const {wsUri, userDefinedTypes} = networkInfo.nodesByName[nodeName]; + const api = await zombie.connect(wsUri, userDefinedTypes); + const action = jsArgs[0] === "register" ? "registerValidators" : "deregisterValidators" + const validatorName = jsArgs[1]; // used as seed + + await zombie.util.cryptoWaitReady(); + + // account to submit tx + const keyring = new zombie.Keyring({ type: "sr25519" }); + const alice = keyring.addFromUri("//Alice"); + const validatorStash = keyring.createFromUri(`//${nameCase(validatorName)}//stash`); + + await new Promise(async (resolve, reject) => { + const unsub = await api.tx.sudo + .sudo(api.tx.validatorManager[action]([validatorStash.address])) + .signAndSend(alice, (result) => { + console.log(`Current status is ${result.status}`); + if (result.status.isInBlock) { + console.log( + `Transaction included at blockHash ${result.status.asInBlock}` + ); + } else if (result.status.isFinalized) { + console.log( + `Transaction finalized at blockHash ${result.status.asFinalized}` + ); + unsub(); + return resolve(); + } else if (result.isError) { + console.log(`Transaction Error`); + unsub(); + return reject(); + } + }); + }); + + return 0; +} + +module.exports = { run }