-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix runtime upgrade test by using governance instead of SUDO (#924)
* Migrate runtime-upgrade test to mocha Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Bump spec-version for test Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Add trigger Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * use wget properlt to download last release binary Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Fix missing config-for-runtime-upgrade-test Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Fix directory Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * CLean up Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Fix test Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Get rid of testnet-ci chain-specs Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Use object for referendumIndex Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Use object for referendumIndex Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Use object for referendumIndex Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Clean up Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Clean up Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Check Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Check Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Check Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Check Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Check Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Check Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Check Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Fix runtime upgrade code Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Clean up Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Clean up Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Clean up Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Update all ci workflows Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Update all ci workflows Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Increase wait time Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Bump timeout Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Bump timeout Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Switch to -local Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Upload 9921 log Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Update runtime-upgrade resource Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Remove unused code Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Check block production in mocha test Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * Revert spec_version bumps that were for testing only Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> * fix duplicate line Signed-off-by: Charles Ferrell <charlie@manta.network> Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network> Signed-off-by: Charles Ferrell <charlie@manta.network> Co-authored-by: Charles Ferrell <charlie@manta.network> Co-authored-by: Adam Reif <garandor@manta.network> Signed-off-by: Charles Ferrell <charlie@manta.network>
- Loading branch information
1 parent
d55dad6
commit 6afddf2
Showing
14 changed files
with
114 additions
and
525 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { ApiPromise, WsProvider } from '@polkadot/api'; | ||
import { Keyring } from '@polkadot/keyring'; | ||
import { manta_pay_types, rpc_api } from './types'; | ||
import {execute_with_root_via_governance } from './manta_pay'; | ||
import { delay } from './test-util'; | ||
import { assert } from 'chai'; | ||
import minimist, { ParsedArgs } from 'minimist'; | ||
import { blake2AsHex } from "@polkadot/util-crypto"; | ||
import * as fs from 'fs'; | ||
|
||
const test_config = { | ||
ws_address: "ws://127.0.0.1:9800", | ||
mnemonic: 'bottom drive obey lake curtain smoke basket hold race lonely fit walk//Alice', | ||
timeout: 2000000 | ||
} | ||
|
||
describe('Node RPC Test', () => { | ||
it('Check RPC result', async () => { | ||
|
||
let nodeAddress = ""; | ||
const args: ParsedArgs = minimist(process.argv.slice(2)); | ||
if (args["address"] == null) { | ||
nodeAddress = test_config.ws_address; | ||
} else { | ||
nodeAddress = args["address"]; | ||
} | ||
console.log("using address %s", nodeAddress); | ||
|
||
const wsProvider = new WsProvider(nodeAddress); | ||
const api = await ApiPromise.create({ | ||
provider: wsProvider, | ||
types: manta_pay_types, | ||
rpc: rpc_api}); | ||
const keyring = new Keyring({ type: 'sr25519' }); | ||
const aliceKeyPair = keyring.addFromMnemonic(test_config.mnemonic); | ||
|
||
const oldRuntimeVersion = await api.rpc.state.getRuntimeVersion(); | ||
const oldSpecVersion = oldRuntimeVersion["specVersion"]; | ||
|
||
const code = fs.readFileSync('calamari.wasm').toString('hex'); | ||
let codeHash = blake2AsHex(`0x${code}`); | ||
const authorizeUpgradeCallData = api.tx.parachainSystem.authorizeUpgrade(codeHash); | ||
var referendumIndexObject = { referendumIndex: 0 }; | ||
execute_with_root_via_governance(api, aliceKeyPair, authorizeUpgradeCallData, referendumIndexObject); | ||
await delay(60000); | ||
api.tx.parachainSystem.enactAuthorizedUpgrade(`0x${code}`).signAndSend(aliceKeyPair, {nonce: -1}); | ||
await delay(120000); | ||
|
||
let newRuntimeVersions = await api.rpc.state.getRuntimeVersion(); | ||
const newSpecVersion = newRuntimeVersions["specVersion"]; | ||
assert(newSpecVersion > oldSpecVersion); | ||
|
||
let blockNow = await api.rpc.chain.getBlock(); | ||
let blockNumberNow = blockNow.block.header.number; | ||
await delay(60000); | ||
let blockLater = await api.rpc.chain.getBlock(); | ||
let blockNumberLater = blockLater.block.header.number; | ||
assert(blockNumberLater > blockNumberNow); | ||
|
||
api.disconnect(); | ||
}).timeout(test_config.timeout); | ||
}); |