Skip to content

Commit

Permalink
feat: add AC to pushCertificate
Browse files Browse the repository at this point in the history
Signed-off-by: Jawad Tariq <[email protected]>
  • Loading branch information
JDawg287 committed Aug 2, 2023
1 parent da41ebb commit f840ac6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion contracts/topos-core/ToposCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ contract ToposCore is IToposCore, AdminMultisigBase {
/// @notice Push the certificate on-chain
/// @param certBytes The certificate in byte
/// @param position The position of the certificate
function pushCertificate(bytes memory certBytes, uint256 position) external override {
function pushCertificate(bytes memory certBytes, uint256 position) external override onlyAdmin {
(
CertificateId prevId,
SubnetId sourceSubnetId,
Expand Down
10 changes: 10 additions & 0 deletions test/topos-core/ToposCore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ describe('ToposCore', () => {
).to.be.revertedWith('Bytes32Set: key already exists in the set.')
})

it('reverts if non-admin tries to push certificate', async () => {
const { defaultCert, toposCore } = await loadFixture(
deployToposCoreFixture
)
const [, nonAdmin] = await ethers.getSigners()
await expect(
toposCore.connect(nonAdmin).pushCertificate(defaultCert, cc.CERT_POS_1)
).to.be.revertedWithCustomError(toposCore, 'NotAdmin')
})

it('gets the certificate count', async () => {
const { defaultCert, toposCore } = await loadFixture(
deployToposCoreFixture
Expand Down

0 comments on commit f840ac6

Please sign in to comment.