Files
openzeppelin-contracts/test/proxy/transparent/TransparentUpgradeableProxy.test.js
Ernesto García 121be5dd09 Make TransparentUpgradeableProxy deploy its ProxyAdmin and optimize proxy interfaces (#4382)
Co-authored-by: Francisco <fg@frang.io>
Co-authored-by: Eric Lau <ericglau@outlook.com>
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
2023-07-13 19:25:22 -03:00

25 lines
1019 B
JavaScript

const shouldBehaveLikeProxy = require('../Proxy.behaviour');
const shouldBehaveLikeTransparentUpgradeableProxy = require('./TransparentUpgradeableProxy.behaviour');
const TransparentUpgradeableProxy = artifacts.require('TransparentUpgradeableProxy');
const ITransparentUpgradeableProxy = artifacts.require('ITransparentUpgradeableProxy');
contract('TransparentUpgradeableProxy', function (accounts) {
const [owner, ...otherAccounts] = accounts;
// `undefined`, `null` and other false-ish opts will not be forwarded.
const createProxy = async function (logic, initData, opts = undefined) {
const { address, transactionHash } = await TransparentUpgradeableProxy.new(
logic,
owner,
initData,
...[opts].filter(Boolean),
);
const instance = await ITransparentUpgradeableProxy.at(address);
return { ...instance, transactionHash };
};
shouldBehaveLikeProxy(createProxy, otherAccounts);
shouldBehaveLikeTransparentUpgradeableProxy(createProxy, owner, otherAccounts);
});