@openzeppelin/upgrade-safe-transpiler
Version:
Solidity preprocessor used to generate OpenZeppelin Contracts Upgrade Safe.
45 lines • 2.02 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const ava_1 = __importDefault(require("ava"));
const hardhat_1 = __importDefault(require("hardhat"));
const path_1 = __importDefault(require("path"));
const get_build_info_1 = require("./test-utils/get-build-info");
const _1 = require(".");
const test = ava_1.default;
const projectDir = 'contracts/project';
const peerProject = '@openzeppelin/test/..';
test.serial.before('compile', async (t) => {
const buildInfo = await (0, get_build_info_1.getBuildInfo)('0.8');
const solcInput = buildInfo.input;
const solcOutput = buildInfo.output;
const exclude = Object.keys(solcOutput.sources).filter(path => !path.startsWith(projectDir));
t.context.inputs = Object.keys(solcInput.sources);
t.context.files = await (0, _1.transpile)(solcInput, solcOutput, hardhat_1.default.config.paths, {
exclude,
peerProject,
});
});
for (const fileName of ['ISomeInterface.sol', 'SomeLibrary.sol', 'SomeStatelessContract.sol']) {
test(`do not transpile ${fileName}`, t => {
const file = t.context.files.find(f => f.fileName === fileName);
// source file exists
t.true(t.context.inputs.includes(path_1.default.join(projectDir, fileName)));
// transpiled file does not exist
t.is(file, undefined, 'file should not be transpiled');
});
}
for (const fileName of ['SomeContract.sol', 'SomeOtherContract.sol']) {
test(`transpile ${fileName}`, t => {
const file = t.context.files.find(f => f.fileName === fileName);
// source file exists
t.true(t.context.inputs.includes(path_1.default.join(projectDir, fileName)));
// transpiled file exists
t.not(file, undefined, 'file not found');
// snapshot
t.snapshot(file);
});
}
//# sourceMappingURL=prepare-peer-project.test.js.map