Skip to content

Commit

Permalink
refactor: ♻️ Fix block arg
Browse files Browse the repository at this point in the history
  • Loading branch information
timbrinded committed Nov 27, 2024
1 parent ad8028f commit 20d326b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/cli/src/internal/commandParsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ export class LaunchCommandParser {
invariant(forkOptions.url.startsWith("http"), "Fork URL must start with http:// or https://");
this.overrideArg(`--fork-chain-from-rpc=${forkOptions.url}`);
}
if (forkOptions.blockNumber) {
this.overrideArg(`--block=${forkOptions.blockNumber}`);
if (forkOptions.blockHash) {
this.overrideArg(`--block=${forkOptions.blockHash}`);
}
if (forkOptions.stateOverridePath) {
this.overrideArg(`--fork-state-overrides=${forkOptions.stateOverridePath}`);
Expand Down
6 changes: 3 additions & 3 deletions packages/types/config_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@
"defaultForkConfig": {
"description": "BETA: Default Fork options for the node (overriden by per-test fork options)",
"properties": {
"blockNumber": {
"description": "The block number to fork from (optional)",
"type": "number"
"blockHash": {
"description": "The block hash to fork from",
"type": "string"
},
"stateOverridePath": {
"description": "The state override path (optional)",
Expand Down
4 changes: 2 additions & 2 deletions packages/types/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,9 @@ export type ForkConfig = {
*/
url: string;
/**
* The block number to fork from (optional)
* The block hash to fork from
*/
blockNumber?: number;
blockHash?: string;
/**
* The state override path (optional)
*/
Expand Down
15 changes: 15 additions & 0 deletions test/suites/fork_test/test_fork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ describeSuite({
forkConfig: {
url: "https://moonbeam.unitedbloc.com",
verbose: true,
blockHash: "0xffe39256c17cc4523a07c907bcf1aeeef4db217cd57cfcfb95d56088e0bb9f2d"
},
},
testCases: ({ it, context, log }) => {
Expand Down Expand Up @@ -43,5 +44,19 @@ describeSuite({
expect(free.toBigInt(), "Free balance should be 1337000").toBe(1337000000000000000000n);
},
});

it({
id: "T03",
title: "Check that forking works at a particular height",
test: async () => {
const testAccount = "0x0f300B667c55B28f4609EecE5628Cc27445A10cC";
log(`Address: ${testAccount}`);

const {
data: { free },
} = await polkadotJs.query.system.account(testAccount);
expect(free.toBigInt(), `Free balance should match what account ${testAccount} has at block #8508372`).toBe(76562560590695097485140n);
},
});
},
});

0 comments on commit 20d326b

Please sign in to comment.