Skip to content

Commit

Permalink
feat: increase coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
joanestebanr committed Nov 13, 2024
1 parent e730cda commit ddd9a55
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
7 changes: 3 additions & 4 deletions aggsender/aggsender.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func New(
cfg Config,
aggLayerClient agglayer.AgglayerClientInterface,
l1InfoTreeSyncer *l1infotreesync.L1InfoTreeSync,
l2Syncer *bridgesync.BridgeSync,
l2Syncer types.L2BridgeSyncer,
epochNotifier types.EpochNotifier) (*AggSender, error) {
storage, err := db.NewAggSenderSQLStorage(logger, cfg.StoragePath)
if err != nil {
Expand Down Expand Up @@ -525,14 +525,13 @@ func (a *AggSender) checkPendingCertificatesStatus(ctx context.Context) bool {
}
}
if slices.Contains(nonSettledStatuses, certificateHeader.Status) {

logErrMsg += fmt.Sprintf("certificate %s is still pending, elapsed_time:%s ", certificateHeader.String(), elapsedTime)
logErrMsg += fmt.Sprintf("certificate %s is still pending, elapsed_time:%s ",
certificateHeader.String(), elapsedTime)
}
}
if logErrMsg != "" {
a.log.Infof(logErrMsg)

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

Sensitive data returned by an access to Password
flows to a logging call.
return true

}
return false
}
Expand Down
22 changes: 17 additions & 5 deletions aggsender/aggsender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,20 +280,32 @@ func TestGetBridgeExits(t *testing.T) {
}
}

func TestNewAggSender(t *testing.T) {
func TestAggSendersendCertificates(t *testing.T) {
AggLayerMock := agglayer.NewAgglayerClientMock(t)
epochNotifierMock := mocks.NewEpochNotifier(t)

bridgeL2SyncerMock := mocks.NewL2BridgeSyncer(t)
ctx, cancel := context.WithCancel(context.Background())
aggSender, err := New(
context.TODO(),
ctx,
log.WithFields("test", "unittest"),
Config{},
Config{
StoragePath: "file::memory:?cache=shared",
},
AggLayerMock,
nil,
nil,
bridgeL2SyncerMock,
epochNotifierMock)
require.NoError(t, err)
require.NotNil(t, aggSender)
ch := make(chan aggsendertypes.EpochEvent)
epochNotifierMock.EXPECT().Subscribe("aggsender").Return(ch)
bridgeL2SyncerMock.EXPECT().GetLastProcessedBlock(mock.Anything).Return(uint64(0), nil)
go aggSender.Start(ctx)
ch <- aggsendertypes.EpochEvent{
Epoch: 1,
}
time.Sleep(100 * time.Millisecond)
cancel()

}

Check failure on line 310 in aggsender/aggsender_test.go

View workflow job for this annotation

GitHub Actions / lint

unnecessary trailing newline (whitespace)

Expand Down

0 comments on commit ddd9a55

Please sign in to comment.