Skip to content

Commit

Permalink
fix: remove test
Browse files Browse the repository at this point in the history
  • Loading branch information
goran-ethernal committed Nov 6, 2024
1 parent 210ef4b commit 73dfe95
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
15 changes: 0 additions & 15 deletions agglayer/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,8 @@ import (
const (
expectedSignedCertificateEmptyMetadataJSON = `{"network_id":1,"height":1,"prev_local_exit_root":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"new_local_exit_root":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"bridge_exits":[{"leaf_type":"Transfer","token_info":null,"dest_network":0,"dest_address":"0x0000000000000000000000000000000000000000","amount":"1","metadata":[]}],"imported_bridge_exits":[{"bridge_exit":{"leaf_type":"Transfer","token_info":null,"dest_network":0,"dest_address":"0x0000000000000000000000000000000000000000","amount":"1","metadata":[]},"claim_data":null,"global_index":{"mainnet_flag":false,"rollup_index":1,"leaf_index":1}}],"metadata":"0x0000000000000000000000000000000000000000000000000000000000000000","signature":{"r":"0x0000000000000000000000000000000000000000000000000000000000000000","s":"0x0000000000000000000000000000000000000000000000000000000000000000","odd_y_parity":false}}`
expectedSignedCertificateyMetadataJSON = `{"network_id":1,"height":1,"prev_local_exit_root":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"new_local_exit_root":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"bridge_exits":[{"leaf_type":"Transfer","token_info":null,"dest_network":0,"dest_address":"0x0000000000000000000000000000000000000000","amount":"1","metadata":[1,2,3]}],"imported_bridge_exits":[{"bridge_exit":{"leaf_type":"Transfer","token_info":null,"dest_network":0,"dest_address":"0x0000000000000000000000000000000000000000","amount":"1","metadata":[]},"claim_data":null,"global_index":{"mainnet_flag":false,"rollup_index":1,"leaf_index":1}}],"metadata":"0x0000000000000000000000000000000000000000000000000000000000000000","signature":{"r":"0x0000000000000000000000000000000000000000000000000000000000000000","s":"0x0000000000000000000000000000000000000000000000000000000000000000","odd_y_parity":false}}`
expectedCertificateJSONEmptyFields = `{"network_id":0,"height":0,"prev_local_exit_root":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"new_local_exit_root":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"bridge_exits":null,"imported_bridge_exits":null,"metadata":"0x0000000000000000000000000000000000000000000000000000000000000000","signature":{"r":"0x0000000000000000000000000000000000000000000000000000000000000000","s":"0x0000000000000000000000000000000000000000000000000000000000000000","odd_y_parity":false}}`
)

func TestMarshalJSONEmptyFields(t *testing.T) {
cert := &SignedCertificate{
Certificate: &Certificate{
BridgeExits: nil,
ImportedBridgeExits: nil,
},
Signature: &Signature{},
}
data, err := json.Marshal(cert)
require.NoError(t, err)
log.Info(string(data))
require.Equal(t, expectedCertificateJSONEmptyFields, string(data))
}

func TestMarshalJSON(t *testing.T) {
cert := SignedCertificate{
Certificate: &Certificate{
Expand Down
9 changes: 6 additions & 3 deletions aggsender/aggsender.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ func (a *AggSender) saveCertificateToFile(signedCertificate *agglayer.SignedCert
if signedCertificate == nil || a.cfg.SaveCertificatesToFilesPath == "" {
return
}
fn := fmt.Sprintf("%s/certificate_%04d-%07d.json", a.cfg.SaveCertificatesToFilesPath, signedCertificate.Height, time.Now().Unix())
fn := fmt.Sprintf("%s/certificate_%04d-%07d.json",
a.cfg.SaveCertificatesToFilesPath, signedCertificate.Height, time.Now().Unix())
a.log.Infof("saving certificate to file: %s", fn)
jsonData, err := json.MarshalIndent(signedCertificate, "", " ")
if err != nil {
Expand All @@ -206,11 +207,13 @@ func (a *AggSender) saveCertificateToFile(signedCertificate *agglayer.SignedCert
}

// getNextHeightAndPreviousLER returns the height and previous LER for the new certificate
func (a *AggSender) getNextHeightAndPreviousLER(lastSentCertificateInfo *aggsendertypes.CertificateInfo) (uint64, common.Hash) {
func (a *AggSender) getNextHeightAndPreviousLER(
lastSentCertificateInfo *aggsendertypes.CertificateInfo) (uint64, common.Hash) {
height := lastSentCertificateInfo.Height + 1
if lastSentCertificateInfo.Status == agglayer.InError {
// previous certificate was in error, so we need to resend it
a.log.Debugf("Last certificate %s failed so reusing height %d", lastSentCertificateInfo.CertificateID, lastSentCertificateInfo.Height)
a.log.Debugf("Last certificate %s failed so reusing height %d",
lastSentCertificateInfo.CertificateID, lastSentCertificateInfo.Height)
height = lastSentCertificateInfo.Height
}

Expand Down

0 comments on commit 73dfe95

Please sign in to comment.