Skip to content
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

test: add test to validate HTTP headers #710

Merged
merged 3 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/tools/js/benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"eslint-plugin-import": "2.27.5",
"eslint-plugin-mocha": "10.4.1",
"eslint-plugin-prettier": "5.2.1",
"hardhat": "2.22.12",
"hardhat": "2.22.15",
"lodash": "^4.17.11",
"mocha": "^10.0.0",
"prettier": "^3.2.5",
Expand Down
2 changes: 1 addition & 1 deletion hardhat-tests/integration/smock/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@types/node": "^20.0.0",
"chai": "^4.3.6",
"ethers": "5.7.2",
"hardhat": "2.22.12",
"hardhat": "2.22.15",
"mocha": "^10.0.0"
},
"keywords": [],
Expand Down
2 changes: 1 addition & 1 deletion hardhat-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"ethereumjs-abi": "^0.6.8",
"ethers": "^6.1.0",
"fs-extra": "^7.0.1",
"hardhat": "2.22.12",
"hardhat": "2.22.15",
"mocha": "^10.0.0",
"prettier": "^3.2.5",
"rimraf": "^3.0.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { assert } from "chai";

import { rpcQuantityToNumber } from "hardhat/internal/core/jsonrpc/types/base-types";
import { workaroundWindowsCiFailures } from "../../../utils/workaround-windows-ci-failures";
import { setCWD } from "../helpers/cwd";
import { FORKED_PROVIDERS } from "../helpers/providers";

describe("Forking with HTTP headers", function () {
FORKED_PROVIDERS.forEach(({ rpcProvider, jsonRpcUrl, useProvider }) => {
workaroundWindowsCiFailures.call(this, { isFork: true });

let url: string;
let bearerToken: string;
const bearerTokenSeparatorIndex = jsonRpcUrl.lastIndexOf("/");
if (bearerTokenSeparatorIndex !== -1) {
url = jsonRpcUrl.substring(0, bearerTokenSeparatorIndex);
bearerToken = jsonRpcUrl.substring(bearerTokenSeparatorIndex + 1);
}

describe(`Using ${rpcProvider}`, function () {
setCWD();

this.beforeAll(function () {
// Skip infura because it doesn't support an API key-based bearer token
if (rpcProvider === "Infura") {
this.skip();
}

// Skip invalid URLs
if (url === undefined || bearerToken === undefined) {
this.skip();
}
});

describe("With API key in HTTP headers", function () {
useProvider({
forkConfig: {
jsonRpcUrl: url,
httpHeaders: {
Authorization: `Bearer ${bearerToken}`,
},
},
});

it("Complete JSON-RPC request", async function () {
const blockNumber = await this.provider.send("eth_blockNumber");
const minBlockNumber = 10494745; // mainnet block number at 20.07.2020
assert.isAtLeast(rpcQuantityToNumber(blockNumber), minBlockNumber);
});
});
});
});
});

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

32 changes: 16 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading