mirror of
https://github.com/lens-protocol/core.git
synced 2026-04-22 03:02:03 -04:00
Merge pull request #121 from aave/fix/emergency-admin-scope
Feat: Prevent Emergency Admin From Setting State When Paused
This commit is contained in:
@@ -51,20 +51,29 @@ makeSuiteCleanRoom('Multi-State Hub', function () {
|
||||
);
|
||||
});
|
||||
|
||||
it('Governance should set user as emergency admin, user should fail to set protocol state to unpaused', async function () {
|
||||
it('Governance should set user as emergency admin, user should fail to set protocol state to Unpaused', async function () {
|
||||
await expect(lensHub.connect(governance).setEmergencyAdmin(userAddress)).to.not.be.reverted;
|
||||
await expect(lensHub.setState(ProtocolState.Unpaused)).to.be.revertedWith(
|
||||
ERRORS.EMERGENCY_ADMIN_CANNOT_UNPAUSE
|
||||
);
|
||||
});
|
||||
|
||||
it('Governance should set user as emergency admin, user should fail to set protocol state to PublishingPaused or Paused from Paused', async function () {
|
||||
await expect(lensHub.connect(governance).setEmergencyAdmin(userAddress)).to.not.be.reverted;
|
||||
await expect(lensHub.connect(governance).setState(ProtocolState.Paused)).to.not.be.reverted;
|
||||
await expect(lensHub.setState(ProtocolState.PublishingPaused)).to.be.revertedWith(
|
||||
ERRORS.PAUSED
|
||||
);
|
||||
await expect(lensHub.setState(ProtocolState.Paused)).to.be.revertedWith(ERRORS.PAUSED);
|
||||
});
|
||||
});
|
||||
|
||||
context('Scenarios', function () {
|
||||
it('Governance should set user as emergency admin, user sets protocol state but fails to set emergency admin, governance sets emergency admin to the zero address, user fails to set protocol state', async function () {
|
||||
await expect(lensHub.connect(governance).setEmergencyAdmin(userAddress)).to.not.be.reverted;
|
||||
|
||||
await expect(lensHub.setState(ProtocolState.Paused)).to.not.be.reverted;
|
||||
await expect(lensHub.setState(ProtocolState.PublishingPaused)).to.not.be.reverted;
|
||||
await expect(lensHub.setState(ProtocolState.Paused)).to.not.be.reverted;
|
||||
await expect(lensHub.setEmergencyAdmin(ZERO_ADDRESS)).to.be.revertedWith(
|
||||
ERRORS.NOT_GOVERNANCE
|
||||
);
|
||||
@@ -98,6 +107,23 @@ makeSuiteCleanRoom('Multi-State Hub', function () {
|
||||
).to.not.be.reverted;
|
||||
expect(await lensHub.getState()).to.eq(ProtocolState.Unpaused);
|
||||
});
|
||||
|
||||
it('Governance should set user as emergency admin, user should set protocol state to PublishingPaused, then Paused, then fail to set it to PublishingPaused', async function () {
|
||||
await expect(lensHub.connect(governance).setEmergencyAdmin(userAddress)).to.not.be.reverted;
|
||||
|
||||
await expect(lensHub.setState(ProtocolState.PublishingPaused)).to.not.be.reverted;
|
||||
await expect(lensHub.setState(ProtocolState.Paused)).to.not.be.reverted;
|
||||
await expect(lensHub.setState(ProtocolState.PublishingPaused)).to.be.revertedWith(
|
||||
ERRORS.PAUSED
|
||||
);
|
||||
});
|
||||
|
||||
it('Governance should set user as emergency admin, user should set protocol state to PublishingPaused, then set it to PublishingPaused again without reverting', async function () {
|
||||
await expect(lensHub.connect(governance).setEmergencyAdmin(userAddress)).to.not.be.reverted;
|
||||
|
||||
await expect(lensHub.setState(ProtocolState.PublishingPaused)).to.not.be.reverted;
|
||||
await expect(lensHub.setState(ProtocolState.PublishingPaused)).to.not.be.reverted;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -121,6 +147,7 @@ makeSuiteCleanRoom('Multi-State Hub', function () {
|
||||
lensHub.transferFrom(userAddress, userTwoAddress, FIRST_PROFILE_ID)
|
||||
).to.be.revertedWith(ERRORS.PAUSED);
|
||||
});
|
||||
|
||||
it('Governance should pause the hub, profile creation should fail, then governance unpauses the hub and profile creation should work', async function () {
|
||||
await expect(lensHub.connect(governance).setState(ProtocolState.Paused)).to.not.be.reverted;
|
||||
|
||||
|
||||
@@ -148,25 +148,26 @@ makeSuiteCleanRoom('Events', function () {
|
||||
|
||||
it('Protocol state change by emergency admin should emit expected events', async function () {
|
||||
await waitForTx(lensHub.connect(governance).setEmergencyAdmin(userAddress));
|
||||
receipt = await waitForTx(lensHub.connect(user).setState(ProtocolState.Paused));
|
||||
|
||||
expect(receipt.logs.length).to.eq(1);
|
||||
matchEvent(receipt, 'StateSet', [
|
||||
userAddress,
|
||||
ProtocolState.Unpaused,
|
||||
ProtocolState.Paused,
|
||||
await getTimestamp(),
|
||||
]);
|
||||
|
||||
receipt = await waitForTx(lensHub.connect(user).setState(ProtocolState.PublishingPaused));
|
||||
|
||||
expect(receipt.logs.length).to.eq(1);
|
||||
matchEvent(receipt, 'StateSet', [
|
||||
userAddress,
|
||||
ProtocolState.Paused,
|
||||
ProtocolState.Unpaused,
|
||||
ProtocolState.PublishingPaused,
|
||||
await getTimestamp(),
|
||||
]);
|
||||
|
||||
receipt = await waitForTx(lensHub.connect(user).setState(ProtocolState.Paused));
|
||||
|
||||
expect(receipt.logs.length).to.eq(1);
|
||||
matchEvent(receipt, 'StateSet', [
|
||||
userAddress,
|
||||
ProtocolState.PublishingPaused,
|
||||
ProtocolState.Paused,
|
||||
await getTimestamp(),
|
||||
]);
|
||||
});
|
||||
|
||||
it('Follow module whitelisting functions should emit expected event', async function () {
|
||||
|
||||
Reference in New Issue
Block a user