From 73dfe95814e82f877c2e8d944dc75eaaf763fb68 Mon Sep 17 00:00:00 2001 From: Goran Rojovic Date: Wed, 6 Nov 2024 17:16:47 +0100 Subject: [PATCH] fix: remove test --- agglayer/types_test.go | 15 --------------- aggsender/aggsender.go | 9 ++++++--- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/agglayer/types_test.go b/agglayer/types_test.go index 2f4e2c62..325c0b88 100644 --- a/agglayer/types_test.go +++ b/agglayer/types_test.go @@ -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{ diff --git a/aggsender/aggsender.go b/aggsender/aggsender.go index 3e364445..62012075 100644 --- a/aggsender/aggsender.go +++ b/aggsender/aggsender.go @@ -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 { @@ -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 }