-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test to validate HTTP headers (#710)
* 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
Showing
13 changed files
with
72 additions
and
223 deletions.
There are no files selected for viewing
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
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
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
53 changes: 53 additions & 0 deletions
53
hardhat-tests/test/internal/hardhat-network/provider/http-headers.ts
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,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); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
27 changes: 0 additions & 27 deletions
27
...nal/hardhat-network/stack-traces/test-files/0_5/console-logs/backward-compatibility/c.sol
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
...hardhat-network/stack-traces/test-files/0_5/console-logs/backward-compatibility/test.json
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
...nal/hardhat-network/stack-traces/test-files/0_6/console-logs/backward-compatibility/c.sol
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
...hardhat-network/stack-traces/test-files/0_6/console-logs/backward-compatibility/test.json
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
...nal/hardhat-network/stack-traces/test-files/0_7/console-logs/backward-compatibility/c.sol
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
...hardhat-network/stack-traces/test-files/0_7/console-logs/backward-compatibility/test.json
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
...nal/hardhat-network/stack-traces/test-files/0_8/console-logs/backward-compatibility/c.sol
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
...hardhat-network/stack-traces/test-files/0_8/console-logs/backward-compatibility/test.json
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.