Skip to content

Commit

Permalink
Add config validation for empty forking url
Browse files Browse the repository at this point in the history
  • Loading branch information
kshyun28 authored and alcuadrado committed May 17, 2024
1 parent c42b5c5 commit e65ba6c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,18 @@ export function getValidationErrors(config: any): string[] {
);
}

if (hardhatNetwork.forking !== undefined) {
if (isEmptyString(hardhatNetwork.forking.url)) {
errors.push(
getEmptyErrorMessage(
`HardhatConfig.networks.${HARDHAT_NETWORK_NAME}.forking.url`,
hardhatNetwork.forking.url,
"string"
)
);
}
}

// Validating the accounts with io-ts leads to very confusing errors messages
const { accounts, ...configExceptAccounts } = hardhatNetwork;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,30 @@ describe("Config validation", function () {
ERRORS.GENERAL.INVALID_CONFIG
);

expectHardhatError(
() =>
validateConfig({
networks: {
[HARDHAT_NETWORK_NAME]: {
forking: { url: "" },
},
},
}),
ERRORS.GENERAL.INVALID_CONFIG
);

expectHardhatError(
() =>
validateConfig({
networks: {
[HARDHAT_NETWORK_NAME]: {
forking: { url: " " },
},
},
}),
ERRORS.GENERAL.INVALID_CONFIG
);

expectHardhatError(
() =>
validateConfig({
Expand Down

0 comments on commit e65ba6c

Please sign in to comment.