Skip to content

Commit ad7f062

Browse files
committed
test: check non-owner upgrading proxy
1 parent e0f52bb commit ad7f062

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

.solcover.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ module.exports = {
33
grep: '[Gg]as.*[Aa]nalysis',
44
invert: true,
55
},
6-
skipFiles: ['mocks/', 'interfaces/', 'libraries/SedaDataTypes.sol', 'test/'],
6+
skipFiles: ['mocks/', 'interfaces/', 'libraries/', 'test/'],
77
modifierWhitelist: ['initializer', 'onlyInitializing'],
88
};

test/core/SedaCoreV1.proxy.test.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,20 @@ describe('Proxy: SedaCore', () => {
5656

5757
// Upgrade to V2
5858
const proxyV2 = await upgrades.upgradeProxy(await proxy.getAddress(), CoreV2Factory);
59-
await proxyV2.initialize();
59+
await proxyV2.getFunction('initialize')();
6060

6161
// Check new V2 functionality
6262
const version = await proxyV2.getVersion();
6363
expect(version).to.equal('2.0.0');
6464
});
65+
66+
it('prevents non-owner from upgrading the proxy', async () => {
67+
const { core: proxy, CoreV2Factory } = await loadFixture(deployProxyFixture);
68+
const [, nonOwner] = await ethers.getSigners();
69+
70+
await expect(
71+
upgrades.upgradeProxy(await proxy.getAddress(), CoreV2Factory.connect(nonOwner)),
72+
).to.be.revertedWithCustomError(proxy, 'OwnableUnauthorizedAccount');
73+
});
6574
});
6675
});

test/prover/Secp256k1ProverV1.proxy.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ describe('Proxy: Secp256k1Prover', () => {
8181

8282
await expect(proxyV2.initialize()).to.be.revertedWithCustomError(proxyV2, 'InvalidInitialization');
8383
});
84+
85+
it('prevents non-owner from upgrading the proxy', async () => {
86+
const { proxy, ProverV2Factory, nonOwner } = await loadFixture(deployProxyFixture);
87+
88+
await expect(
89+
upgrades.upgradeProxy(await proxy.getAddress(), ProverV2Factory.connect(nonOwner)),
90+
).to.be.revertedWithCustomError(proxy, 'OwnableUnauthorizedAccount');
91+
});
8492
});
8593

8694
describe('resettable variant', () => {

0 commit comments

Comments
 (0)