Finalize test migration: remove legacy dependencies and test helpers (#4797)
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
const { ethers } = require('hardhat');
|
||||
const { expect } = require('chai');
|
||||
const { loadFixture } = require('@nomicfoundation/hardhat-network-helpers');
|
||||
const { getAddressInSlot, BeaconSlot } = require('../../helpers/erc1967');
|
||||
|
||||
const { getAddressInSlot, BeaconSlot } = require('../../helpers/storage');
|
||||
|
||||
async function fixture() {
|
||||
const [admin, other] = await ethers.getSigners();
|
||||
@ -27,7 +28,7 @@ describe('BeaconProxy', function () {
|
||||
|
||||
await expect(this.newBeaconProxy(notBeacon, '0x'))
|
||||
.to.be.revertedWithCustomError(this.factory, 'ERC1967InvalidBeacon')
|
||||
.withArgs(notBeacon.address);
|
||||
.withArgs(notBeacon);
|
||||
});
|
||||
|
||||
it('non-compliant beacon', async function () {
|
||||
@ -48,7 +49,7 @@ describe('BeaconProxy', function () {
|
||||
describe('initialization', function () {
|
||||
async function assertInitialized({ value, balance }) {
|
||||
const beaconAddress = await getAddressInSlot(this.proxy, BeaconSlot);
|
||||
expect(beaconAddress).to.equal(this.beacon.target);
|
||||
expect(beaconAddress).to.equal(this.beacon);
|
||||
|
||||
const dummy = this.v1.attach(this.proxy);
|
||||
expect(await dummy.value()).to.equal(value);
|
||||
|
||||
@ -20,36 +20,36 @@ describe('UpgradeableBeacon', function () {
|
||||
it('cannot be created with non-contract implementation', async function () {
|
||||
await expect(ethers.deployContract('UpgradeableBeacon', [this.other, this.admin]))
|
||||
.to.be.revertedWithCustomError(this.beacon, 'BeaconInvalidImplementation')
|
||||
.withArgs(this.other.address);
|
||||
.withArgs(this.other);
|
||||
});
|
||||
|
||||
describe('once deployed', async function () {
|
||||
it('emits Upgraded event to the first implementation', async function () {
|
||||
await expect(this.beacon.deploymentTransaction()).to.emit(this.beacon, 'Upgraded').withArgs(this.v1.target);
|
||||
await expect(this.beacon.deploymentTransaction()).to.emit(this.beacon, 'Upgraded').withArgs(this.v1);
|
||||
});
|
||||
|
||||
it('returns implementation', async function () {
|
||||
expect(await this.beacon.implementation()).to.equal(this.v1.target);
|
||||
expect(await this.beacon.implementation()).to.equal(this.v1);
|
||||
});
|
||||
|
||||
it('can be upgraded by the admin', async function () {
|
||||
await expect(this.beacon.connect(this.admin).upgradeTo(this.v2))
|
||||
.to.emit(this.beacon, 'Upgraded')
|
||||
.withArgs(this.v2.target);
|
||||
.withArgs(this.v2);
|
||||
|
||||
expect(await this.beacon.implementation()).to.equal(this.v2.target);
|
||||
expect(await this.beacon.implementation()).to.equal(this.v2);
|
||||
});
|
||||
|
||||
it('cannot be upgraded to a non-contract', async function () {
|
||||
await expect(this.beacon.connect(this.admin).upgradeTo(this.other))
|
||||
.to.be.revertedWithCustomError(this.beacon, 'BeaconInvalidImplementation')
|
||||
.withArgs(this.other.address);
|
||||
.withArgs(this.other);
|
||||
});
|
||||
|
||||
it('cannot be upgraded by other account', async function () {
|
||||
await expect(this.beacon.connect(this.other).upgradeTo(this.v2))
|
||||
.to.be.revertedWithCustomError(this.beacon, 'OwnableUnauthorizedAccount')
|
||||
.withArgs(this.other.address);
|
||||
.withArgs(this.other);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user