Finalize test migration: remove legacy dependencies and test helpers (#4797)
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
const { ethers } = require('hardhat');
|
||||
const { expect } = require('chai');
|
||||
|
||||
const { getAddressInSlot, ImplementationSlot, AdminSlot } = require('../../helpers/erc1967');
|
||||
const { impersonate } = require('../../helpers/account');
|
||||
const { getAddressInSlot, ImplementationSlot, AdminSlot } = require('../../helpers/storage');
|
||||
|
||||
// createProxy, initialOwner, accounts
|
||||
module.exports = function shouldBehaveLikeTransparentUpgradeableProxy() {
|
||||
@ -43,7 +43,7 @@ module.exports = function shouldBehaveLikeTransparentUpgradeableProxy() {
|
||||
|
||||
describe('implementation', function () {
|
||||
it('returns the current implementation address', async function () {
|
||||
expect(await getAddressInSlot(this.proxy, ImplementationSlot)).to.equal(this.implementationV0.target);
|
||||
expect(await getAddressInSlot(this.proxy, ImplementationSlot)).to.equal(this.implementationV0);
|
||||
});
|
||||
|
||||
it('delegates to the implementation', async function () {
|
||||
@ -53,26 +53,26 @@ module.exports = function shouldBehaveLikeTransparentUpgradeableProxy() {
|
||||
|
||||
describe('proxy admin', function () {
|
||||
it('emits AdminChanged event during construction', async function () {
|
||||
await expect(this.tx).to.emit(this.proxy, 'AdminChanged').withArgs(ethers.ZeroAddress, this.proxyAdmin.target);
|
||||
await expect(this.tx).to.emit(this.proxy, 'AdminChanged').withArgs(ethers.ZeroAddress, this.proxyAdmin);
|
||||
});
|
||||
|
||||
it('sets the proxy admin in storage with the correct initial owner', async function () {
|
||||
expect(await getAddressInSlot(this.proxy, AdminSlot)).to.equal(this.proxyAdmin.target);
|
||||
expect(await getAddressInSlot(this.proxy, AdminSlot)).to.equal(this.proxyAdmin);
|
||||
|
||||
expect(await this.proxyAdmin.owner()).to.equal(this.owner.address);
|
||||
expect(await this.proxyAdmin.owner()).to.equal(this.owner);
|
||||
});
|
||||
|
||||
it('can overwrite the admin by the implementation', async function () {
|
||||
await this.instance.unsafeOverrideAdmin(this.other);
|
||||
|
||||
const ERC1967AdminSlotValue = await getAddressInSlot(this.proxy, AdminSlot);
|
||||
expect(ERC1967AdminSlotValue).to.equal(this.other.address);
|
||||
expect(ERC1967AdminSlotValue).to.not.equal(this.proxyAdmin.address);
|
||||
expect(ERC1967AdminSlotValue).to.equal(this.other);
|
||||
expect(ERC1967AdminSlotValue).to.not.equal(this.proxyAdmin);
|
||||
|
||||
// Still allows previous admin to execute admin operations
|
||||
await expect(this.proxy.connect(this.proxyAdminAsSigner).upgradeToAndCall(this.implementationV1, '0x'))
|
||||
.to.emit(this.proxy, 'Upgraded')
|
||||
.withArgs(this.implementationV1.target);
|
||||
.withArgs(this.implementationV1);
|
||||
});
|
||||
});
|
||||
|
||||
@ -99,11 +99,11 @@ module.exports = function shouldBehaveLikeTransparentUpgradeableProxy() {
|
||||
});
|
||||
|
||||
it('upgrades to the requested implementation', async function () {
|
||||
expect(await getAddressInSlot(this.proxy, ImplementationSlot)).to.equal(this.behavior.target);
|
||||
expect(await getAddressInSlot(this.proxy, ImplementationSlot)).to.equal(this.behavior);
|
||||
});
|
||||
|
||||
it('emits an event', async function () {
|
||||
await expect(this.tx).to.emit(this.proxy, 'Upgraded').withArgs(this.behavior.target);
|
||||
await expect(this.tx).to.emit(this.proxy, 'Upgraded').withArgs(this.behavior);
|
||||
});
|
||||
|
||||
it('calls the initializer function', async function () {
|
||||
@ -160,9 +160,9 @@ module.exports = function shouldBehaveLikeTransparentUpgradeableProxy() {
|
||||
});
|
||||
|
||||
it('upgrades to the requested version and emits an event', async function () {
|
||||
expect(await getAddressInSlot(this.proxy, ImplementationSlot)).to.equal(this.behaviorV1.target);
|
||||
expect(await getAddressInSlot(this.proxy, ImplementationSlot)).to.equal(this.behaviorV1);
|
||||
|
||||
await expect(this.tx).to.emit(this.proxy, 'Upgraded').withArgs(this.behaviorV1.target);
|
||||
await expect(this.tx).to.emit(this.proxy, 'Upgraded').withArgs(this.behaviorV1);
|
||||
});
|
||||
|
||||
it("calls the 'initialize' function and sends given value to the proxy", async function () {
|
||||
@ -184,9 +184,9 @@ module.exports = function shouldBehaveLikeTransparentUpgradeableProxy() {
|
||||
});
|
||||
|
||||
it('upgrades to the requested version and emits an event', async function () {
|
||||
expect(await getAddressInSlot(this.proxy, ImplementationSlot)).to.equal(this.behaviorV2.target);
|
||||
expect(await getAddressInSlot(this.proxy, ImplementationSlot)).to.equal(this.behaviorV2);
|
||||
|
||||
await expect(this.tx).to.emit(this.proxy, 'Upgraded').withArgs(this.behaviorV2.target);
|
||||
await expect(this.tx).to.emit(this.proxy, 'Upgraded').withArgs(this.behaviorV2);
|
||||
});
|
||||
|
||||
it("calls the 'migrate' function and sends given value to the proxy", async function () {
|
||||
@ -209,9 +209,9 @@ module.exports = function shouldBehaveLikeTransparentUpgradeableProxy() {
|
||||
});
|
||||
|
||||
it('upgrades to the requested version and emits an event', async function () {
|
||||
expect(await getAddressInSlot(this.proxy, ImplementationSlot)).to.equal(this.behaviorV3.target);
|
||||
expect(await getAddressInSlot(this.proxy, ImplementationSlot)).to.equal(this.behaviorV3);
|
||||
|
||||
await expect(this.tx).to.emit(this.proxy, 'Upgraded').withArgs(this.behaviorV3.target);
|
||||
await expect(this.tx).to.emit(this.proxy, 'Upgraded').withArgs(this.behaviorV3);
|
||||
});
|
||||
|
||||
it("calls the 'migrate' function and sends given value to the proxy", async function () {
|
||||
@ -255,7 +255,7 @@ module.exports = function shouldBehaveLikeTransparentUpgradeableProxy() {
|
||||
it('executes the proxy function if the sender is the admin', async function () {
|
||||
await expect(this.proxy.connect(this.proxyAdminAsSigner).upgradeToAndCall(this.clashingImplV1, '0x'))
|
||||
.to.emit(this.proxy, 'Upgraded')
|
||||
.withArgs(this.clashingImplV1.target);
|
||||
.withArgs(this.clashingImplV1);
|
||||
});
|
||||
|
||||
it('delegates the call to implementation when sender is not the admin', async function () {
|
||||
|
||||
Reference in New Issue
Block a user