UNPKG

@solvprotocol/upgrade-safe-transpiler

Version:

Solidity preprocessor used to generate OpenZeppelin Contracts Upgrade Safe.

54 lines 2.93 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 rename_identifiers_1 = require("./transformations/rename-identifiers"); const remove_immutable_1 = require("./transformations/remove-immutable"); const purge_var_inits_1 = require("./transformations/purge-var-inits"); const transform_constructor_1 = require("./transformations/transform-constructor"); const rename_inheritdoc_1 = require("./transformations/rename-inheritdoc"); const add_storage_gaps_1 = require("./transformations/add-storage-gaps"); const rename_contract_definition_1 = require("./transformations/rename-contract-definition"); const test = ava_1.default; test.serial.before('compile', async (t) => { const buildInfo = await (0, get_build_info_1.getBuildInfo)('0.8'); t.context.solcInput = buildInfo.input; t.context.solcOutput = buildInfo.output; }); test.beforeEach('transform', async (t) => { t.context.transform = new transform_1.Transform(t.context.solcInput, t.context.solcOutput); }); test('rename parents in solidity 0.8', t => { const file = 'contracts/rename-0.8.sol'; t.context.transform.apply(rename_identifiers_1.renameIdentifiers); t.context.transform.apply(rename_inheritdoc_1.renameInheritdoc); t.snapshot(t.context.transform.results()[file]); }); test('correctly index when utf8 characters', t => { const file = 'contracts/TransformUtf8Chars.sol'; t.context.transform.apply(rename_identifiers_1.renameIdentifiers); t.context.transform.apply(rename_contract_definition_1.renameContractDefinition); t.snapshot(t.context.transform.results()[file]); }); test('preserves immutable if allowed', t => { const file = 'contracts/TransformAllowedImmutable.sol'; t.context.transform.apply(transform_constructor_1.transformConstructor); t.context.transform.apply(transform_constructor_1.removeLeftoverConstructorHead); t.context.transform.apply(purge_var_inits_1.removeStateVarInits); t.context.transform.apply(remove_immutable_1.removeImmutable); t.snapshot(t.context.transform.results()[file]); }); test('custom contract size', t => { const file = 'contracts/TransformCustomSize.sol'; t.context.transform.apply(transform_constructor_1.transformConstructor); t.context.transform.apply(transform_constructor_1.removeLeftoverConstructorHead); t.context.transform.apply(purge_var_inits_1.removeStateVarInits); t.context.transform.apply(remove_immutable_1.removeImmutable); t.context.transform.apply(add_storage_gaps_1.addStorageGaps); t.snapshot(t.context.transform.results()[file]); }); //# sourceMappingURL=transform-0.8.test.js.map