Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky test #23

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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