Make Ownable's initial owner explicit (#4267)

Co-authored-by: Ernesto García <ernestognw@gmail.com>
This commit is contained in:
Hadrien Croubois
2023-05-23 23:26:43 +02:00
committed by GitHub
parent 11d65442b3
commit 13d5e0466a
10 changed files with 29 additions and 20 deletions

View File

@ -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');

View File

@ -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 () {

View File

@ -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);
});