Implement recommendations from 5.0 audit Phase 1B (#4502)

Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
Co-authored-by: Francisco Giordano <fg@frang.io>
This commit is contained in:
Ernesto García
2023-08-04 14:23:38 -06:00
committed by GitHub
parent 21716722ad
commit f715365ec4
25 changed files with 286 additions and 283 deletions

View File

@ -9,6 +9,7 @@ const ERC1967Utils = artifacts.require('$ERC1967Utils');
const V1 = artifacts.require('DummyImplementation');
const V2 = artifacts.require('CallReceiverMock');
const UpgradeableBeaconMock = artifacts.require('UpgradeableBeaconMock');
const UpgradeableBeaconReentrantMock = artifacts.require('UpgradeableBeaconReentrantMock');
contract('ERC1967Utils', function (accounts) {
const [, admin, anotherAccount] = accounts;
@ -155,6 +156,17 @@ contract('ERC1967Utils', function (accounts) {
await expectEvent.inTransaction(receipt.tx, await V2.at(this.utils.address), 'MockFunctionCalled');
});
});
describe('reentrant beacon implementation() call', function () {
it('sees the new beacon implementation', async function () {
const newBeacon = await UpgradeableBeaconReentrantMock.new();
await expectRevertCustomError(
this.utils.$upgradeBeaconToAndCall(newBeacon.address, '0x'),
'BeaconProxyBeaconSlotAddress',
[newBeacon.address],
);
});
});
});
});
});

View File

@ -20,6 +20,13 @@ contract('UpgradeableBeacon', function (accounts) {
this.beacon = await UpgradeableBeacon.new(this.v1.address, owner);
});
it('emits Upgraded event to the first implementation', async function () {
const beacon = await UpgradeableBeacon.new(this.v1.address, owner);
await expectEvent.inTransaction(beacon.contract.transactionHash, beacon, 'Upgraded', {
implementation: this.v1.address,
});
});
it('returns implementation', async function () {
expect(await this.beacon.implementation()).to.equal(this.v1.address);
});