Make Ownable's initial owner explicit (#4267)
Co-authored-by: Ernesto García <ernestognw@gmail.com>
This commit is contained in:
@ -11,7 +11,7 @@ const BadBeaconNoImpl = artifacts.require('BadBeaconNoImpl');
|
||||
const BadBeaconNotContract = artifacts.require('BadBeaconNotContract');
|
||||
|
||||
contract('BeaconProxy', function (accounts) {
|
||||
const [anotherAccount] = accounts;
|
||||
const [upgradeableBeaconAdmin, anotherAccount] = accounts;
|
||||
|
||||
describe('bad beacon is not accepted', async function () {
|
||||
it('non-contract beacon', async function () {
|
||||
@ -49,7 +49,7 @@ contract('BeaconProxy', function (accounts) {
|
||||
});
|
||||
|
||||
beforeEach('deploy beacon', async function () {
|
||||
this.beacon = await UpgradeableBeacon.new(this.implementationV0.address);
|
||||
this.beacon = await UpgradeableBeacon.new(this.implementationV0.address, upgradeableBeaconAdmin);
|
||||
});
|
||||
|
||||
it('no initialization', async function () {
|
||||
@ -81,7 +81,7 @@ contract('BeaconProxy', function (accounts) {
|
||||
});
|
||||
|
||||
it('upgrade a proxy by upgrading its beacon', async function () {
|
||||
const beacon = await UpgradeableBeacon.new(this.implementationV0.address);
|
||||
const beacon = await UpgradeableBeacon.new(this.implementationV0.address, upgradeableBeaconAdmin);
|
||||
|
||||
const value = '10';
|
||||
const data = this.implementationV0.contract.methods.initializeNonPayableWithValue(value).encodeABI();
|
||||
@ -96,7 +96,7 @@ contract('BeaconProxy', function (accounts) {
|
||||
expect(await dummy.version()).to.eq('V1');
|
||||
|
||||
// upgrade beacon
|
||||
await beacon.upgradeTo(this.implementationV1.address);
|
||||
await beacon.upgradeTo(this.implementationV1.address, { from: upgradeableBeaconAdmin });
|
||||
|
||||
// test upgraded version
|
||||
expect(await dummy.version()).to.eq('V2');
|
||||
@ -106,7 +106,7 @@ contract('BeaconProxy', function (accounts) {
|
||||
const value1 = '10';
|
||||
const value2 = '42';
|
||||
|
||||
const beacon = await UpgradeableBeacon.new(this.implementationV0.address);
|
||||
const beacon = await UpgradeableBeacon.new(this.implementationV0.address, upgradeableBeaconAdmin);
|
||||
|
||||
const proxy1InitializeData = this.implementationV0.contract.methods
|
||||
.initializeNonPayableWithValue(value1)
|
||||
@ -130,7 +130,7 @@ contract('BeaconProxy', function (accounts) {
|
||||
expect(await dummy2.version()).to.eq('V1');
|
||||
|
||||
// upgrade beacon
|
||||
await beacon.upgradeTo(this.implementationV1.address);
|
||||
await beacon.upgradeTo(this.implementationV1.address, { from: upgradeableBeaconAdmin });
|
||||
|
||||
// test upgraded version
|
||||
expect(await dummy1.version()).to.eq('V2');
|
||||
|
||||
@ -9,13 +9,16 @@ contract('UpgradeableBeacon', function (accounts) {
|
||||
const [owner, other] = accounts;
|
||||
|
||||
it('cannot be created with non-contract implementation', async function () {
|
||||
await expectRevert(UpgradeableBeacon.new(accounts[0]), 'UpgradeableBeacon: implementation is not a contract');
|
||||
await expectRevert(
|
||||
UpgradeableBeacon.new(accounts[0], owner),
|
||||
'UpgradeableBeacon: implementation is not a contract',
|
||||
);
|
||||
});
|
||||
|
||||
context('once deployed', async function () {
|
||||
beforeEach('deploying beacon', async function () {
|
||||
this.v1 = await Implementation1.new();
|
||||
this.beacon = await UpgradeableBeacon.new(this.v1.address, { from: owner });
|
||||
this.beacon = await UpgradeableBeacon.new(this.v1.address, owner);
|
||||
});
|
||||
|
||||
it('returns implementation', async function () {
|
||||
|
||||
@ -17,12 +17,11 @@ contract('ProxyAdmin', function (accounts) {
|
||||
|
||||
beforeEach(async function () {
|
||||
const initializeData = Buffer.from('');
|
||||
this.proxyAdmin = await ProxyAdmin.new({ from: proxyAdminOwner });
|
||||
this.proxyAdmin = await ProxyAdmin.new(proxyAdminOwner);
|
||||
const proxy = await TransparentUpgradeableProxy.new(
|
||||
this.implementationV1.address,
|
||||
this.proxyAdmin.address,
|
||||
initializeData,
|
||||
{ from: proxyAdminOwner },
|
||||
);
|
||||
this.proxy = await ITransparentUpgradeableProxy.at(proxy.address);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user