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
8 changed files
with
59 additions
and
113 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,52 @@ | ||
import { connect } from "./utils" | ||
|
||
export async function run(_nodeName: string, networkInfo: any) { | ||
const { chainHead } = await connect(networkInfo) | ||
|
||
let initialized = false | ||
|
||
let finalizedCount = 0 | ||
let finalized = false | ||
|
||
let newBlockCount = 0 | ||
let newBlock = false | ||
|
||
let bestBlockCount = 0 | ||
let bestBlock = false | ||
|
||
await new Promise((resolve, reject) => { | ||
let requested = false | ||
const chainHeadFollower = chainHead( | ||
true, | ||
(event) => { | ||
console.log("event", event.type) | ||
|
||
if (event.type === "newBlock" && ++newBlockCount === 2) { | ||
chainHeadFollower.unpin([event.blockHash]) | ||
newBlock = true | ||
return | ||
} | ||
|
||
if (initialized || event.type === "initialized") { | ||
initialized = true | ||
return | ||
} | ||
|
||
if (event.type === "finalized" && ++finalizedCount === 2) { | ||
finalized = true | ||
} | ||
|
||
if (event.type === "bestBlockChanged" && ++bestBlockCount === 5) { | ||
bestBlock = true | ||
} | ||
|
||
if (finalized && newBlock && bestBlock) { | ||
resolve(chainHeadFollower.unfollow()) | ||
} else { | ||
return | ||
} | ||
}, | ||
reject, | ||
) | ||
}) | ||
} |
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,7 @@ | ||
Description: Simple Parachain Smoke Test | ||
Network: ./0003-check-events.toml | ||
Creds: config | ||
|
||
alice: is up | ||
bob: is up | ||
alice: ts-script ./0003-check-events.ts within 200 seconds |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.