diff --git a/test/docker-e2e/e2e_test.go b/test/docker-e2e/e2e_test.go index 51e2211b8b..743e486bf9 100644 --- a/test/docker-e2e/e2e_test.go +++ b/test/docker-e2e/e2e_test.go @@ -138,7 +138,7 @@ func (s *CelestiaTestSuite) GetLatestBlockHeight(ctx context.Context, statusClie // WaitForSync waits for a Celestia node to synchronize based on a provided sync condition within a specified timeout. // The method periodically checks the node's sync status. Returns an error if the timeout is exceeded. // Returns nil when the provided condition function returns true. -func (s *CelestiaTestSuite) WaitForSync(ctx context.Context, statusClient rpcclient.StatusClient, syncTimeout time.Duration, syncCondition func(coretypes.SyncInfo) bool) error { +func (s *CelestiaTestSuite) WaitForSync(ctx context.Context, client rpcclient.Client, syncTimeout time.Duration, syncCondition func(coretypes.SyncInfo) bool) error { ticker := time.NewTicker(10 * time.Second) defer ticker.Stop() @@ -148,8 +148,8 @@ func (s *CelestiaTestSuite) WaitForSync(ctx context.Context, statusClient rpccli s.T().Log("Waiting for sync to complete...") // check immediately first - if status, err := statusClient.Status(timeoutCtx); err == nil { - s.T().Logf("Sync node status: Height=%d, CatchingUp=%t", status.SyncInfo.LatestBlockHeight, status.SyncInfo.CatchingUp) + if status, err := client.Status(timeoutCtx); err == nil { + s.logSyncStatus(timeoutCtx, client, status.SyncInfo) if syncCondition(status.SyncInfo) { s.T().Logf("Sync completed successfully") return nil @@ -160,13 +160,13 @@ func (s *CelestiaTestSuite) WaitForSync(ctx context.Context, statusClient rpccli for { select { case <-ticker.C: - status, err := statusClient.Status(timeoutCtx) + status, err := client.Status(timeoutCtx) if err != nil { s.T().Logf("Failed to get status from state sync node, retrying...: %v", err) continue } - s.T().Logf("Sync node status: Height=%d, CatchingUp=%t", status.SyncInfo.LatestBlockHeight, status.SyncInfo.CatchingUp) + s.logSyncStatus(timeoutCtx, client, status.SyncInfo) if syncCondition(status.SyncInfo) { s.T().Logf("Sync completed successfully") @@ -179,6 +179,17 @@ func (s *CelestiaTestSuite) WaitForSync(ctx context.Context, statusClient rpccli } } +// logSyncStatus logs the node's sync status along with peer count. A NetInfo +// error is logged but not fatal — sync-wait polling continues either way. +func (s *CelestiaTestSuite) logSyncStatus(ctx context.Context, client rpcclient.Client, info coretypes.SyncInfo) { + netInfo, err := client.NetInfo(ctx) + if err != nil { + s.T().Logf("Sync node status: Height=%d, CatchingUp=%t, NetInfo error: %v", info.LatestBlockHeight, info.CatchingUp, err) + return + } + s.T().Logf("Sync node status: Height=%d, CatchingUp=%t, Peers=%d", info.LatestBlockHeight, info.CatchingUp, netInfo.NPeers) +} + // CheckLiveness validates that all validators proposed blocks and no nodes halted. // Automatically waits for sufficient blocks (3 per validator minimum) if needed. //