You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
850 B
25 lines
850 B
2 years ago
|
const { HardhatError } = require('hardhat/internal/core/errors');
|
||
|
|
||
|
// Modifies `artifacts.require(X)` so that instead of X it loads the XUpgradeable contract.
|
||
|
// This allows us to run the same test suite on both the original and the transpiled and renamed Upgradeable contracts.
|
||
|
|
||
|
extendEnvironment(env => {
|
||
|
const artifactsRequire = env.artifacts.require;
|
||
|
|
||
|
env.artifacts.require = name => {
|
||
|
for (const suffix of ['UpgradeableWithInit', 'Upgradeable', '']) {
|
||
|
try {
|
||
|
return artifactsRequire(name + suffix);
|
||
|
} catch (e) {
|
||
|
// HH700: Artifact not found - from https://hardhat.org/hardhat-runner/docs/errors#HH700
|
||
|
if (HardhatError.isHardhatError(e) && e.number === 700 && suffix !== '') {
|
||
|
continue;
|
||
|
} else {
|
||
|
throw e;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
throw new Error('Unreachable');
|
||
|
};
|
||
|
});
|