Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
wirednkod committed Sep 29, 2023
1 parent ae49806 commit de57d78
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .zombienet-tests/0002-check-storage.zndsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Creds: config

alice: is up
bob: is up
alice: ts-script ./0002-check-storage.ts with "alice" return is 1000000000000000000 within 200 seconds
alice: ts-script ./0002-checkStorage.ts with "alice" return is 1000000000000000000 within 200 seconds
File renamed without changes.
17 changes: 17 additions & 0 deletions .zombienet-tests/0003-call-head.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[settings]
timeout = 240000

[relaychain]
default_image = "parity/polkadot:latest"
chain = "rococo-local"
default_command = "polkadot"

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

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

9 changes: 9 additions & 0 deletions .zombienet-tests/0003-call-head.zndsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Description: Relay Chain Smoke Test
Network: ./0003-call-head.toml
Creds: config

alice: is up
bob: is up
alice: reports block height is at least 5 within 120 seconds
alice: reports finalised height is at least 2 within 120 seconds
bob: ts-script ./0003-checallHead.ts within 140 seconds
39 changes: 39 additions & 0 deletions .zombienet-tests/0003-callHead.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Tuple, compact, metadata } from "../packages/substrate-bindings/dist"
import { getDynamicBuilder } from "../packages/substrate-codegen/dist"
import { connect } from "./utils"
import { BigNumber } from "bignumber.js"

const ALICE = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"

export async function run(_nodeName: string, networkInfo: any) {
const { chainHead } = await connect(networkInfo)

const opaqueMeta = Tuple(compact, metadata)

let count = 0

await new Promise(async (resolve, reject) => {
let requested = false
const chainHeadFollower = chainHead(
true,
async (event) => {
if (event.type === "newBlock") {
chainHeadFollower.unpin([event.blockHash])
return
}
if (requested || event.type !== "initialized") return
const latestFinalized = event.finalizedBlockHash

// Call metadata
let response = await chainHeadFollower.header(latestFinalized)

console.log("response", response)

// if (1 === 1) {
resolve(chainHeadFollower.unfollow())
// }
},
reject,
)
})
}

0 comments on commit de57d78

Please sign in to comment.