-
Notifications
You must be signed in to change notification settings - Fork 383
add a smoke test to verify fix for the invalid parent hash in moonbase #2276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f60ee77
add a smoke test to verify fix for the invalid parent hash in moonbase
nbaztec caa2fda
make smoke test generic for current blocks as well
nbaztec c26412a
fixes
nbaztec 9f512b2
Merge branch 'master' into nish-smoke-test-parent-hash-fix
nbaztec File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,76 @@ | ||
| import "@moonbeam-network/api-augment"; | ||
| import { ApiDecoration } from "@polkadot/api/types"; | ||
| import chalk from "chalk"; | ||
| import { expect } from "chai"; | ||
| import { describeSmokeSuite } from "../util/setup-smoke-tests"; | ||
|
|
||
| const debug = require("debug")("smoke:ethereum-contract"); | ||
|
|
||
| describeSmokeSuite("S570", `RPC Eth ParentHash`, async function (context, testIt) { | ||
| let atBlockNumber: number = 0; | ||
| let previousBlockNumber: number = 0; | ||
| let apiAt: ApiDecoration<"promise"> = null; | ||
| let apiAtPrevious: ApiDecoration<"promise"> = null; | ||
|
|
||
| before("configure api at block", async function () { | ||
| this.timeout(6_000_000); // 30 minutes | ||
|
|
||
| atBlockNumber = (await context.polkadotApi.rpc.chain.getHeader()).number.toNumber(); | ||
| previousBlockNumber = atBlockNumber - 1; | ||
| apiAt = await context.polkadotApi.at( | ||
| await context.polkadotApi.rpc.chain.getBlockHash(atBlockNumber) | ||
| ); | ||
| apiAtPrevious = await context.polkadotApi.at( | ||
| await context.polkadotApi.rpc.chain.getBlockHash(atBlockNumber - 1) | ||
| ); | ||
| }); | ||
|
|
||
| testIt("C100", `should return correct parent hash via rpc for current block`, async function () { | ||
| const rpcParentHash = ( | ||
| await context.polkadotApi.rpc.eth.getBlockByNumber(atBlockNumber, false) | ||
| ).unwrap().parentHash; | ||
| const storedParentHash = ((await apiAt.query.ethereum.currentBlock()).unwrap() as any).header | ||
| .parentHash; | ||
|
|
||
| const actualParentHash = ( | ||
| await context.polkadotApi.rpc.eth.getBlockByNumber(previousBlockNumber, false) | ||
| ).unwrap().blockHash; | ||
| expect(storedParentHash.isEmpty, "stored parentHash was empty").to.be.false; | ||
| expect(rpcParentHash.toString()).to.equal(actualParentHash.toString()); | ||
|
|
||
| debug( | ||
| `Verified ethereum parentHash ${rpcParentHash} for block #${atBlockNumber} \ | ||
| (at #${atBlockNumber})` | ||
| ); | ||
| }); | ||
|
|
||
| testIt("C100", `should return correct parent hash via rpc for block #1648995`, async function () { | ||
|
crystalin marked this conversation as resolved.
Outdated
|
||
| const badBlockNumber = 1648995; | ||
| const apiAtBadBlock = await context.polkadotApi.at( | ||
| await context.polkadotApi.rpc.chain.getBlockHash(badBlockNumber) | ||
| ); | ||
|
|
||
| const specName = context.polkadotApi.consts.system.version.specName.toString(); | ||
| if (specName !== "moonbase") { | ||
| debug(`Test only applies for "moonbase", skipping for "${specName}"`); | ||
| this.skip(); | ||
| } | ||
|
|
||
| const rpcParentHash = ( | ||
| await context.polkadotApi.rpc.eth.getBlockByNumber(badBlockNumber, false) | ||
| ).unwrap().parentHash; | ||
| const storedParentHash = ((await apiAtBadBlock.query.ethereum.currentBlock()).unwrap() as any) | ||
| .header.parentHash; | ||
|
|
||
| // The stored parentHash is zero-value due to a missing migration in RT1200. | ||
| expect(storedParentHash.isEmpty, "stored parentHash was not empty").to.be.true; | ||
| expect(rpcParentHash.toString()).to.equal( | ||
| "0x0d0fd88778aec08b3a83ce36387dbf130f6f304fc91e9a44c9605eaf8a80ce5d" | ||
| ); | ||
|
|
||
| debug( | ||
| `Verified ethereum parentHash ${rpcParentHash} for block #${badBlockNumber} in moonbase \ | ||
| (at #${atBlockNumber})` | ||
| ); | ||
| }); | ||
| }); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.