forked from paritytech/polkadot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
squashed commits from paritytech#4639
- Loading branch information
Showing
91 changed files
with
74,604 additions
and
1,249 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Allows to manually submit extrinsic to collator. | ||
// Usage: | ||
// zombienet-linux -p native spwan 0008-parachain-extrinsic-gets-finalized.toml | ||
// node 0008-main.js <path-to-generated-tmpdir/zombie.json> | ||
|
||
global.zombie = null | ||
|
||
const fs = require('fs'); | ||
const test = require('./0008-transaction_gets_finalized.js'); | ||
|
||
if (process.argv.length == 2) { | ||
console.error('Path to zombie.json (generated by zombienet-linux spawn command shall be given)!'); | ||
process.exit(1); | ||
} | ||
|
||
let networkInfo = JSON.parse(fs.readFileSync(process.argv[2])); | ||
|
||
test.run("charlie", networkInfo).then(process.exit) |
25 changes: 25 additions & 0 deletions
25
cumulus/zombienet/tests/0008-parachain_extrinsic_gets_finalized.toml
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,25 @@ | ||
[relaychain] | ||
default_image = "{{RELAY_IMAGE}}" | ||
default_command = "polkadot" | ||
chain = "rococo-local" | ||
|
||
[[relaychain.nodes]] | ||
name = "alice" | ||
validator = true | ||
|
||
[[relaychain.nodes]] | ||
name = "bob" | ||
validator = true | ||
|
||
[[parachains]] | ||
id = 2000 | ||
cumulus_based = true | ||
chain = "asset-hub-rococo-local" | ||
|
||
# run charlie as parachain collator | ||
[[parachains.collators]] | ||
name = "charlie" | ||
validator = true | ||
image = "{{POLKADOT_PARACHAIN_IMAGE}}" | ||
command = "polkadot-parachain" | ||
args = ["--force-authoring", "-ltxpool=trace"] |
20 changes: 20 additions & 0 deletions
20
cumulus/zombienet/tests/0008-parachain_extrinsic_gets_finalized.zndsl
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,20 @@ | ||
Description: Block building | ||
Network: ./0008-parachain_extrinsic_gets_finalized.toml | ||
Creds: config | ||
|
||
alice: reports node_roles is 4 | ||
bob: reports node_roles is 4 | ||
charlie: reports node_roles is 4 | ||
|
||
alice: reports peers count is at least 1 | ||
bob: reports peers count is at least 1 | ||
|
||
alice: reports block height is at least 5 within 60 seconds | ||
bob: reports block height is at least 5 within 60 seconds | ||
charlie: reports block height is at least 2 within 120 seconds | ||
|
||
alice: count of log lines containing "error" is 0 within 2 seconds | ||
bob: count of log lines containing "error" is 0 within 2 seconds | ||
charlie: count of log lines containing "error" is 0 within 2 seconds | ||
|
||
charlie: js-script ./0008-transaction_gets_finalized.js within 600 seconds |
77 changes: 77 additions & 0 deletions
77
cumulus/zombienet/tests/0008-transaction_gets_finalized.js
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,77 @@ | ||
//based on: https://polkadot.js.org/docs/api/examples/promise/transfer-events | ||
|
||
const assert = require("assert"); | ||
|
||
async function run(nodeName, networkInfo, args) { | ||
// console.log('xxxxxxxxxxx 1'); | ||
const {wsUri, userDefinedTypes} = networkInfo.nodesByName[nodeName]; | ||
// console.log('xxxxxxxxxxx 2'); | ||
// Create the API and wait until ready | ||
var api = null; | ||
var keyring = null; | ||
if (zombie == null) { | ||
const testKeyring = require('@polkadot/keyring/testing'); | ||
const { WsProvider, ApiPromise } = require('@polkadot/api'); | ||
const provider = new WsProvider(wsUri); | ||
api = await ApiPromise.create({provider}); | ||
// Construct the keyring after the API (crypto has an async init) | ||
keyring = testKeyring.createTestKeyring({ type: "sr25519" }); | ||
} else { | ||
keyring = new zombie.Keyring({ type: "sr25519" }); | ||
// console.log('xxxxxxxxxxx 3'); | ||
api = await zombie.connect(wsUri, userDefinedTypes); | ||
// console.log('xxxxxxxxxxx 4'); | ||
} | ||
|
||
|
||
// Add Alice to our keyring with a hard-derivation path (empty phrase, so uses dev) | ||
const alice = keyring.addFromUri('//Alice'); | ||
// console.log('xxxxxxxxxxx 5'); | ||
|
||
// Create a extrinsic: | ||
const extrinsic = api.tx.system.remark("xxx"); | ||
// console.log('xxxxxxxxxxx 6'); | ||
|
||
let extrinsic_success_event = false; | ||
try { | ||
// console.log('xxxxxxxxxxx 7'); | ||
await new Promise( async (resolve, reject) => { | ||
const unsubscribe = await extrinsic | ||
.signAndSend(alice, { nonce: -1 }, ({ events = [], status }) => { | ||
console.log('Extrinsic status:', status.type); | ||
|
||
if (status.isInBlock) { | ||
console.log('Included at block hash', status.asInBlock.toHex()); | ||
console.log('Events:'); | ||
|
||
events.forEach(({ event: { data, method, section }, phase }) => { | ||
console.log('\t', phase.toString(), `: ${section}.${method}`, data.toString()); | ||
|
||
if (section=="system" && method =="ExtrinsicSuccess") { | ||
extrinsic_success_event = true; | ||
} | ||
}); | ||
} else if (status.isFinalized) { | ||
console.log('Finalized block hash', status.asFinalized.toHex()); | ||
unsubscribe(); | ||
if (extrinsic_success_event) { | ||
resolve(); | ||
} else { | ||
reject("ExtrinsicSuccess has not been seen"); | ||
} | ||
} else if (status.isError) { | ||
unsubscribe(); | ||
reject("Extrinsic status.isError"); | ||
} | ||
|
||
}); | ||
}); | ||
// console.log('xxxxxxxxxxx 8'); | ||
} catch (error) { | ||
assert.fail("Transfer promise failed, error: " + error); | ||
} | ||
|
||
assert.ok("test passed"); | ||
} | ||
|
||
module.exports = { run } |
Oops, something went wrong.