Merge branch 'master' into next-v5.0

This commit is contained in:
Hadrien Croubois
2023-01-14 18:51:03 -03:00
committed by Francisco Giordano
265 changed files with 5659 additions and 8542 deletions

View File

@ -16,7 +16,7 @@ const InitializableMock = artifacts.require('InitializableMock');
const DummyImplementation = artifacts.require('DummyImplementation');
const ClashingImplementation = artifacts.require('ClashingImplementation');
module.exports = function shouldBehaveLikeTransparentUpgradeableProxy (createProxy, accounts) {
module.exports = function shouldBehaveLikeTransparentUpgradeableProxy(createProxy, accounts) {
const [proxyAdminAddress, proxyAdminOwner, anotherAccount] = accounts;
before(async function () {
@ -59,12 +59,9 @@ module.exports = function shouldBehaveLikeTransparentUpgradeableProxy (createPro
});
it('emits an event', async function () {
expectEvent(
await this.proxy.upgradeTo(this.implementationV1, { from }),
'Upgraded', {
implementation: this.implementationV1,
},
);
expectEvent(await this.proxy.upgradeTo(this.implementationV1, { from }), 'Upgraded', {
implementation: this.implementationV1,
});
});
});
@ -82,9 +79,7 @@ module.exports = function shouldBehaveLikeTransparentUpgradeableProxy (createPro
const from = anotherAccount;
it('reverts', async function () {
await expectRevert.unspecified(
this.proxy.upgradeTo(this.implementationV1, { from }),
);
await expectRevert.unspecified(this.proxy.upgradeTo(this.implementationV1, { from }));
});
});
});
@ -177,7 +172,7 @@ module.exports = function shouldBehaveLikeTransparentUpgradeableProxy (createPro
expectEvent(this.receipt, 'Upgraded', { implementation: this.behaviorV1.address });
});
it('calls the \'initialize\' function and sends given value to the proxy', async function () {
it("calls the 'initialize' function and sends given value to the proxy", async function () {
const migratable = new MigratableMockV1(this.proxyAddress);
const x = await migratable.x();
@ -193,8 +188,10 @@ module.exports = function shouldBehaveLikeTransparentUpgradeableProxy (createPro
beforeEach(async function () {
this.behaviorV2 = await MigratableMockV2.new();
this.balancePreviousV2 = new BN(await web3.eth.getBalance(this.proxyAddress));
this.receipt =
await this.proxy.upgradeToAndCall(this.behaviorV2.address, v2MigrationData, { from, value });
this.receipt = await this.proxy.upgradeToAndCall(this.behaviorV2.address, v2MigrationData, {
from,
value,
});
});
it('upgrades to the requested version and emits an event', async function () {
@ -203,7 +200,7 @@ module.exports = function shouldBehaveLikeTransparentUpgradeableProxy (createPro
expectEvent(this.receipt, 'Upgraded', { implementation: this.behaviorV2.address });
});
it('calls the \'migrate\' function and sends given value to the proxy', async function () {
it("calls the 'migrate' function and sends given value to the proxy", async function () {
const migratable = new MigratableMockV2(this.proxyAddress);
const x = await migratable.x();
@ -222,8 +219,10 @@ module.exports = function shouldBehaveLikeTransparentUpgradeableProxy (createPro
beforeEach(async function () {
this.behaviorV3 = await MigratableMockV3.new();
this.balancePreviousV3 = new BN(await web3.eth.getBalance(this.proxyAddress));
this.receipt =
await this.proxy.upgradeToAndCall(this.behaviorV3.address, v3MigrationData, { from, value });
this.receipt = await this.proxy.upgradeToAndCall(this.behaviorV3.address, v3MigrationData, {
from,
value,
});
});
it('upgrades to the requested version and emits an event', async function () {
@ -232,7 +231,7 @@ module.exports = function shouldBehaveLikeTransparentUpgradeableProxy (createPro
expectEvent(this.receipt, 'Upgraded', { implementation: this.behaviorV3.address });
});
it('calls the \'migrate\' function and sends given value to the proxy', async function () {
it("calls the 'migrate' function and sends given value to the proxy", async function () {
const migratable = new MigratableMockV3(this.proxyAddress);
const x = await migratable.x();
@ -255,9 +254,7 @@ module.exports = function shouldBehaveLikeTransparentUpgradeableProxy (createPro
it('reverts', async function () {
const behaviorV1 = await MigratableMockV1.new();
const v1MigrationData = new MigratableMockV1('').contract.methods.initialize(42).encodeABI();
await expectRevert.unspecified(
this.proxy.upgradeToAndCall(behaviorV1.address, v1MigrationData, { from }),
);
await expectRevert.unspecified(this.proxy.upgradeToAndCall(behaviorV1.address, v1MigrationData, { from }));
});
});
});
@ -392,9 +389,7 @@ module.exports = function shouldBehaveLikeTransparentUpgradeableProxy (createPro
await proxy.upgradeTo(instance2.address, { from: proxyAdminAddress });
const data = '0x';
await expectRevert.unspecified(
web3.eth.sendTransaction({ to: proxy.address, from: anotherAccount, data }),
);
await expectRevert.unspecified(web3.eth.sendTransaction({ to: proxy.address, from: anotherAccount, data }));
const proxyInstance2 = new Implementation2(proxy.address);
const res = await proxyInstance2.getValue();