-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(chain spec mutator): test components + add to CI
- Loading branch information
Showing
5 changed files
with
82 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[relaychain] | ||
default_image = "docker.io/parity/polkadot:latest" | ||
default_command = "polkadot" | ||
default_args = [ "-lparachain=debug" ] | ||
chain = "rococo-local" | ||
|
||
chain_spec_modifier_commands = [[ | ||
"./change-name-in-chain-spec.sh", | ||
"{{'plain'|chainSpec}}", | ||
]] | ||
|
||
[[relaychain.nodes]] | ||
name = "alice" | ||
validator = true | ||
|
||
[[relaychain.nodes]] | ||
name = "bob" | ||
validator = true |
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,10 @@ | ||
Description: Chain Spec Modification | ||
Network: ./0014-chain-spec-modification.toml | ||
Creds: config | ||
|
||
|
||
alice: is up | ||
bob: is up | ||
alice: log line matches "Imported #[0-9]+" within 10 seconds | ||
|
||
alice: js-script ./check-testnet-name.js with "Tentset Lacol Ococor" return is true |
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,11 @@ | ||
#!/bin/bash | ||
|
||
# The first argument sent to the script must be the path of the chain spec | ||
chain_spec_path = $1 | ||
# Assume that the name | ||
old_name="Rococo Local Testnet" | ||
# Set the new name for the network | ||
new_name="Tentset Lacol Ococor" | ||
|
||
# Replace the name field in the JSON file | ||
sed -i "s/\"name\": \"$old_name\"/\"name\": \"$new_name\"/" $chain_spec_path |
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,12 @@ | ||
// Check if the testnet's name is the same as the expected name from the args | ||
async function run(nodeName, networkInfo, args) { | ||
const {wsUri, userDefinedTypes} = networkInfo.nodesByName[nodeName]; | ||
const api = await zombie.connect(wsUri, userDefinedTypes); | ||
|
||
const expectedName = args[0] ?? "Rococo Local Testnet"; | ||
const testnetName = await api.rpc.system.chain(); | ||
|
||
return testnetName == expectedName; | ||
} | ||
|
||
module.exports = { run } |