Skip to content

Commit

Permalink
test: add test to validate HTTP headers (#710)
Browse files Browse the repository at this point in the history
* test: add test to validate HTTP headers

* build: bump Hardhat to v2.22.15

* fix: remove console.log backwards compatibility tests

This was already done in Hardhat in this PR:
NomicFoundation/hardhat#5764
  • Loading branch information
Wodann authored Oct 28, 2024
1 parent 498d007 commit e995977
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 223 deletions.
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.

0 comments on commit e995977

Please sign in to comment.