Skip to content

Commit e65ba6c

Browse files
kshyun28alcuadrado
authored andcommitted
Add config validation for empty forking url
1 parent c42b5c5 commit e65ba6c

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

packages/hardhat-core/src/internal/core/config/config-validation.ts

+12
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,18 @@ export function getValidationErrors(config: any): string[] {
401401
);
402402
}
403403

404+
if (hardhatNetwork.forking !== undefined) {
405+
if (isEmptyString(hardhatNetwork.forking.url)) {
406+
errors.push(
407+
getEmptyErrorMessage(
408+
`HardhatConfig.networks.${HARDHAT_NETWORK_NAME}.forking.url`,
409+
hardhatNetwork.forking.url,
410+
"string"
411+
)
412+
);
413+
}
414+
}
415+
404416
// Validating the accounts with io-ts leads to very confusing errors messages
405417
const { accounts, ...configExceptAccounts } = hardhatNetwork;
406418

packages/hardhat-core/test/internal/core/config/config-validation.ts

+24
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,30 @@ describe("Config validation", function () {
857857
ERRORS.GENERAL.INVALID_CONFIG
858858
);
859859

860+
expectHardhatError(
861+
() =>
862+
validateConfig({
863+
networks: {
864+
[HARDHAT_NETWORK_NAME]: {
865+
forking: { url: "" },
866+
},
867+
},
868+
}),
869+
ERRORS.GENERAL.INVALID_CONFIG
870+
);
871+
872+
expectHardhatError(
873+
() =>
874+
validateConfig({
875+
networks: {
876+
[HARDHAT_NETWORK_NAME]: {
877+
forking: { url: " " },
878+
},
879+
},
880+
}),
881+
ERRORS.GENERAL.INVALID_CONFIG
882+
);
883+
860884
expectHardhatError(
861885
() =>
862886
validateConfig({

0 commit comments

Comments
 (0)