TransparentUpgradeableProxy.test.js 1019 B

123456789101112131415161718192021222324
  1. const shouldBehaveLikeProxy = require('../Proxy.behaviour');
  2. const shouldBehaveLikeTransparentUpgradeableProxy = require('./TransparentUpgradeableProxy.behaviour');
  3. const TransparentUpgradeableProxy = artifacts.require('TransparentUpgradeableProxy');
  4. const ITransparentUpgradeableProxy = artifacts.require('ITransparentUpgradeableProxy');
  5. contract('TransparentUpgradeableProxy', function (accounts) {
  6. const [owner, ...otherAccounts] = accounts;
  7. // `undefined`, `null` and other false-ish opts will not be forwarded.
  8. const createProxy = async function (logic, initData, opts = undefined) {
  9. const { address, transactionHash } = await TransparentUpgradeableProxy.new(
  10. logic,
  11. owner,
  12. initData,
  13. ...[opts].filter(Boolean),
  14. );
  15. const instance = await ITransparentUpgradeableProxy.at(address);
  16. return { ...instance, transactionHash };
  17. };
  18. shouldBehaveLikeProxy(createProxy, otherAccounts);
  19. shouldBehaveLikeTransparentUpgradeableProxy(createProxy, owner, otherAccounts);
  20. });