diff --git a/validator/valnode/redis/consumer.go b/validator/valnode/redis/consumer.go index 3569e78b5c..016f30bd61 100644 --- a/validator/valnode/redis/consumer.go +++ b/validator/valnode/redis/consumer.go @@ -70,7 +70,7 @@ func (s *ValidationServer) Start(ctx_in context.Context) { } select { case <-ctx.Done(): - log.Info("Context done", "error", ctx.Err().Error()) + log.Info("Context done while checking redis stream existance", "error", ctx.Err().Error()) return case <-time.After(time.Millisecond * 100): } @@ -79,7 +79,7 @@ func (s *ValidationServer) Start(ctx_in context.Context) { s.StopWaiter.LaunchThread(func(ctx context.Context) { select { case <-ctx.Done(): - log.Info("Context done", "error", ctx.Err().Error()) + log.Info("Context done while waiting a redis stream to be ready", "error", ctx.Err().Error()) return case <-ready: // Wait until the stream exists and start consuming iteratively. } @@ -116,7 +116,7 @@ func (s *ValidationServer) Start(ctx_in context.Context) { case <-time.After(s.streamTimeout): log.Error("Waiting for redis streams timed out") case <-ctx.Done(): - log.Info(("Context expired, failed to start")) + log.Info("Context done while waiting redis streams to be ready, failed to start") return } } diff --git a/validator/valnode/redis/consumer_test.go b/validator/valnode/redis/consumer_test.go new file mode 100644 index 0000000000..0ebd697f16 --- /dev/null +++ b/validator/valnode/redis/consumer_test.go @@ -0,0 +1,30 @@ +package redis + +import ( + "context" + "testing" + "time" + + "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/util/redisutil" + "github.com/offchainlabs/nitro/util/testhelpers" +) + +func TestTimeout(t *testing.T) { + handler := testhelpers.InitTestLog(t, log.LevelInfo) + ctx, cancel := context.WithCancel(context.Background()) + redisURL := redisutil.CreateTestRedis(ctx, t) + TestValidationServerConfig.RedisURL = redisURL + TestValidationServerConfig.ModuleRoots = []string{"0x123"} + TestValidationServerConfig.StreamTimeout = 100 * time.Millisecond + vs, err := NewValidationServer(&TestValidationServerConfig, nil) + if err != nil { + t.Fatalf("NewValidationSever() unexpected error: %v", err) + } + vs.Start(ctx) + time.Sleep(time.Second) + if !handler.WasLogged("Waiting for redis streams timed out") { + t.Error("Expected message about stream time-outs was not logged") + } + cancel() +}