UNPKG

@openzeppelin/upgrade-safe-transpiler

Version:

Solidity preprocessor used to generate OpenZeppelin Contracts Upgrade Safe.

39 lines 1.99 kB
"use strict"; 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 get_build_info_1 = require("./test-utils/get-build-info"); const transform_1 = require("./transform"); const purge_var_inits_1 = require("./transformations/purge-var-inits"); const add_namespace_struct_1 = require("./transformations/add-namespace-struct"); const transform_constructor_1 = require("./transformations/transform-constructor"); const test = ava_1.default; test.serial.before('compile', async (t) => { const buildInfo = await (0, get_build_info_1.getBuildInfo)('0.8.20'); t.context.solcInput = buildInfo.input; t.context.solcOutput = buildInfo.output; }); test.beforeEach('transform', async (t) => { t.context.transformFile = (file) => new transform_1.Transform(t.context.solcInput, t.context.solcOutput, { exclude: source => source !== file, }); }); test('add namespace', t => { const file = 'contracts/namespaces.sol'; const transform = t.context.transformFile(file); transform.apply((0, transform_constructor_1.transformConstructor)(() => true)); transform.apply(transform_constructor_1.removeLeftoverConstructorHead); transform.apply(purge_var_inits_1.removeStateVarInits); transform.apply((0, add_namespace_struct_1.addNamespaceStruct)(() => true)); t.snapshot(transform.results()[file]); }); test('error with @custom:storage-size', t => { const file = 'contracts/namespaces-error-storage-size.sol'; const transform = t.context.transformFile(file); t.throws(() => transform.apply((0, add_namespace_struct_1.addNamespaceStruct)(() => true)), { message: 'Cannot combine namespaces with @custom:storage-size annotations (contracts/namespaces-error-storage-size.sol:5)', }); }); //# sourceMappingURL=transform-namespaces.test.js.map