Skip to content

Commit

Permalink
fix: raw to signed_certificate
Browse files Browse the repository at this point in the history
  • Loading branch information
goran-ethernal committed Nov 8, 2024
1 parent fdb0138 commit 5597648
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
16 changes: 8 additions & 8 deletions aggsender/aggsender.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,14 @@ func (a *AggSender) sendCertificate(ctx context.Context) (*agglayer.SignedCertif

createdTime := time.Now().UTC().UnixMilli()
certInfo := aggsendertypes.CertificateInfo{
Height: certificate.Height,
CertificateID: certificateHash,
NewLocalExitRoot: certificate.NewLocalExitRoot,
FromBlock: fromBlock,
ToBlock: toBlock,
CreatedAt: createdTime,
UpdatedAt: createdTime,
Raw: string(raw),
Height: certificate.Height,
CertificateID: certificateHash,
NewLocalExitRoot: certificate.NewLocalExitRoot,
FromBlock: fromBlock,
ToBlock: toBlock,
CreatedAt: createdTime,
UpdatedAt: createdTime,
SignedCertificate: string(raw),
}

if err := a.storage.SaveLastSentCertificate(ctx, certInfo); err != nil {
Expand Down
20 changes: 10 additions & 10 deletions aggsender/db/aggsender_db_storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,22 +348,22 @@ func Test_SaveLastSentCertificate(t *testing.T) {
require.NoError(t, err)

certificate := types.CertificateInfo{
Height: 1,
CertificateID: common.HexToHash("0x9"),
NewLocalExitRoot: common.HexToHash("0x2"),
FromBlock: 1,
ToBlock: 10,
Status: agglayer.Pending,
CreatedAt: updateTime,
UpdatedAt: updateTime,
Raw: string(raw),
Height: 1,
CertificateID: common.HexToHash("0x9"),
NewLocalExitRoot: common.HexToHash("0x2"),
FromBlock: 1,
ToBlock: 10,
Status: agglayer.Pending,
CreatedAt: updateTime,
UpdatedAt: updateTime,
SignedCertificate: string(raw),
}
require.NoError(t, storage.SaveLastSentCertificate(ctx, certificate))

certificateFromDB, err := storage.GetCertificateByHeight(certificate.Height)
require.NoError(t, err)
require.Equal(t, certificate, certificateFromDB)
require.Equal(t, raw, []byte(certificateFromDB.Raw))
require.Equal(t, raw, []byte(certificateFromDB.SignedCertificate))

require.NoError(t, storage.clean())
})
Expand Down
2 changes: 1 addition & 1 deletion aggsender/db/migrations/0001.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ CREATE TABLE certificate_info (
to_block INTEGER NOT NULL,
created_at INTEGER NOT NULL,
updated_at INTEGER NOT NULL,
raw TEXT
signed_certificate TEXT
);
18 changes: 9 additions & 9 deletions aggsender/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ type Logger interface {
}

type CertificateInfo struct {
Height uint64 `meddler:"height"`
CertificateID common.Hash `meddler:"certificate_id,hash"`
NewLocalExitRoot common.Hash `meddler:"new_local_exit_root,hash"`
FromBlock uint64 `meddler:"from_block"`
ToBlock uint64 `meddler:"to_block"`
Status agglayer.CertificateStatus `meddler:"status"`
CreatedAt int64 `meddler:"created_at"`
UpdatedAt int64 `meddler:"updated_at"`
Raw string `meddler:"raw"`
Height uint64 `meddler:"height"`
CertificateID common.Hash `meddler:"certificate_id,hash"`
NewLocalExitRoot common.Hash `meddler:"new_local_exit_root,hash"`
FromBlock uint64 `meddler:"from_block"`
ToBlock uint64 `meddler:"to_block"`
Status agglayer.CertificateStatus `meddler:"status"`
CreatedAt int64 `meddler:"created_at"`
UpdatedAt int64 `meddler:"updated_at"`
SignedCertificate string `meddler:"signed_certificate"`
}

func (c CertificateInfo) String() string {
Expand Down

0 comments on commit 5597648

Please sign in to comment.