Skip to content

Commit

Permalink
[L-03] fix of revocation state inconsistency in CertifierHbbft Contract
Browse files Browse the repository at this point in the history
  • Loading branch information
axel-muller committed Jan 23, 2025
1 parent 5a1ae69 commit 5c35c64
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions contracts/CertifierHbbft.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ contract CertifierHbbft is Initializable, OwnableUpgradeable, ICertifier {
/// Can only be called by the `owner`.
/// @param _who The address for which transactions with a zero gas price must be denied.
function revoke(address _who) external onlyOwner {
if (!_certified[_who]) {
return;
}

_certified[_who] = false;

emit Revoked(_who);
}

Expand Down
16 changes: 15 additions & 1 deletion test/CertifierHbbft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ describe('CertifierHbbft contract', () => {
.withArgs(caller.address);
});

it("should sertify address", async function () {
it("should certify address", async function () {
const { certifier } = await loadFixture(deployContracts);
const who = accounts[4];

Expand Down Expand Up @@ -173,6 +173,20 @@ describe('CertifierHbbft contract', () => {
expect(await certifier.certified(who.address)).to.be.false;
});

it("should do nothing if revoking from uncertified address", async function () {
const { certifier } = await loadFixture(deployContracts);
const who = accounts[9];

expect(await certifier.certifiedExplicitly(who.address)).to.be.false;
expect(await certifier.certified(who.address)).to.be.false;

await expect(certifier.connect(owner).revoke(who.address))
.to.not.emit(certifier, "Revoked");

expect(await certifier.certifiedExplicitly(who.address)).to.be.false;
expect(await certifier.certified(who.address)).to.be.false;
});

it("validator account should be certified by default", async function () {
const { certifier } = await loadFixture(deployContracts);

Expand Down

0 comments on commit 5c35c64

Please sign in to comment.