Skip to content

Commit

Permalink
Hardhat network configuration should not contain url property
Browse files Browse the repository at this point in the history
Modified conditional clause for disallowing undefined url property of Hardhat network at the networks configuration object
  • Loading branch information
sisco0 committed Dec 20, 2020
1 parent eab324a commit 7b9601e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export function getValidationErrors(config: any): string[] {
if (config !== undefined && typeof config.networks === "object") {
const hardhatNetwork = config.networks[HARDHAT_NETWORK_NAME];
if (hardhatNetwork !== undefined) {
if (hardhatNetwork.url !== undefined) {
if (hardhatNetwork.hasOwnProperty("url")) {
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 7b9601e

Please sign in to comment.