Commit 7e5b468d authored by Andreas Bigger's avatar Andreas Bigger

Minor fixes to the log store.

parent 365d40ea
...@@ -108,7 +108,7 @@ func (l *logStore) buildBackoffStrategy() backoff.Strategy { ...@@ -108,7 +108,7 @@ func (l *logStore) buildBackoffStrategy() backoff.Strategy {
// resubscribe attempts to re-establish the log store internal // resubscribe attempts to re-establish the log store internal
// subscription with a backoff strategy. // subscription with a backoff strategy.
func (l *logStore) resubscribe(ctx context.Context) error { func (l *logStore) resubscribe(ctx context.Context) error {
l.log.Info("resubscribing") l.log.Info("log store resubscribing with backoff")
backoffStrategy := l.buildBackoffStrategy() backoffStrategy := l.buildBackoffStrategy()
return backoff.DoCtx(ctx, 10, backoffStrategy, func() error { return backoff.DoCtx(ctx, 10, backoffStrategy, func() error {
if l.subscription == nil { if l.subscription == nil {
......
...@@ -110,7 +110,7 @@ func TestLogStore_Subscribe_ReceivesLogs(t *testing.T) { ...@@ -110,7 +110,7 @@ func TestLogStore_Subscribe_ReceivesLogs(t *testing.T) {
} }
client.logs <- mockLog client.logs <- mockLog
timeout, tCancel := context.WithTimeout(context.Background(), 5*time.Second) timeout, tCancel := context.WithTimeout(context.Background(), 30*time.Second)
defer tCancel() defer tCancel()
err := e2eutils.WaitFor(timeout, 500*time.Millisecond, func() (bool, error) { err := e2eutils.WaitFor(timeout, 500*time.Millisecond, func() (bool, error) {
result := logStore.GetLogByBlockHash(mockLog.BlockHash) result := logStore.GetLogByBlockHash(mockLog.BlockHash)
...@@ -126,7 +126,7 @@ func TestLogStore_Subscribe_SubscriptionErrors(t *testing.T) { ...@@ -126,7 +126,7 @@ func TestLogStore_Subscribe_SubscriptionErrors(t *testing.T) {
client.sub.errorChan <- ErrTestError client.sub.errorChan <- ErrTestError
timeout, tCancel := context.WithTimeout(context.Background(), 5*time.Second) timeout, tCancel := context.WithTimeout(context.Background(), 30*time.Second)
defer tCancel() defer tCancel()
err := e2eutils.WaitFor(timeout, 500*time.Millisecond, func() (bool, error) { err := e2eutils.WaitFor(timeout, 500*time.Millisecond, func() (bool, error) {
subcount := client.subcount == 2 subcount := client.subcount == 2
...@@ -137,13 +137,10 @@ func TestLogStore_Subscribe_SubscriptionErrors(t *testing.T) { ...@@ -137,13 +137,10 @@ func TestLogStore_Subscribe_SubscriptionErrors(t *testing.T) {
} }
func TestLogStore_Subscribe_NoClient_Panics(t *testing.T) { func TestLogStore_Subscribe_NoClient_Panics(t *testing.T) {
defer func() { require.Panics(t, func() {
if recover() == nil {
t.Error("expected nil client to panic")
}
}()
logStore, _ := newErrorLogStore(t, nil) logStore, _ := newErrorLogStore(t, nil)
require.NoError(t, logStore.Subscribe(context.Background())) _ = logStore.Subscribe(context.Background())
})
} }
func TestLogStore_Subscribe_ErrorSubscribing(t *testing.T) { func TestLogStore_Subscribe_ErrorSubscribing(t *testing.T) {
...@@ -162,11 +159,8 @@ func TestLogStore_Quit_ResetsSubscription(t *testing.T) { ...@@ -162,11 +159,8 @@ func TestLogStore_Quit_ResetsSubscription(t *testing.T) {
} }
func TestLogStore_Quit_NoSubscription_Panics(t *testing.T) { func TestLogStore_Quit_NoSubscription_Panics(t *testing.T) {
defer func() { require.Panics(t, func() {
if recover() == nil {
t.Error("expected no subscription to panic")
}
}()
logStore, _ := newErrorLogStore(t, nil) logStore, _ := newErrorLogStore(t, nil)
logStore.Quit() logStore.Quit()
})
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment