Skip to content

Commit

Permalink
e2e native fee payment check
Browse files Browse the repository at this point in the history
  • Loading branch information
Szegoo committed Apr 17, 2024
1 parent 38258dd commit 7eb5809
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 7 deletions.
7 changes: 0 additions & 7 deletions zombienet_tests/0001-smoke-test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ timeout = 1000


[relaychain]
default_image = "{{POLKADOT_IMAGE}}"
chain = "rococo-local"
command = "polkadot"

Expand All @@ -21,11 +20,5 @@ addToGenesis = false

[parachains.collator]
name = "regionx-collator01"
image = "{{REGIONX_IMAGE}}"
command = "regionx-node"
args = [ "-lruntime=debug,parachain=trace" ]

[types.Header]
number = "u64"
parent_hash = "Hash"
post_state = "Hash"
23 changes: 23 additions & 0 deletions zombienet_tests/0002-native-fee-payment-test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[settings]
timeout = 1000

[relaychain]
chain = "rococo-local"
command = "polkadot"

[[relaychain.nodes]]
name = "alice"
validator = true

[[relaychain.nodes]]
name = "bob"
validator = true

[[parachains]]
id = 2000
addToGenesis = false

[parachains.collator]
name = "regionx-collator01"
command = "regionx-node"
args = [ "-lruntime=debug,parachain=trace" ]
10 changes: 10 additions & 0 deletions zombienet_tests/0002-native-fee-payment-test.zndsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Description: Native currency fee payment
Network: ./0002-native-fee-payment-test.toml
Creds: config

alice: is up
bob: is up

alice: parachain 2000 is registered within 225 seconds

regionx-collator01: js-script ./0002-native-transfer.js return is 0 within 200 seconds
40 changes: 40 additions & 0 deletions zombienet_tests/0002-native-transfer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const BOB = "5HpG9w8EBLe5XCrbczpwq5TSXvedjrBGCwqxK1iQ7qUsSWFc";

async function run(nodeName, networkInfo, _jsArgs) {
const { wsUri, userDefinedTypes } = networkInfo.nodesByName[nodeName];
const api = await zombie.connect(wsUri, userDefinedTypes);

await zombie.util.cryptoWaitReady();

// account to submit tx
const keyring = new zombie.Keyring({ type: "sr25519" });
const alice = keyring.addFromUri("//Alice");

const call = api.tx.balances.transferKeepAlive(BOB, 10n**6n);
const sudo = api.tx.sudo.sudo(call);

await new Promise(async (resolve, reject) => {
const unsub = await sudo.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 resolve();
}
});
});

return 0;
}

module.exports = { run };

0 comments on commit 7eb5809

Please sign in to comment.