Skip to content

Commit

Permalink
Merge pull request NomicFoundation#1118 from sisco0/master
Browse files Browse the repository at this point in the history
Hardhat network configuration should not contain url property
  • Loading branch information
alcuadrado committed Dec 29, 2020
2 parents 547c750 + 76c1ab1 commit fa1267e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ export function getValidationErrors(config: any): string[] {
// These can't be validated with io-ts
if (config !== undefined && typeof config.networks === "object") {
const hardhatNetwork = config.networks[HARDHAT_NETWORK_NAME];
if (hardhatNetwork !== undefined) {
if (hardhatNetwork.url !== undefined) {
if (hardhatNetwork !== undefined && typeof hardhatNetwork === "object") {
if ("url" in hardhatNetwork) {
errors.push(
`HardhatConfig.networks.${HARDHAT_NETWORK_NAME} can't have an url`
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,20 @@ describe("Config validation", function () {
assert.isEmpty(errors);
});

it("Should fail if url is set for hardhat network (undefined)", function () {
const errors = getValidationErrors({
networks: { [HARDHAT_NETWORK_NAME]: { url: undefined } },
});
assert.isNotEmpty(errors);
});

it("Should fail if url is set for hardhat network", function () {
const errors = getValidationErrors({
networks: { [HARDHAT_NETWORK_NAME]: { url: "anyurl" } },
});
assert.isNotEmpty(errors);
});

it("Shouldn't fail if no url is set for hardhat network", function () {
const errors = getValidationErrors({
networks: { [HARDHAT_NETWORK_NAME]: {} },
Expand Down

0 comments on commit fa1267e

Please sign in to comment.