Skip to content

Commit

Permalink
Fix log out of test
Browse files Browse the repository at this point in the history
Explicitly closing poller
  • Loading branch information
asoliman92 committed Jul 1, 2024
1 parent bf16989 commit 3723c49
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ func TestHomeChainReader(t *testing.T) {
//================================Setup HomeChainReader===============================
//ctx := testutils.Context(t)
ctx, cancelFunc := context.WithCancel(context.Background())
chainReader := helpers.SetupChainReader(t, ctx, backend, capConfAddress, cfg, "CCIPConfig")
testData := helpers.SetupReaderTestData(t, ctx, backend, capConfAddress, cfg, "CCIPConfig")
chainReader := testData.ChainReader
logPoller := testData.LogPoller
require.NoError(t, err)
pollDuration := 5 * time.Millisecond
homeChain := ccipreader.NewHomeChainReader(chainReader, logger.TestLogger(t), pollDuration)
Expand All @@ -110,14 +112,15 @@ func TestHomeChainReader(t *testing.T) {
_, err = capConfContract.ApplyChainConfigUpdates(transactor, []uint64{chainC}, nil)
require.NoError(t, err)
backend.Commit()
time.Sleep(pollDuration * 3) // Wait for the chain reader to update
time.Sleep(pollDuration * 5) // Wait for the chain reader to update
configs, err = homeChain.GetAllChainConfigs()
require.NoError(t, err)
delete(expectedChainConfigs, cciptypes.ChainSelector(chainC))
require.Equal(t, expectedChainConfigs, configs)
//================================Close HomeChain Reader===============================
t.Cleanup(cancelFunc)
require.NoError(t, homeChain.Close())
require.NoError(t, logPoller.Close())
require.NoError(t, chainReader.Close())
t.Logf("homchain reader successfully closed")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"testing"
"time"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
"github.com/ethereum/go-ethereum/common"

Expand All @@ -24,16 +23,12 @@ import (

const chainID = 1337

type TestSetupData[T any] struct {
ContractAddr common.Address
Contract *T
SimulatedBE *backends.SimulatedBackend
Auth *bind.TransactOpts
ChainReader *evm.ChainReaderService
ChainID int
type TestSetupData struct {
LogPoller logpoller.LogPoller
ChainReader evm.ChainReaderService
}

func SetupChainReader(t *testing.T, ctx context.Context, simulatedBackend *backends.SimulatedBackend, address common.Address, chainReaderConfig evmtypes.ChainReaderConfig, contractName string) evm.ChainReaderService {
func SetupReaderTestData(t *testing.T, ctx context.Context, simulatedBackend *backends.SimulatedBackend, address common.Address, chainReaderConfig evmtypes.ChainReaderConfig, contractName string) TestSetupData {

Check failure on line 31 in core/services/ocr3/plugins/ccip_integration_tests/integration_helpers.go

View workflow job for this annotation

GitHub Actions / lint

context-as-argument: context.Context should be the first parameter of a function (revive)
lggr := logger.TestLogger(t)
db := pgtest.NewSqlxDB(t)
lpOpts := logpoller.Opts{
Expand Down Expand Up @@ -63,5 +58,8 @@ func SetupChainReader(t *testing.T, ctx context.Context, simulatedBackend *backe
break
}
}
return cr
return TestSetupData{
LogPoller: lp,
ChainReader: cr,
}
}

0 comments on commit 3723c49

Please sign in to comment.