forked from polkadot-api/polkadot-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
66 additions
and
1 deletion.
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
File renamed without changes.
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,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 | ||
|
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,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 |
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,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, | ||
) | ||
}) | ||
} |