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

Commit

Permalink
fix: return value of a storage cert (#104)
Browse files Browse the repository at this point in the history
Signed-off-by: Jawad Tariq <[email protected]>
  • Loading branch information
JDawg287 authored Aug 30, 2023
1 parent db754be commit d9a291d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 47 deletions.
18 changes: 1 addition & 17 deletions contracts/interfaces/IToposCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,7 @@ interface IToposCore {

function getCertIdAtIndex(uint256 index) external view returns (CertificateId);

function getCertificate(
CertificateId certId
)
external
view
returns (
CertificateId,
SubnetId,
bytes32,
bytes32,
SubnetId[] memory,
uint32,
CertificateId,
bytes memory,
bytes memory,
uint256
);
function getCertificate(CertificateId certId) external view returns (Certificate memory storedCert);

function getCertificateCount() external view returns (uint256);

Expand Down
32 changes: 2 additions & 30 deletions contracts/topos-core/ToposCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -177,36 +177,8 @@ contract ToposCore is IToposCore, AdminMultisigBase, Initializable {

/// @notice Get the certificate for the provided certificate ID
/// @param certId certificate ID
function getCertificate(
CertificateId certId
)
public
view
returns (
CertificateId,
SubnetId,
bytes32,
bytes32,
SubnetId[] memory,
uint32,
CertificateId,
bytes memory,
bytes memory,
uint256
)
{
Certificate memory storedCert = certificates[certId];
(
storedCert.prevId,
storedCert.sourceSubnetId,
storedCert.stateRoot,
storedCert.receiptRoot,
storedCert.targetSubnets,
storedCert.verifier,
storedCert.certId,
storedCert.starkProof,
storedCert.signature
);
function getCertificate(CertificateId certId) public view returns (Certificate memory storedCert) {
storedCert = certificates[certId];
}

/// @notice Get the checkpoints for the received source subnet IDs
Expand Down
21 changes: 21 additions & 0 deletions test/topos-core/ToposCore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,27 @@ describe('ToposCore', () => {
)
})

it('gets a storage certificate', async () => {
const { defaultCert, toposCore } = await loadFixture(
deployToposCoreFixture
)
await toposCore.pushCertificate(defaultCert, cc.CERT_POS_1)
const certificate = await toposCore.getCertificate(cc.CERT_ID_1)
const encodedCert = testUtils.encodeCertParam(
certificate.prevId,
certificate.sourceSubnetId,
certificate.stateRoot,
certificate.txRoot,
certificate.receiptRoot,
certificate.targetSubnets,
certificate.verifier,
certificate.certId,
certificate.starkProof,
certificate.signature
)
expect(encodedCert).to.equal(defaultCert)
})

it('emits a certificate stored event', async () => {
const { defaultCert, toposCore } = await loadFixture(
deployToposCoreFixture
Expand Down

0 comments on commit d9a291d

Please sign in to comment.