Skip to content

Commit

Permalink
Fix flaky test
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Semenyuk <[email protected]>
  • Loading branch information
alex-semenyuk committed Nov 10, 2023
1 parent 2addcdd commit 8132af3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ MOCKERY := $(GOBIN)/mockery

all: build test go-mod-tidy
test: deps
$(VGO) test ./internal/... ./cmd/... -cover -coverprofile=coverage.txt -covermode=atomic -timeout=30s
$(VGO) test ./internal/... ./cmd/... -v -short -cover -coverprofile=coverage.txt -covermode=atomic -timeout=30s
coverage.html:
$(VGO) tool cover -html=coverage.txt
coverage: test coverage.html
Expand Down
7 changes: 6 additions & 1 deletion internal/tezos/new_block_listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package tezos

import (
"testing"
"time"

"blockwatch.cc/tzgo/rpc"
"blockwatch.cc/tzgo/tezos"
Expand All @@ -11,7 +12,7 @@ import (
"github.com/stretchr/testify/mock"
)

func TestNewBlockListenerOK(t *testing.T) {
func TestNewBlockListenerOKWithDelay(t *testing.T) {
ctx, c, mRPC, done := newTestConnector(t)
defer done()

Expand All @@ -24,13 +25,17 @@ func TestNewBlockListenerOK(t *testing.T) {
Level: 12345,
},
}, nil).Maybe()
mRPC.On("MonitorBlockHeader", mock.Anything, mock.Anything).Return(nil)

req := &ffcapi.NewBlockListenerRequest{
ID: fftypes.NewUUID(),
ListenerContext: ctx,
BlockListener: make(chan<- *ffcapi.BlockHashEvent),
}

res, _, err := c.NewBlockListener(ctx, req)

time.Sleep(1 * time.Second)
assert.NoError(t, err)
assert.NotNil(t, res)
}
4 changes: 1 addition & 3 deletions internal/tezos/retry_delay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ func TestRetryDelay(t *testing.T) {
c.retry.InitialDelay = 1 * time.Microsecond

ctx, cancel := context.WithCancel(context.Background())
go func() {
cancel()
}()
cancel()

testCases := []struct {
name string
Expand Down

0 comments on commit 8132af3

Please sign in to comment.