Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

feat: add access control to pushCertificate #98

Merged
merged 5 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading