-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2355 from OffchainLabs/minor-fixes
Add tests to check errors are logged when context is cancelled [NIT-2547]
- Loading branch information
Showing
2 changed files
with
33 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
} |