diff --git a/charts/chainlink-cluster/dashboard/cmd/dashboard_deploy.go b/charts/chainlink-cluster/dashboard/cmd/dashboard_deploy.go index c752794f53f..170ffa02883 100644 --- a/charts/chainlink-cluster/dashboard/cmd/dashboard_deploy.go +++ b/charts/chainlink-cluster/dashboard/cmd/dashboard_deploy.go @@ -1,12 +1,14 @@ package main import ( + "context" "os" "github.com/smartcontractkit/chainlink/v2/dashboard/dashboard" ) func main() { + ctx := context.Background() name := os.Getenv("DASHBOARD_NAME") if name == "" { panic("DASHBOARD_NAME must be provided") @@ -36,7 +38,7 @@ func main() { if err != nil { panic(err) } - if err := db.Deploy(); err != nil { + if err := db.Deploy(ctx); err != nil { panic(err) } } diff --git a/charts/chainlink-cluster/dashboard/dashboard.go b/charts/chainlink-cluster/dashboard/dashboard.go index 7918b996dd0..293cded2b0c 100644 --- a/charts/chainlink-cluster/dashboard/dashboard.go +++ b/charts/chainlink-cluster/dashboard/dashboard.go @@ -378,8 +378,7 @@ func (m *CLClusterDashboard) generate() error { } // Deploy deploys the dashboard to Grafana -func (m *CLClusterDashboard) Deploy() error { - ctx := context.Background() +func (m *CLClusterDashboard) Deploy(ctx context.Context) error { client := grabana.NewClient(&http.Client{}, m.GrafanaURL, grabana.WithAPIToken(m.GrafanaToken)) folder, err := client.FindOrCreateFolder(ctx, m.Folder) if err != nil { diff --git a/common/client/send_only_node_lifecycle.go b/common/client/send_only_node_lifecycle.go index 0f663eab30e..4d5b102b5bd 100644 --- a/common/client/send_only_node_lifecycle.go +++ b/common/client/send_only_node_lifecycle.go @@ -1,7 +1,6 @@ package client import ( - "context" "fmt" "time" @@ -14,15 +13,17 @@ import ( // It will continue checking until success and then exit permanently. func (s *sendOnlyNode[CHAIN_ID, RPC]) verifyLoop() { defer s.wg.Done() + ctx, cancel := s.chStop.NewCtx() + defer cancel() backoff := utils.NewRedialBackoff() for { select { - case <-s.chStop: + case <-ctx.Done(): return case <-time.After(backoff.Duration()): } - chainID, err := s.rpc.ChainID(context.Background()) + chainID, err := s.rpc.ChainID(ctx) if err != nil { ok := s.IfStarted(func() { if changed := s.setState(nodeStateUnreachable); changed { diff --git a/core/chains/evm/client/send_only_node_lifecycle.go b/core/chains/evm/client/send_only_node_lifecycle.go index 509be53c8a3..9d704e49389 100644 --- a/core/chains/evm/client/send_only_node_lifecycle.go +++ b/core/chains/evm/client/send_only_node_lifecycle.go @@ -1,7 +1,6 @@ package client import ( - "context" "fmt" "time" @@ -14,12 +13,14 @@ import ( // It will continue checking until success and then exit permanently. func (s *sendOnlyNode) verifyLoop() { defer s.wg.Done() + ctx, cancel := s.chStop.NewCtx() + defer cancel() backoff := utils.NewRedialBackoff() for { select { case <-time.After(backoff.Duration()): - chainID, err := s.sender.ChainID(context.Background()) + chainID, err := s.sender.ChainID(ctx) if err != nil { ok := s.IfStarted(func() { if changed := s.setState(NodeStateUnreachable); changed { @@ -60,7 +61,7 @@ func (s *sendOnlyNode) verifyLoop() { s.log.Infow("Sendonly RPC Node is online", "nodeState", s.state) return } - case <-s.chStop: + case <-ctx.Done(): return } } diff --git a/core/chains/evm/gas/models_test.go b/core/chains/evm/gas/models_test.go index 8ac94a2269c..a2dce58ee3f 100644 --- a/core/chains/evm/gas/models_test.go +++ b/core/chains/evm/gas/models_test.go @@ -1,7 +1,6 @@ package gas_test import ( - "context" "math/big" "testing" @@ -14,11 +13,12 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas/mocks" rollupMocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas/rollups/mocks" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" ) func TestWrappedEvmEstimator(t *testing.T) { t.Parallel() - ctx := context.Background() + ctx := testutils.Context(t) // fee values gasLimit := uint32(10) diff --git a/core/chains/evm/logpoller/log_poller.go b/core/chains/evm/logpoller/log_poller.go index 6676b694b0f..bb93db40378 100644 --- a/core/chains/evm/logpoller/log_poller.go +++ b/core/chains/evm/logpoller/log_poller.go @@ -130,8 +130,10 @@ type logPoller struct { // support chain, polygon, which has 2s block times, we need RPCs roughly with <= 500ms latency func NewLogPoller(orm ORM, ec Client, lggr logger.Logger, pollPeriod time.Duration, useFinalityTag bool, finalityDepth int64, backfillBatchSize int64, rpcBatchSize int64, keepFinalizedBlocksDepth int64) *logPoller { - + ctx, cancel := context.WithCancel(context.Background()) return &logPoller{ + ctx: ctx, + cancel: cancel, ec: ec, orm: orm, lggr: lggr.Named("LogPoller"), @@ -371,18 +373,15 @@ func (lp *logPoller) recvReplayComplete() { func (lp *logPoller) ReplayAsync(fromBlock int64) { lp.wg.Add(1) go func() { - if err := lp.Replay(context.Background(), fromBlock); err != nil { + if err := lp.Replay(lp.ctx, fromBlock); err != nil { lp.lggr.Error(err) } lp.wg.Done() }() } -func (lp *logPoller) Start(parentCtx context.Context) error { +func (lp *logPoller) Start(context.Context) error { return lp.StartOnce("LogPoller", func() error { - ctx, cancel := context.WithCancel(parentCtx) - lp.ctx = ctx - lp.cancel = cancel lp.wg.Add(1) go lp.run() return nil diff --git a/core/chains/evm/logpoller/log_poller_internal_test.go b/core/chains/evm/logpoller/log_poller_internal_test.go index c0d081582f7..2ef276802ba 100644 --- a/core/chains/evm/logpoller/log_poller_internal_test.go +++ b/core/chains/evm/logpoller/log_poller_internal_test.go @@ -20,6 +20,7 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/zap/zapcore" + "github.com/smartcontractkit/chainlink-common/pkg/services" evmclimocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/log_emitter" @@ -233,7 +234,6 @@ func TestLogPoller_BackupPollerStartup(t *testing.T) { func TestLogPoller_Replay(t *testing.T) { t.Parallel() addr := common.HexToAddress("0x2ab9a2dc53736b361b72d900cdf9f78f9406fbbc") - tctx := testutils.Context(t) lggr, observedLogs := logger.TestLoggerObserved(t, zapcore.ErrorLevel) chainID := testutils.FixtureChainID @@ -259,48 +259,39 @@ func TestLogPoller_Replay(t *testing.T) { lp := NewLogPoller(orm, ec, lggr, time.Hour, false, 3, 3, 3, 20) // process 1 log in block 3 - lp.PollAndSaveLogs(tctx, 4) + lp.PollAndSaveLogs(testutils.Context(t), 4) latest, err := lp.LatestBlock() require.NoError(t, err) require.Equal(t, int64(4), latest.BlockNumber) t.Run("abort before replayStart received", func(t *testing.T) { // Replay() should abort immediately if caller's context is cancelled before request signal is read - ctx, cancel := context.WithCancel(tctx) + ctx, cancel := context.WithCancel(testutils.Context(t)) cancel() err = lp.Replay(ctx, 3) assert.ErrorIs(t, err, ErrReplayRequestAborted) }) - recvStartReplay := func(parentCtx context.Context, block int64, withTimeout bool) { - var err error - var ctx context.Context - var cancel context.CancelFunc - if withTimeout { - ctx, cancel = context.WithTimeout(parentCtx, testutils.WaitTimeout(t)) - } else { - ctx, cancel = context.WithCancel(parentCtx) - } - defer cancel() + recvStartReplay := func(ctx context.Context, block int64) { select { case fromBlock := <-lp.replayStart: assert.Equal(t, block, fromBlock) case <-ctx.Done(): - err = ctx.Err() + assert.NoError(t, ctx.Err(), "Timed out waiting to receive replay request from lp.replayStart") } - assert.NoError(t, err, "Timed out waiting to receive replay request from lp.replayStart") } // Replay() should return error code received from replayComplete t.Run("returns error code on replay complete", func(t *testing.T) { + ctx := testutils.Context(t) anyErr := errors.New("any error") done := make(chan struct{}) go func() { defer close(done) - recvStartReplay(tctx, 1, true) + recvStartReplay(ctx, 1) lp.replayComplete <- anyErr }() - assert.ErrorIs(t, lp.Replay(tctx, 1), anyErr) + assert.ErrorIs(t, lp.Replay(ctx, 1), anyErr) <-done }) @@ -310,7 +301,7 @@ func TestLogPoller_Replay(t *testing.T) { done := make(chan struct{}) go func() { defer close(done) - recvStartReplay(ctx, 4, false) + recvStartReplay(ctx, 4) cancel() }() assert.ErrorIs(t, lp.Replay(ctx, 4), ErrReplayInProgress) @@ -323,29 +314,33 @@ func TestLogPoller_Replay(t *testing.T) { t.Run("client abort doesnt hang run loop", func(t *testing.T) { lp.backupPollerNextBlock = 0 - timeLeft := testutils.WaitTimeout(t) - timeout := time.After(timeLeft) - ctx, cancel := context.WithCancel(tctx) + ctx := testutils.Context(t) - var wg sync.WaitGroup pass := make(chan struct{}) cancelled := make(chan struct{}) + rctx, rcancel := context.WithCancel(testutils.Context(t)) + var wg sync.WaitGroup + defer func() { wg.Wait() }() ec.On("FilterLogs", mock.Anything, mock.Anything).Once().Return([]types.Log{log1}, nil).Run(func(args mock.Arguments) { wg.Add(1) go func() { defer wg.Done() - assert.ErrorIs(t, lp.Replay(ctx, 4), ErrReplayInProgress) + assert.ErrorIs(t, lp.Replay(rctx, 4), ErrReplayInProgress) close(cancelled) }() }) ec.On("FilterLogs", mock.Anything, mock.Anything).Once().Return([]types.Log{log1}, nil).Run(func(args mock.Arguments) { - cancel() + rcancel() wg.Add(1) go func() { defer wg.Done() - lp.replayStart <- 4 - close(pass) + select { + case lp.replayStart <- 4: + close(pass) + case <-ctx.Done(): + return + } }() // We cannot return until we're sure that Replay() received the cancellation signal, // otherwise replayComplete<- might be sent first @@ -354,24 +349,13 @@ func TestLogPoller_Replay(t *testing.T) { ec.On("FilterLogs", mock.Anything, mock.Anything).Return([]types.Log{log1}, nil).Maybe() // in case task gets delayed by >= 100ms - lp.ctx, lp.cancel = context.WithCancel(tctx) - lp.wg.Add(1) - defer func() { - select { - case <-lp.replayStart: - default: - } - wg.Wait() - lp.cancel() - lp.wg.Wait() - }() + t.Cleanup(lp.reset) + require.NoError(t, lp.Start(ctx)) + t.Cleanup(func() { assert.NoError(t, lp.Close()) }) - go func() { - lp.run() - }() select { - case <-timeout: - assert.Failf(t, "lp.run() got stuck--failed to respond to second replay event within %s", timeLeft.String()) + case <-ctx.Done(): + t.Errorf("timed out waiting for lp.run() to respond to second replay event") case <-pass: } }) @@ -383,13 +367,18 @@ func TestLogPoller_Replay(t *testing.T) { t.Run("shutdown during replay", func(t *testing.T) { lp.backupPollerNextBlock = 0 - safeToExit := make(chan struct{}) pass := make(chan struct{}) + done := make(chan struct{}) + defer func() { <-done }() + ctx := testutils.Context(t) ec.On("FilterLogs", mock.Anything, mock.Anything).Once().Return([]types.Log{log1}, nil).Run(func(args mock.Arguments) { go func() { - lp.replayStart <- 4 - close(safeToExit) + defer close(done) + select { + case lp.replayStart <- 4: + case <-ctx.Done(): + } }() }) ec.On("FilterLogs", mock.Anything, mock.Anything).Once().Return([]types.Log{log1}, nil).Run(func(args mock.Arguments) { @@ -398,71 +387,57 @@ func TestLogPoller_Replay(t *testing.T) { }) ec.On("FilterLogs", mock.Anything, mock.Anything).Return([]types.Log{log1}, nil).Maybe() // in case task gets delayed by >= 100ms - timeLeft := testutils.WaitTimeout(t) - timeout := time.After(timeLeft) - require.NoError(t, lp.Start(tctx)) - - defer func() { - select { - case <-lp.replayStart: // unblock replayStart<- goroutine if it's stuck - default: - } - <-safeToExit - lp.Close() - }() + t.Cleanup(lp.reset) + require.NoError(t, lp.Start(ctx)) + t.Cleanup(func() { assert.NoError(t, lp.Close()) }) select { - case <-timeout: - assert.Failf(t, "lp.run() failed to respond to shutdown event during replay within %s", timeLeft.String()) + case <-ctx.Done(): + t.Error("timed out waiting for lp.run() to respond to shutdown event during replay") case <-pass: } }) // ReplayAsync should return as soon as replayStart is received t.Run("ReplayAsync success", func(t *testing.T) { - lp.ctx, lp.cancel = context.WithTimeout(tctx, testutils.WaitTimeout(t)) - defer func() { - lp.replayComplete <- nil - lp.cancel() - lp.wg.Wait() - }() + t.Cleanup(lp.reset) + require.NoError(t, lp.Start(testutils.Context(t))) + t.Cleanup(func() { assert.NoError(t, lp.Close()) }) - done := make(chan struct{}) - go func() { - lp.ReplayAsync(1) - close(done) - }() - recvStartReplay(tctx, 1, true) - <-done + lp.ReplayAsync(1) + + recvStartReplay(testutils.Context(t), 1) }) t.Run("ReplayAsync error", func(t *testing.T) { - timeLeft := testutils.WaitTimeout(t) - lp.ctx, lp.cancel = context.WithTimeout(tctx, timeLeft) - defer func() { - lp.cancel() - lp.wg.Wait() - }() + t.Cleanup(lp.reset) + require.NoError(t, lp.Start(testutils.Context(t))) + t.Cleanup(func() { assert.NoError(t, lp.Close()) }) + anyErr := errors.New("async error") observedLogs.TakeAll() lp.ReplayAsync(4) - recvStartReplay(tctx, 4, true) + recvStartReplay(testutils.Context(t), 4) select { case lp.replayComplete <- anyErr: time.Sleep(2 * time.Second) case <-lp.ctx.Done(): - assert.Failf(t, "failed to receive replayComplete signal within %s", timeLeft.String()) + t.Error("timed out waiting to send replaceComplete") } require.Equal(t, 1, observedLogs.Len()) assert.Equal(t, observedLogs.All()[0].Message, anyErr.Error()) }) } +func (lp *logPoller) reset() { + lp.StateMachine = services.StateMachine{} + lp.ctx, lp.cancel = context.WithCancel(context.Background()) +} + func Test_latestBlockAndFinalityDepth(t *testing.T) { - tctx := testutils.Context(t) - lggr, _ := logger.TestLoggerObserved(t, zapcore.ErrorLevel) + lggr := logger.TestLogger(t) chainID := testutils.FixtureChainID db := pgtest.NewSqlxDB(t) orm := NewORM(chainID, db, lggr, pgtest.NewQConfig(true)) @@ -474,7 +449,7 @@ func Test_latestBlockAndFinalityDepth(t *testing.T) { ec.On("HeadByNumber", mock.Anything, mock.Anything).Return(&head, nil) lp := NewLogPoller(orm, ec, lggr, time.Hour, false, finalityDepth, 3, 3, 20) - latestBlock, lastFinalizedBlockNumber, err := lp.latestBlocks(tctx) + latestBlock, lastFinalizedBlockNumber, err := lp.latestBlocks(testutils.Context(t)) require.NoError(t, err) require.Equal(t, latestBlock.Number, head.Number) require.Equal(t, finalityDepth, latestBlock.Number-lastFinalizedBlockNumber) @@ -499,7 +474,7 @@ func Test_latestBlockAndFinalityDepth(t *testing.T) { lp := NewLogPoller(orm, ec, lggr, time.Hour, true, 3, 3, 3, 20) - latestBlock, lastFinalizedBlockNumber, err := lp.latestBlocks(tctx) + latestBlock, lastFinalizedBlockNumber, err := lp.latestBlocks(testutils.Context(t)) require.NoError(t, err) require.Equal(t, expectedLatestBlockNumber, latestBlock.Number) require.Equal(t, expectedLastFinalizedBlockNumber, lastFinalizedBlockNumber) @@ -516,7 +491,7 @@ func Test_latestBlockAndFinalityDepth(t *testing.T) { }) lp := NewLogPoller(orm, ec, lggr, time.Hour, true, 3, 3, 3, 20) - _, _, err := lp.latestBlocks(tctx) + _, _, err := lp.latestBlocks(testutils.Context(t)) require.Error(t, err) }) @@ -525,7 +500,7 @@ func Test_latestBlockAndFinalityDepth(t *testing.T) { ec.On("BatchCallContext", mock.Anything, mock.Anything).Return(fmt.Errorf("some error")) lp := NewLogPoller(orm, ec, lggr, time.Hour, true, 3, 3, 3, 20) - _, _, err := lp.latestBlocks(tctx) + _, _, err := lp.latestBlocks(testutils.Context(t)) require.Error(t, err) }) }) diff --git a/core/chains/evm/logpoller/log_poller_test.go b/core/chains/evm/logpoller/log_poller_test.go index 5f013ca9140..94589f505a6 100644 --- a/core/chains/evm/logpoller/log_poller_test.go +++ b/core/chains/evm/logpoller/log_poller_test.go @@ -626,19 +626,19 @@ func TestLogPoller_BlockTimestamps(t *testing.T) { require.Len(t, gethLogs, 2) lb, _ := th.LogPoller.LatestBlock(pg.WithParentCtx(testutils.Context(t))) - th.PollAndSaveLogs(context.Background(), lb.BlockNumber+1) + th.PollAndSaveLogs(ctx, lb.BlockNumber+1) lg1, err := th.LogPoller.Logs(0, 20, EmitterABI.Events["Log1"].ID, th.EmitterAddress1, - pg.WithParentCtx(testutils.Context(t))) + pg.WithParentCtx(ctx)) require.NoError(t, err) lg2, err := th.LogPoller.Logs(0, 20, EmitterABI.Events["Log2"].ID, th.EmitterAddress2, - pg.WithParentCtx(testutils.Context(t))) + pg.WithParentCtx(ctx)) require.NoError(t, err) // Logs should have correct timestamps - b, _ := th.Client.BlockByHash(context.Background(), lg1[0].BlockHash) + b, _ := th.Client.BlockByHash(ctx, lg1[0].BlockHash) t.Log(len(lg1), lg1[0].BlockTimestamp) assert.Equal(t, int64(b.Time()), lg1[0].BlockTimestamp.UTC().Unix(), time1) - b2, _ := th.Client.BlockByHash(context.Background(), lg2[0].BlockHash) + b2, _ := th.Client.BlockByHash(ctx, lg2[0].BlockHash) assert.Equal(t, int64(b2.Time()), lg2[0].BlockTimestamp.UTC().Unix(), time2) } diff --git a/core/chains/evm/txmgr/evm_tx_store.go b/core/chains/evm/txmgr/evm_tx_store.go index 9262c85a833..0e08d32b77a 100644 --- a/core/chains/evm/txmgr/evm_tx_store.go +++ b/core/chains/evm/txmgr/evm_tx_store.go @@ -1107,11 +1107,9 @@ ORDER BY nonce ASC return etxs, pkgerrors.Wrap(err, "FindTransactionsConfirmedInBlockRange failed") } -func saveAttemptWithNewState(q pg.Queryer, timeout time.Duration, logger logger.Logger, attempt TxAttempt, broadcastAt time.Time) error { - ctx, cancel := context.WithTimeout(context.Background(), timeout) +func saveAttemptWithNewState(ctx context.Context, q pg.Queryer, logger logger.Logger, attempt TxAttempt, broadcastAt time.Time) error { var dbAttempt DbEthTxAttempt dbAttempt.FromTxAttempt(&attempt) - defer cancel() return pg.SqlxTransaction(ctx, q, logger, func(tx pg.Queryer) error { // In case of null broadcast_at (shouldn't happen) we don't want to // update anyway because it indicates a state where broadcast_at makes @@ -1133,15 +1131,19 @@ func (o *evmTxStore) SaveInsufficientFundsAttempt(ctx context.Context, timeout t return errors.New("expected state to be either in_progress or insufficient_eth") } attempt.State = txmgrtypes.TxAttemptInsufficientFunds - return pkgerrors.Wrap(saveAttemptWithNewState(qq, timeout, o.logger, *attempt, broadcastAt), "saveInsufficientEthAttempt failed") + ctx, cancel = context.WithTimeout(ctx, timeout) + defer cancel() + return pkgerrors.Wrap(saveAttemptWithNewState(ctx, qq, o.logger, *attempt, broadcastAt), "saveInsufficientEthAttempt failed") } -func saveSentAttempt(q pg.Queryer, timeout time.Duration, logger logger.Logger, attempt *TxAttempt, broadcastAt time.Time) error { +func saveSentAttempt(ctx context.Context, q pg.Queryer, timeout time.Duration, logger logger.Logger, attempt *TxAttempt, broadcastAt time.Time) error { if attempt.State != txmgrtypes.TxAttemptInProgress { return errors.New("expected state to be in_progress") } attempt.State = txmgrtypes.TxAttemptBroadcast - return pkgerrors.Wrap(saveAttemptWithNewState(q, timeout, logger, *attempt, broadcastAt), "saveSentAttempt failed") + ctx, cancel := context.WithTimeout(ctx, timeout) + defer cancel() + return pkgerrors.Wrap(saveAttemptWithNewState(ctx, q, logger, *attempt, broadcastAt), "saveSentAttempt failed") } func (o *evmTxStore) SaveSentAttempt(ctx context.Context, timeout time.Duration, attempt *TxAttempt, broadcastAt time.Time) error { @@ -1149,7 +1151,7 @@ func (o *evmTxStore) SaveSentAttempt(ctx context.Context, timeout time.Duration, ctx, cancel = o.mergeContexts(ctx) defer cancel() qq := o.q.WithOpts(pg.WithParentCtx(ctx)) - return saveSentAttempt(qq, timeout, o.logger, attempt, broadcastAt) + return saveSentAttempt(ctx, qq, timeout, o.logger, attempt, broadcastAt) } func (o *evmTxStore) SaveConfirmedMissingReceiptAttempt(ctx context.Context, timeout time.Duration, attempt *TxAttempt, broadcastAt time.Time) error { @@ -1158,7 +1160,7 @@ func (o *evmTxStore) SaveConfirmedMissingReceiptAttempt(ctx context.Context, tim defer cancel() qq := o.q.WithOpts(pg.WithParentCtx(ctx)) err := qq.Transaction(func(tx pg.Queryer) error { - if err := saveSentAttempt(tx, timeout, o.logger, attempt, broadcastAt); err != nil { + if err := saveSentAttempt(ctx, tx, timeout, o.logger, attempt, broadcastAt); err != nil { return err } if _, err := tx.Exec(`UPDATE evm.txes SET state = 'confirmed_missing_receipt' WHERE id = $1`, attempt.TxID); err != nil { diff --git a/core/cmd/ocr2vrf_configure_commands.go b/core/cmd/ocr2vrf_configure_commands.go index bb4cef4708b..cf014d5e5dc 100644 --- a/core/cmd/ocr2vrf_configure_commands.go +++ b/core/cmd/ocr2vrf_configure_commands.go @@ -126,6 +126,7 @@ chainID = %d const forwarderAdditionalEOACount = 4 func (s *Shell) ConfigureOCR2VRFNode(c *cli.Context, owner *bind.TransactOpts, ec *ethclient.Client) (*SetupOCR2VRFNodePayload, error) { + ctx := s.ctx() lggr := logger.Sugared(s.Logger.Named("ConfigureOCR2VRFNode")) lggr.Infow( fmt.Sprintf("Configuring Chainlink Node for job type %s %s at commit %s", c.String("job-type"), static.Version, static.Sha), @@ -156,15 +157,13 @@ func (s *Shell) ConfigureOCR2VRFNode(c *cli.Context, owner *bind.TransactOpts, e cfg := s.Config ldb := pg.NewLockedDB(cfg.AppID(), cfg.Database(), cfg.Database().Lock(), lggr) - rootCtx, cancel := context.WithCancel(context.Background()) - defer cancel() - if err = ldb.Open(rootCtx); err != nil { + if err = ldb.Open(ctx); err != nil { return nil, s.errorOut(errors.Wrap(err, "opening db")) } defer lggr.ErrorIfFn(ldb.Close, "Error closing db") - app, err := s.AppFactory.NewApplication(rootCtx, s.Config, lggr, ldb.DB()) + app, err := s.AppFactory.NewApplication(ctx, s.Config, lggr, ldb.DB()) if err != nil { return nil, s.errorOut(errors.Wrap(err, "fatal error instantiating application")) } @@ -179,7 +178,7 @@ func (s *Shell) ConfigureOCR2VRFNode(c *cli.Context, owner *bind.TransactOpts, e } // Start application. - err = app.Start(rootCtx) + err = app.Start(ctx) if err != nil { return nil, s.errorOut(err) } @@ -243,10 +242,10 @@ func (s *Shell) ConfigureOCR2VRFNode(c *cli.Context, owner *bind.TransactOpts, e if c.Bool("isBootstrapper") { // Set up bootstrapper job if bootstrapper. - err = createBootstrapperJob(lggr, c, app) + err = createBootstrapperJob(ctx, lggr, c, app) } else if c.String("job-type") == "DKG" { // Set up DKG job. - err = createDKGJob(lggr, app, dkgTemplateArgs{ + err = createDKGJob(ctx, lggr, app, dkgTemplateArgs{ contractID: c.String("contractID"), ocrKeyBundleID: ocr2.ID(), p2pv2BootstrapperPeerID: peerID, @@ -260,7 +259,7 @@ func (s *Shell) ConfigureOCR2VRFNode(c *cli.Context, owner *bind.TransactOpts, e }) } else if c.String("job-type") == "OCR2VRF" { // Set up OCR2VRF job. - err = createOCR2VRFJob(lggr, app, ocr2vrfTemplateArgs{ + err = createOCR2VRFJob(ctx, lggr, app, ocr2vrfTemplateArgs{ dkgTemplateArgs: dkgTemplateArgs{ contractID: c.String("dkg-address"), ocrKeyBundleID: ocr2.ID(), @@ -320,12 +319,13 @@ func (s *Shell) appendForwarders(chainID int64, ks keystore.Eth, sendingKeys []s } func (s *Shell) authorizeForwarder(c *cli.Context, db *sqlx.DB, lggr logger.Logger, chainID int64, ec *ethclient.Client, owner *bind.TransactOpts, sendingKeysAddresses []common.Address) error { + ctx := s.ctx() // Replace the transmitter ID with the forwarder address. forwarderAddress := c.String("forwarder-address") // We have to set the authorized senders on-chain here, otherwise the job spawner will fail as the // forwarder will not be recognized. - ctx, cancel := context.WithTimeout(context.Background(), 300*time.Second) + ctx, cancel := context.WithTimeout(ctx, 300*time.Second) defer cancel() f, err := authorized_forwarder.NewAuthorizedForwarder(common.HexToAddress(forwarderAddress), ec) if err != nil { @@ -400,7 +400,7 @@ func setupKeystore(cli *Shell, app chainlink.Application, keyStore keystore.Mast return nil } -func createBootstrapperJob(lggr logger.Logger, c *cli.Context, app chainlink.Application) error { +func createBootstrapperJob(ctx context.Context, lggr logger.Logger, c *cli.Context, app chainlink.Application) error { sp := fmt.Sprintf(BootstrapTemplate, c.Int64("chainID"), c.String("contractID"), @@ -418,7 +418,7 @@ func createBootstrapperJob(lggr logger.Logger, c *cli.Context, app chainlink.App } jb.BootstrapSpec = &os - err = app.AddJobV2(context.Background(), &jb) + err = app.AddJobV2(ctx, &jb) if err != nil { return errors.Wrap(err, "failed to add job") } @@ -430,7 +430,7 @@ func createBootstrapperJob(lggr logger.Logger, c *cli.Context, app chainlink.App return nil } -func createDKGJob(lggr logger.Logger, app chainlink.Application, args dkgTemplateArgs) error { +func createDKGJob(ctx context.Context, lggr logger.Logger, app chainlink.Application, args dkgTemplateArgs) error { sp := fmt.Sprintf(DKGTemplate, args.contractID, args.ocrKeyBundleID, @@ -455,7 +455,7 @@ func createDKGJob(lggr logger.Logger, app chainlink.Application, args dkgTemplat } jb.OCR2OracleSpec = &os - err = app.AddJobV2(context.Background(), &jb) + err = app.AddJobV2(ctx, &jb) if err != nil { return errors.Wrap(err, "failed to add job") } @@ -464,7 +464,7 @@ func createDKGJob(lggr logger.Logger, app chainlink.Application, args dkgTemplat return nil } -func createOCR2VRFJob(lggr logger.Logger, app chainlink.Application, args ocr2vrfTemplateArgs) error { +func createOCR2VRFJob(ctx context.Context, lggr logger.Logger, app chainlink.Application, args ocr2vrfTemplateArgs) error { var sendingKeysString = fmt.Sprintf(`"%s"`, args.sendingKeys[0]) for x := 1; x < len(args.sendingKeys); x++ { sendingKeysString = fmt.Sprintf(`%s,"%s"`, sendingKeysString, args.sendingKeys[x]) @@ -498,7 +498,7 @@ func createOCR2VRFJob(lggr logger.Logger, app chainlink.Application, args ocr2vr } jb.OCR2OracleSpec = &os - err = app.AddJobV2(context.Background(), &jb) + err = app.AddJobV2(ctx, &jb) if err != nil { return errors.Wrap(err, "failed to add job") } diff --git a/core/internal/cltest/cltest.go b/core/internal/cltest/cltest.go index 02aa2de0cc0..cf3f4f5c073 100644 --- a/core/internal/cltest/cltest.go +++ b/core/internal/cltest/cltest.go @@ -1076,7 +1076,7 @@ type TransactionReceipter interface { func RequireTxSuccessful(t testing.TB, client TransactionReceipter, txHash common.Hash) *types.Receipt { t.Helper() - r, err := client.TransactionReceipt(context.Background(), txHash) + r, err := client.TransactionReceipt(testutils.Context(t), txHash) require.NoError(t, err) require.NotNil(t, r) require.Equal(t, uint64(1), r.Status) diff --git a/core/internal/testutils/pgtest/txdb_test.go b/core/internal/testutils/pgtest/txdb_test.go index c1aeef4b8c2..37339bf28be 100644 --- a/core/internal/testutils/pgtest/txdb_test.go +++ b/core/internal/testutils/pgtest/txdb_test.go @@ -8,6 +8,8 @@ import ( "github.com/google/uuid" "github.com/jmoiron/sqlx" "github.com/stretchr/testify/assert" + + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" ) func TestTxDBDriver(t *testing.T) { @@ -35,7 +37,7 @@ func TestTxDBDriver(t *testing.T) { ensureValuesPresent(t, db) t.Run("Cancel of tx's context does not trigger rollback of driver's tx", func(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(testutils.Context(t)) _, err := db.BeginTx(ctx, nil) assert.NoError(t, err) cancel() diff --git a/core/services/blockhashstore/bhs_test.go b/core/services/blockhashstore/bhs_test.go index 5c501a62ac9..44205ec7b86 100644 --- a/core/services/blockhashstore/bhs_test.go +++ b/core/services/blockhashstore/bhs_test.go @@ -1,7 +1,6 @@ package blockhashstore_test import ( - "context" "testing" "github.com/ethereum/go-ethereum/common" @@ -12,6 +11,7 @@ import ( txmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr/mocks" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/blockhash_store" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" @@ -66,9 +66,11 @@ func TestStoreRotatesFromAddresses(t *testing.T) { return tx.FromAddress.String() == k2.Address.String() })).Once().Return(txmgr.Tx{}, nil) + ctx := testutils.Context(t) + // store 2 blocks - err = bhs.Store(context.Background(), 1) + err = bhs.Store(ctx, 1) require.NoError(t, err) - err = bhs.Store(context.Background(), 2) + err = bhs.Store(ctx, 2) require.NoError(t, err) } diff --git a/core/services/feeds/service.go b/core/services/feeds/service.go index da19a33abc8..32a8432f876 100644 --- a/core/services/feeds/service.go +++ b/core/services/feeds/service.go @@ -186,7 +186,7 @@ func (s *service) RegisterManager(ctx context.Context, params RegisterManagerPar } var id int64 - q := s.q.WithOpts(pg.WithParentCtx(context.Background())) + q := s.q.WithOpts(pg.WithParentCtx(ctx)) err = q.Transaction(func(tx pg.Queryer) error { var txerr error diff --git a/core/services/gateway/handlers/handler.dummy_test.go b/core/services/gateway/handlers/handler.dummy_test.go index c2c7a7a12a3..c3f23935e67 100644 --- a/core/services/gateway/handlers/handler.dummy_test.go +++ b/core/services/gateway/handlers/handler.dummy_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/require" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/gateway/api" "github.com/smartcontractkit/chainlink/v2/core/services/gateway/config" @@ -41,15 +42,17 @@ func TestDummyHandler_BasicFlow(t *testing.T) { require.NoError(t, err) connMgr.SetHandler(handler) + ctx := testutils.Context(t) + // User request msg := api.Message{Body: api.MessageBody{MessageId: "1234"}} callbackCh := make(chan handlers.UserCallbackPayload, 1) - require.NoError(t, handler.HandleUserMessage(context.Background(), &msg, callbackCh)) + require.NoError(t, handler.HandleUserMessage(ctx, &msg, callbackCh)) require.Equal(t, 2, connMgr.sendCounter) // Responses from both nodes - require.NoError(t, handler.HandleNodeMessage(context.Background(), &msg, "addr_1")) - require.NoError(t, handler.HandleNodeMessage(context.Background(), &msg, "addr_2")) + require.NoError(t, handler.HandleNodeMessage(ctx, &msg, "addr_1")) + require.NoError(t, handler.HandleNodeMessage(ctx, &msg, "addr_2")) response := <-callbackCh require.Equal(t, "1234", response.Msg.Body.MessageId) } diff --git a/core/services/job/job_orm_test.go b/core/services/job/job_orm_test.go index 87ee15873d5..21035140f54 100644 --- a/core/services/job/job_orm_test.go +++ b/core/services/job/job_orm_test.go @@ -1615,7 +1615,7 @@ func Test_FindJobWithoutSpecErrors(t *testing.T) { jb, err = orm.FindJobWithoutSpecErrors(jobSpec.ID) require.NoError(t, err) - jbWithErrors, err := orm.FindJobTx(jobSpec.ID) + jbWithErrors, err := orm.FindJobTx(testutils.Context(t), jobSpec.ID) require.NoError(t, err) assert.Equal(t, len(jb.JobSpecErrors), 0) diff --git a/core/services/job/mocks/orm.go b/core/services/job/mocks/orm.go index 3d858f81320..9e18573f4e5 100644 --- a/core/services/job/mocks/orm.go +++ b/core/services/job/mocks/orm.go @@ -247,23 +247,23 @@ func (_m *ORM) FindJobIDsWithBridge(name string) ([]int32, error) { return r0, r1 } -// FindJobTx provides a mock function with given fields: id -func (_m *ORM) FindJobTx(id int32) (job.Job, error) { - ret := _m.Called(id) +// FindJobTx provides a mock function with given fields: ctx, id +func (_m *ORM) FindJobTx(ctx context.Context, id int32) (job.Job, error) { + ret := _m.Called(ctx, id) var r0 job.Job var r1 error - if rf, ok := ret.Get(0).(func(int32) (job.Job, error)); ok { - return rf(id) + if rf, ok := ret.Get(0).(func(context.Context, int32) (job.Job, error)); ok { + return rf(ctx, id) } - if rf, ok := ret.Get(0).(func(int32) job.Job); ok { - r0 = rf(id) + if rf, ok := ret.Get(0).(func(context.Context, int32) job.Job); ok { + r0 = rf(ctx, id) } else { r0 = ret.Get(0).(job.Job) } - if rf, ok := ret.Get(1).(func(int32) error); ok { - r1 = rf(id) + if rf, ok := ret.Get(1).(func(context.Context, int32) error); ok { + r1 = rf(ctx, id) } else { r1 = ret.Error(1) } diff --git a/core/services/job/orm.go b/core/services/job/orm.go index ba102c6bb8b..c5f533c3d20 100644 --- a/core/services/job/orm.go +++ b/core/services/job/orm.go @@ -49,7 +49,7 @@ type ORM interface { InsertJob(job *Job, qopts ...pg.QOpt) error CreateJob(jb *Job, qopts ...pg.QOpt) error FindJobs(offset, limit int) ([]Job, int, error) - FindJobTx(id int32) (Job, error) + FindJobTx(ctx context.Context, id int32) (Job, error) FindJob(ctx context.Context, id int32) (Job, error) FindJobByExternalJobID(uuid uuid.UUID, qopts ...pg.QOpt) (Job, error) FindJobIDByAddress(address ethkey.EIP55Address, evmChainID *utils.Big, qopts ...pg.QOpt) (int32, error) @@ -782,8 +782,8 @@ func LoadConfigVarsOCR(evmOcrCfg evmconfig.OCR, ocrCfg OCRConfig, os OCROracleSp return LoadConfigVarsLocalOCR(evmOcrCfg, os, ocrCfg), nil } -func (o *orm) FindJobTx(id int32) (Job, error) { - ctx, cancel := context.WithTimeout(context.Background(), o.cfg.DefaultQueryTimeout()) +func (o *orm) FindJobTx(ctx context.Context, id int32) (Job, error) { + ctx, cancel := context.WithTimeout(ctx, o.cfg.DefaultQueryTimeout()) defer cancel() return o.FindJob(ctx, id) } diff --git a/core/services/keystore/starknet_test.go b/core/services/keystore/starknet_test.go index df9516f8710..7fc5718bac0 100644 --- a/core/services/keystore/starknet_test.go +++ b/core/services/keystore/starknet_test.go @@ -1,7 +1,6 @@ package keystore_test import ( - "context" "fmt" "math/big" "testing" @@ -13,6 +12,7 @@ import ( "github.com/smartcontractkit/caigo" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/services/keystore" @@ -121,13 +121,13 @@ func TestStarknetSigner(t *testing.T) { // on existing sender id t.Run("key exists", func(t *testing.T) { baseKs.On("Get", starknetSenderAddr).Return(starkKey, nil) - signed, err := lk.Sign(context.Background(), starknetSenderAddr, nil) + signed, err := lk.Sign(testutils.Context(t), starknetSenderAddr, nil) require.Nil(t, signed) require.NoError(t, err) }) t.Run("key doesn't exists", func(t *testing.T) { baseKs.On("Get", mock.Anything).Return(starkkey.Key{}, fmt.Errorf("key doesn't exist")) - signed, err := lk.Sign(context.Background(), "not an address", nil) + signed, err := lk.Sign(testutils.Context(t), "not an address", nil) require.Nil(t, signed) require.Error(t, err) }) @@ -140,7 +140,7 @@ func TestStarknetSigner(t *testing.T) { baseKs.On("Get", starknetSenderAddr).Return(starkKey, nil) hash, err := caigo.Curve.PedersenHash([]*big.Int{big.NewInt(42)}) require.NoError(t, err) - r, s, err := adapter.Sign(context.Background(), starknetSenderAddr, hash) + r, s, err := adapter.Sign(testutils.Context(t), starknetSenderAddr, hash) require.NoError(t, err) require.NotNil(t, r) require.NotNil(t, s) diff --git a/core/services/ocr2/plugins/generic/pipeline_runner_adapter_test.go b/core/services/ocr2/plugins/generic/pipeline_runner_adapter_test.go index f70e0dd443a..c2060a92905 100644 --- a/core/services/ocr2/plugins/generic/pipeline_runner_adapter_test.go +++ b/core/services/ocr2/plugins/generic/pipeline_runner_adapter_test.go @@ -14,6 +14,7 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/types" "github.com/smartcontractkit/chainlink/v2/core/bridges" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" _ "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" @@ -53,7 +54,7 @@ func TestAdapter_Integration(t *testing.T) { http.DefaultClient, ) pra := generic.NewPipelineRunnerAdapter(logger, job.Job{}, pr) - results, err := pra.ExecuteRun(context.Background(), spec, types.Vars{Vars: map[string]interface{}{"val": 1}}, types.Options{}) + results, err := pra.ExecuteRun(testutils.Context(t), spec, types.Vars{Vars: map[string]interface{}{"val": 1}}, types.Options{}) require.NoError(t, err) finalResult := results[0].Value.(decimal.Decimal) @@ -85,7 +86,7 @@ func TestAdapter_AddsDefaultVars(t *testing.T) { jobID, externalJobID, name := int32(100), uuid.New(), null.StringFrom("job-name") pra := generic.NewPipelineRunnerAdapter(logger, job.Job{ID: jobID, ExternalJobID: externalJobID, Name: name}, mpr) - _, err := pra.ExecuteRun(context.Background(), spec, types.Vars{}, types.Options{}) + _, err := pra.ExecuteRun(testutils.Context(t), spec, types.Vars{}, types.Options{}) require.NoError(t, err) gotName, err := mpr.vars.Get("jb.name") @@ -107,8 +108,8 @@ func TestPipelineRunnerAdapter_SetsVarsOnSpec(t *testing.T) { jobID, externalJobID, name, jobType := int32(100), uuid.New(), null.StringFrom("job-name"), job.Type("generic") pra := generic.NewPipelineRunnerAdapter(logger, job.Job{ID: jobID, ExternalJobID: externalJobID, Name: name, Type: jobType}, mpr) - maxDuration := time.Duration(100 * time.Second) - _, err := pra.ExecuteRun(context.Background(), spec, types.Vars{}, types.Options{MaxTaskDuration: maxDuration}) + maxDuration := 100 * time.Second + _, err := pra.ExecuteRun(testutils.Context(t), spec, types.Vars{}, types.Options{MaxTaskDuration: maxDuration}) require.NoError(t, err) assert.Equal(t, jobID, mpr.spec.JobID) diff --git a/core/services/ocr2/plugins/generic/telemetry_adapter_test.go b/core/services/ocr2/plugins/generic/telemetry_adapter_test.go index e137343f2b4..24f422bf0cb 100644 --- a/core/services/ocr2/plugins/generic/telemetry_adapter_test.go +++ b/core/services/ocr2/plugins/generic/telemetry_adapter_test.go @@ -1,13 +1,14 @@ package generic_test import ( - "context" "testing" - "github.com/smartcontractkit/libocr/commontypes" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/smartcontractkit/libocr/commontypes" + + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/generic" "github.com/smartcontractkit/chainlink/v2/core/services/synchronization" ) @@ -88,7 +89,7 @@ func TestTelemetryAdapter(t *testing.T) { } for _, test := range tests { t.Run(test.name, func(t *testing.T) { - err := ta.Send(context.Background(), test.networkID, test.chainID, test.contractID, test.telemetryType, test.payload) + err := ta.Send(testutils.Context(t), test.networkID, test.chainID, test.contractID, test.telemetryType, test.payload) if test.errorMsg != "" { assert.ErrorContains(t, err, test.errorMsg) } else { diff --git a/core/services/ocr2/plugins/mercury/helpers_test.go b/core/services/ocr2/plugins/mercury/helpers_test.go index 588f772120e..ed59213840c 100644 --- a/core/services/ocr2/plugins/mercury/helpers_test.go +++ b/core/services/ocr2/plugins/mercury/helpers_test.go @@ -138,14 +138,14 @@ func (node *Node) AddJob(t *testing.T, spec string) { c := node.App.GetConfig() job, err := validate.ValidatedOracleSpecToml(c.OCR2(), c.Insecure(), spec) require.NoError(t, err) - err = node.App.AddJobV2(context.Background(), &job) + err = node.App.AddJobV2(testutils.Context(t), &job) require.NoError(t, err) } func (node *Node) AddBootstrapJob(t *testing.T, spec string) { job, err := ocrbootstrap.ValidatedBootstrapSpecToml(spec) require.NoError(t, err) - err = node.App.AddJobV2(context.Background(), &job) + err = node.App.AddJobV2(testutils.Context(t), &job) require.NoError(t, err) } diff --git a/core/services/ocr2/plugins/ocr2keeper/evm20/registry_test.go b/core/services/ocr2/plugins/ocr2keeper/evm20/registry_test.go index 8662bfd0475..340bd923577 100644 --- a/core/services/ocr2/plugins/ocr2keeper/evm20/registry_test.go +++ b/core/services/ocr2/plugins/ocr2keeper/evm20/registry_test.go @@ -1,21 +1,22 @@ package evm import ( - "context" "fmt" "math/big" "testing" "time" "github.com/ethereum/go-ethereum/common" - ocr2keepers "github.com/smartcontractkit/ocr2keepers/pkg/v2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" + ocr2keepers "github.com/smartcontractkit/ocr2keepers/pkg/v2" + commonmocks "github.com/smartcontractkit/chainlink/v2/common/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller/mocks" evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/utils" ) @@ -54,7 +55,7 @@ func TestGetActiveUpkeepKeys(t *testing.T) { active: actives, } - keys, err := rg.GetActiveUpkeepIDs(context.Background()) + keys, err := rg.GetActiveUpkeepIDs(testutils.Context(t)) if test.ExpectedErr != nil { assert.ErrorIs(t, err, test.ExpectedErr) diff --git a/core/services/ocr2/plugins/ocr2keeper/evm21/block_subscriber_test.go b/core/services/ocr2/plugins/ocr2keeper/evm21/block_subscriber_test.go index 004b5fac6cc..afb9d4a0919 100644 --- a/core/services/ocr2/plugins/ocr2keeper/evm21/block_subscriber_test.go +++ b/core/services/ocr2/plugins/ocr2keeper/evm21/block_subscriber_test.go @@ -1,16 +1,16 @@ package evm import ( - "context" "fmt" "testing" "time" "github.com/ethereum/go-ethereum/common" - ocr2keepers "github.com/smartcontractkit/ocr2keepers/pkg/v3/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" + ocr2keepers "github.com/smartcontractkit/ocr2keepers/pkg/v3/types" + commonmocks "github.com/smartcontractkit/chainlink/v2/common/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/headtracker/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" @@ -304,7 +304,7 @@ func TestBlockSubscriber_Start(t *testing.T) { bs := NewBlockSubscriber(hb, lp, finality, lggr) bs.blockHistorySize = historySize bs.blockSize = blockSize - err := bs.Start(context.Background()) + err := bs.Start(testutils.Context(t)) assert.Nil(t, err) h97 := evmtypes.Head{ diff --git a/core/services/ocr2/plugins/ocr2keeper/evm21/logprovider/block_time_test.go b/core/services/ocr2/plugins/ocr2keeper/evm21/logprovider/block_time_test.go index 7009cfaa9b2..683ba378940 100644 --- a/core/services/ocr2/plugins/ocr2keeper/evm21/logprovider/block_time_test.go +++ b/core/services/ocr2/plugins/ocr2keeper/evm21/logprovider/block_time_test.go @@ -1,7 +1,6 @@ package logprovider import ( - "context" "fmt" "testing" "time" @@ -11,6 +10,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" lpmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller/mocks" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" ) func TestBlockTimeResolver_BlockTime(t *testing.T) { @@ -63,8 +63,7 @@ func TestBlockTimeResolver_BlockTime(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() + ctx := testutils.Context(t) lp := new(lpmocks.LogPoller) resolver := newBlockTimeResolver(lp) diff --git a/core/services/ocr2/plugins/ocr2keeper/evm21/logprovider/integration_test.go b/core/services/ocr2/plugins/ocr2keeper/evm21/logprovider/integration_test.go index 0df774d5dfd..c7db01d8788 100644 --- a/core/services/ocr2/plugins/ocr2keeper/evm21/logprovider/integration_test.go +++ b/core/services/ocr2/plugins/ocr2keeper/evm21/logprovider/integration_test.go @@ -614,10 +614,11 @@ func deployUpkeepCounter( backend *backends.SimulatedBackend, account *bind.TransactOpts, logProvider logprovider.LogEventProvider, -) ([]*big.Int, []common.Address, []*log_upkeep_counter_wrapper.LogUpkeepCounter) { - var ids []*big.Int - var contracts []*log_upkeep_counter_wrapper.LogUpkeepCounter - var contractsAddrs []common.Address +) ( + ids []*big.Int, + contractsAddrs []common.Address, + contracts []*log_upkeep_counter_wrapper.LogUpkeepCounter, +) { for i := 0; i < n; i++ { upkeepAddr, _, upkeepContract, err := log_upkeep_counter_wrapper.DeployLogUpkeepCounter( account, backend, @@ -633,7 +634,7 @@ func deployUpkeepCounter( upkeepID := ocr2keepers.UpkeepIdentifier(append(common.LeftPadBytes([]byte{1}, 16), upkeepAddr[:16]...)) id := upkeepID.BigInt() ids = append(ids, id) - b, err := ethClient.BlockByHash(context.Background(), backend.Commit()) + b, err := ethClient.BlockByHash(ctx, backend.Commit()) require.NoError(t, err) bn := b.Number() err = logProvider.RegisterFilter(ctx, logprovider.FilterOptions{ @@ -643,7 +644,7 @@ func deployUpkeepCounter( }) require.NoError(t, err) } - return ids, contractsAddrs, contracts + return } func newPlainLogTriggerConfig(upkeepAddr common.Address) logprovider.LogTriggerConfig { diff --git a/core/services/ocr2/plugins/ocr2keeper/evm21/logprovider/provider_life_cycle_test.go b/core/services/ocr2/plugins/ocr2keeper/evm21/logprovider/provider_life_cycle_test.go index 03395cb5b5f..b28b45fcb42 100644 --- a/core/services/ocr2/plugins/ocr2keeper/evm21/logprovider/provider_life_cycle_test.go +++ b/core/services/ocr2/plugins/ocr2keeper/evm21/logprovider/provider_life_cycle_test.go @@ -1,19 +1,20 @@ package logprovider import ( - "context" "fmt" "math/big" "testing" "github.com/ethereum/go-ethereum/common" - ocr2keepers "github.com/smartcontractkit/ocr2keepers/pkg/v3/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + ocr2keepers "github.com/smartcontractkit/ocr2keepers/pkg/v3/types" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller/mocks" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evm21/core" ) @@ -103,8 +104,7 @@ func TestLogEventProvider_LifeCycle(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() + ctx := testutils.Context(t) if tc.mockPoller { lp := new(mocks.LogPoller) @@ -144,8 +144,7 @@ func TestLogEventProvider_LifeCycle(t *testing.T) { } func TestEventLogProvider_RefreshActiveUpkeeps(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() + ctx := testutils.Context(t) mp := new(mocks.LogPoller) mp.On("RegisterFilter", mock.Anything).Return(nil) mp.On("UnregisterFilter", mock.Anything).Return(nil) diff --git a/core/services/ocr2/plugins/ocr2keeper/evm21/logprovider/provider_test.go b/core/services/ocr2/plugins/ocr2keeper/evm21/logprovider/provider_test.go index a8e33ba23b7..c6ebb1c51a3 100644 --- a/core/services/ocr2/plugins/ocr2keeper/evm21/logprovider/provider_test.go +++ b/core/services/ocr2/plugins/ocr2keeper/evm21/logprovider/provider_test.go @@ -16,6 +16,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller/mocks" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/logger" "golang.org/x/time/rate" @@ -174,8 +175,7 @@ func TestLogEventProvider_ScheduleReadJobs(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() + ctx := testutils.Context(t) readInterval := 10 * time.Millisecond opts := NewOptions(200) @@ -239,8 +239,7 @@ func TestLogEventProvider_ScheduleReadJobs(t *testing.T) { } func TestLogEventProvider_ReadLogs(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() + ctx := testutils.Context(t) mp := new(mocks.LogPoller) diff --git a/core/services/ocr2/plugins/ocr2keeper/evm21/logprovider/recoverer_test.go b/core/services/ocr2/plugins/ocr2keeper/evm21/logprovider/recoverer_test.go index c882a22bc1a..77b0eec5454 100644 --- a/core/services/ocr2/plugins/ocr2keeper/evm21/logprovider/recoverer_test.go +++ b/core/services/ocr2/plugins/ocr2keeper/evm21/logprovider/recoverer_test.go @@ -11,11 +11,12 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/pkg/errors" - ocr2keepers "github.com/smartcontractkit/ocr2keepers/pkg/v3/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + ocr2keepers "github.com/smartcontractkit/ocr2keepers/pkg/v3/types" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" lpmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller/mocks" @@ -29,8 +30,7 @@ import ( ) func TestLogRecoverer_GetRecoverables(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() + ctx := testutils.Context(t) lp := &lpmocks.LogPoller{} lp.On("LatestBlock", mock.Anything).Return(logpoller.LogPollerBlock{BlockNumber: 100}, nil) r := NewLogRecoverer(logger.TestLogger(t), lp, nil, nil, nil, nil, NewOptions(200)) @@ -213,8 +213,7 @@ func TestLogRecoverer_Clean(t *testing.T) { } func TestLogRecoverer_Recover(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() + ctx := testutils.Context(t) tests := []struct { name string @@ -1079,7 +1078,7 @@ func TestLogRecoverer_GetProposalData(t *testing.T) { recoverer.states = tc.stateReader } - b, err := recoverer.GetProposalData(context.Background(), tc.proposal) + b, err := recoverer.GetProposalData(testutils.Context(t), tc.proposal) if tc.expectErr { assert.Error(t, err) assert.Equal(t, tc.wantErr.Error(), err.Error()) diff --git a/core/services/ocr2/plugins/ocr2keeper/evm21/mercury/streams/streams_test.go b/core/services/ocr2/plugins/ocr2keeper/evm21/mercury/streams/streams_test.go index 194d74febba..0653796f413 100644 --- a/core/services/ocr2/plugins/ocr2keeper/evm21/mercury/streams/streams_test.go +++ b/core/services/ocr2/plugins/ocr2keeper/evm21/mercury/streams/streams_test.go @@ -2,7 +2,6 @@ package streams import ( "bytes" - "context" "encoding/json" "fmt" "io" @@ -20,11 +19,13 @@ import ( "github.com/stretchr/testify/assert" - ocr2keepers "github.com/smartcontractkit/ocr2keepers/pkg/v3/types" "github.com/stretchr/testify/mock" + ocr2keepers "github.com/smartcontractkit/ocr2keepers/pkg/v3/types" + evmClientMocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" iregistry21 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_keeper_registry_master_wrapper_2_1" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evm21/mercury" v02 "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evm21/mercury/v02" v03 "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evm21/mercury/v03" @@ -257,7 +258,7 @@ func TestStreams_CheckCallback(t *testing.T) { }).Once() s.client = client - state, retryable, _, err := s.checkCallback(context.Background(), tt.values, tt.lookup) + state, retryable, _, err := s.checkCallback(testutils.Context(t), tt.values, tt.lookup) tt.wantErr(t, err, fmt.Sprintf("Error asserion failed: %v", tt.name)) assert.Equal(t, tt.state, state) assert.Equal(t, tt.retryable, retryable) @@ -719,7 +720,7 @@ func TestStreams_StreamsLookup(t *testing.T) { }).Once() } - got := s.Lookup(context.Background(), tt.input) + got := s.Lookup(testutils.Context(t), tt.input) assert.Equal(t, tt.expectedResults, got, tt.name) }) } diff --git a/core/services/ocr2/plugins/ocr2keeper/evm21/mercury/v02/v02_request_test.go b/core/services/ocr2/plugins/ocr2keeper/evm21/mercury/v02/v02_request_test.go index 17ef8515fd1..2aecc0df771 100644 --- a/core/services/ocr2/plugins/ocr2keeper/evm21/mercury/v02/v02_request_test.go +++ b/core/services/ocr2/plugins/ocr2keeper/evm21/mercury/v02/v02_request_test.go @@ -2,7 +2,6 @@ package v02 import ( "bytes" - "context" "encoding/json" "errors" "io" @@ -16,6 +15,7 @@ import ( "github.com/patrickmn/go-cache" "github.com/stretchr/testify/mock" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/models" "github.com/smartcontractkit/chainlink/v2/core/utils" @@ -258,7 +258,7 @@ func TestV02_SingleFeedRequest(t *testing.T) { c.httpClient = hc ch := make(chan mercury.MercuryData, 1) - c.singleFeedRequest(context.Background(), ch, tt.index, tt.lookup) + c.singleFeedRequest(testutils.Context(t), ch, tt.index, tt.lookup) m := <-ch assert.Equal(t, tt.index, m.Index) @@ -450,7 +450,7 @@ func TestV02_DoMercuryRequestV02(t *testing.T) { } c.httpClient = hc - state, reason, values, retryable, retryInterval, reqErr := c.DoRequest(context.Background(), tt.lookup, tt.pluginRetryKey) + state, reason, values, retryable, retryInterval, reqErr := c.DoRequest(testutils.Context(t), tt.lookup, tt.pluginRetryKey) assert.Equal(t, tt.expectedValues, values) assert.Equal(t, tt.expectedRetryable, retryable) if retryable { diff --git a/core/services/ocr2/plugins/ocr2keeper/evm21/mercury/v03/v03_request_test.go b/core/services/ocr2/plugins/ocr2keeper/evm21/mercury/v03/v03_request_test.go index bef2cdac58a..049448f8f76 100644 --- a/core/services/ocr2/plugins/ocr2keeper/evm21/mercury/v03/v03_request_test.go +++ b/core/services/ocr2/plugins/ocr2keeper/evm21/mercury/v03/v03_request_test.go @@ -2,7 +2,6 @@ package v03 import ( "bytes" - "context" "encoding/json" "io" "math/big" @@ -14,6 +13,7 @@ import ( "github.com/patrickmn/go-cache" "github.com/stretchr/testify/mock" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/models" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evm21/mocks" @@ -162,7 +162,7 @@ func TestV03_DoMercuryRequestV03(t *testing.T) { } c.httpClient = hc - state, reason, values, retryable, retryInterval, reqErr := c.DoRequest(context.Background(), tt.lookup, tt.pluginRetryKey) + state, reason, values, retryable, retryInterval, reqErr := c.DoRequest(testutils.Context(t), tt.lookup, tt.pluginRetryKey) assert.Equal(t, tt.expectedValues, values) assert.Equal(t, tt.expectedRetryable, retryable) @@ -514,7 +514,7 @@ func TestV03_MultiFeedRequest(t *testing.T) { c.httpClient = hc ch := make(chan mercury.MercuryData, 1) - c.multiFeedsRequest(context.Background(), ch, tt.lookup) + c.multiFeedsRequest(testutils.Context(t), ch, tt.lookup) m := <-ch assert.Equal(t, 0, m.Index) diff --git a/core/services/ocr2/plugins/ocr2keeper/evm21/payload_builder_test.go b/core/services/ocr2/plugins/ocr2keeper/evm21/payload_builder_test.go index e75084ff968..e68e316ae30 100644 --- a/core/services/ocr2/plugins/ocr2keeper/evm21/payload_builder_test.go +++ b/core/services/ocr2/plugins/ocr2keeper/evm21/payload_builder_test.go @@ -6,9 +6,11 @@ import ( "testing" "github.com/pkg/errors" - "github.com/smartcontractkit/ocr2keepers/pkg/v3/types" "github.com/stretchr/testify/assert" + "github.com/smartcontractkit/ocr2keepers/pkg/v3/types" + + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evm21/core" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evm21/logprovider" @@ -191,7 +193,7 @@ func TestNewPayloadBuilder(t *testing.T) { t.Run(tc.name, func(t *testing.T) { lggr, _ := logger.NewLogger() builder := NewPayloadBuilder(tc.activeList, tc.recoverer, lggr) - payloads, err := builder.BuildPayloads(context.Background(), tc.proposals...) + payloads, err := builder.BuildPayloads(testutils.Context(t), tc.proposals...) assert.NoError(t, err) assert.Equal(t, tc.wantPayloads, payloads) }) diff --git a/core/services/ocr2/plugins/ocr2keeper/evm21/registry_check_pipeline_test.go b/core/services/ocr2/plugins/ocr2keeper/evm21/registry_check_pipeline_test.go index 2e39892e478..d4e38637d8c 100644 --- a/core/services/ocr2/plugins/ocr2keeper/evm21/registry_check_pipeline_test.go +++ b/core/services/ocr2/plugins/ocr2keeper/evm21/registry_check_pipeline_test.go @@ -18,13 +18,15 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_keeper_registry_master_wrapper_2_1" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/streams_lookup_compatible_interface" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/models" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evm21/mocks" - ocr2keepers "github.com/smartcontractkit/ocr2keepers/pkg/v3/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" + ocr2keepers "github.com/smartcontractkit/ocr2keepers/pkg/v3/types" + evmClientMocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" @@ -205,7 +207,7 @@ func TestRegistry_VerifyCheckBlock(t *testing.T) { e.client = client } - state, retryable := e.verifyCheckBlock(context.Background(), tc.checkBlock, tc.upkeepId, tc.checkHash) + state, retryable := e.verifyCheckBlock(testutils.Context(t), tc.checkBlock, tc.upkeepId, tc.checkHash) assert.Equal(t, tc.state, state) assert.Equal(t, tc.retryable, retryable) }) @@ -350,7 +352,7 @@ func TestRegistry_VerifyLogExists(t *testing.T) { e := &EvmRegistry{ lggr: lggr, bs: bs, - ctx: context.Background(), + ctx: testutils.Context(t), } if tc.makeEthCall { @@ -530,7 +532,7 @@ func TestRegistry_CheckUpkeeps(t *testing.T) { } e.client = client - results, err := e.checkUpkeeps(context.Background(), tc.inputs) + results, err := e.checkUpkeeps(testutils.Context(t), tc.inputs) assert.Equal(t, tc.results, results) assert.Equal(t, tc.err, err) }) @@ -651,7 +653,7 @@ func TestRegistry_SimulatePerformUpkeeps(t *testing.T) { }).Once() e.client = client - results, err := e.simulatePerformUpkeeps(context.Background(), tc.inputs) + results, err := e.simulatePerformUpkeeps(testutils.Context(t), tc.inputs) assert.Equal(t, tc.results, results) assert.Equal(t, tc.err, err) }) diff --git a/core/services/ocr2/plugins/ocr2keeper/evm21/transmit/event_provider_test.go b/core/services/ocr2/plugins/ocr2keeper/evm21/transmit/event_provider_test.go index 58e95bc423e..a33056977ac 100644 --- a/core/services/ocr2/plugins/ocr2keeper/evm21/transmit/event_provider_test.go +++ b/core/services/ocr2/plugins/ocr2keeper/evm21/transmit/event_provider_test.go @@ -1,29 +1,29 @@ package transmit import ( - "context" "math/big" "runtime" "testing" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" - ocr2keepers "github.com/smartcontractkit/ocr2keepers/pkg/v3/types" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + ocr2keepers "github.com/smartcontractkit/ocr2keepers/pkg/v3/types" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" evmClientMocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller/mocks" iregistry21 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_keeper_registry_master_wrapper_2_1" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evm21/core" ) func TestTransmitEventProvider_Sanity(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() + ctx := testutils.Context(t) lp := new(mocks.LogPoller) diff --git a/core/services/ocr2/plugins/ocr2keeper/evm21/upkeepstate/store_test.go b/core/services/ocr2/plugins/ocr2keeper/evm21/upkeepstate/store_test.go index 8e2e77f7fb4..579d8757921 100644 --- a/core/services/ocr2/plugins/ocr2keeper/evm21/upkeepstate/store_test.go +++ b/core/services/ocr2/plugins/ocr2keeper/evm21/upkeepstate/store_test.go @@ -357,7 +357,7 @@ func TestUpkeepStateStore_SetSelectIntegration(t *testing.T) { }) for _, insert := range test.storedValues { - require.NoError(t, store.SetUpkeepState(context.Background(), insert.result, insert.state), "storing states should not produce an error") + require.NoError(t, store.SetUpkeepState(ctx, insert.result, insert.state), "storing states should not produce an error") } tickerCh <- time.Now() @@ -408,7 +408,7 @@ func TestUpkeepStateStore_emptyDB(t *testing.T) { scanner := &mockScanner{} store := NewUpkeepStateStore(orm, lggr, scanner) - states, err := store.SelectByWorkIDs(context.Background(), []string{"0x1", "0x2", "0x3", "0x4"}...) + states, err := store.SelectByWorkIDs(testutils.Context(t), []string{"0x1", "0x2", "0x3", "0x4"}...) assert.NoError(t, err) assert.Equal(t, []ocr2keepers.UpkeepState{ ocr2keepers.UnknownState, @@ -454,6 +454,7 @@ func TestUpkeepStateStore_Upsert(t *testing.T) { } func TestUpkeepStateStore_Service(t *testing.T) { + ctx := testutils.Context(t) orm := &mockORM{ onDelete: func(tm time.Time) { @@ -466,10 +467,10 @@ func TestUpkeepStateStore_Service(t *testing.T) { store.retention = 500 * time.Millisecond store.cleanCadence = 100 * time.Millisecond - assert.NoError(t, store.Start(context.Background()), "no error from starting service") + assert.NoError(t, store.Start(ctx), "no error from starting service") // add a value to set up the test - require.NoError(t, store.SetUpkeepState(context.Background(), ocr2keepers.CheckResult{ + require.NoError(t, store.SetUpkeepState(ctx, ocr2keepers.CheckResult{ Eligible: false, WorkID: "0x2", Trigger: ocr2keepers.Trigger{ @@ -481,7 +482,7 @@ func TestUpkeepStateStore_Service(t *testing.T) { time.Sleep(110 * time.Millisecond) // select from store to ensure values still exist - values, err := store.SelectByWorkIDs(context.Background(), "0x2") + values, err := store.SelectByWorkIDs(ctx, "0x2") require.NoError(t, err, "no error from selecting states") require.Equal(t, []ocr2keepers.UpkeepState{ocr2keepers.Ineligible}, values, "selected values should match expected") @@ -489,7 +490,7 @@ func TestUpkeepStateStore_Service(t *testing.T) { time.Sleep(700 * time.Millisecond) // select from store to ensure cached values were removed - values, err = store.SelectByWorkIDs(context.Background(), "0x2") + values, err = store.SelectByWorkIDs(ctx, "0x2") require.NoError(t, err, "no error from selecting states") require.Equal(t, []ocr2keepers.UpkeepState{ocr2keepers.UnknownState}, values, "selected values should match expected") diff --git a/core/services/ocr2/plugins/ocr2keeper/integration_21_test.go b/core/services/ocr2/plugins/ocr2keeper/integration_21_test.go index 109a644ca09..d2f35a3e37a 100644 --- a/core/services/ocr2/plugins/ocr2keeper/integration_21_test.go +++ b/core/services/ocr2/plugins/ocr2keeper/integration_21_test.go @@ -890,6 +890,7 @@ func (c *feedLookupUpkeepController) EnableMercury( MercuryEnabled: true, }) + ctx := testutils.Context(t) for _, id := range c.upkeepIds { if _, err := registry.SetUpkeepPrivilegeConfig(registryOwner, id, adminBytes); err != nil { require.NoError(t, err) @@ -900,7 +901,7 @@ func (c *feedLookupUpkeepController) EnableMercury( callOpts := &bind.CallOpts{ Pending: true, From: registryOwner.From, - Context: context.Background(), + Context: ctx, } bts, err := registry.GetUpkeepPrivilegeConfig(callOpts, id) @@ -989,7 +990,7 @@ func (c *feedLookupUpkeepController) EmitEvents( backend.Commit() // verify event was emitted - block, _ := backend.BlockByHash(context.Background(), backend.Commit()) + block, _ := backend.BlockByHash(ctx, backend.Commit()) t.Logf("block number after emit event: %d", block.NumberU64()) iter, _ := c.protocol.FilterLimitOrderExecuted( diff --git a/core/services/ocr2/plugins/ocr2keeper/integration_test.go b/core/services/ocr2/plugins/ocr2keeper/integration_test.go index a2184d92aec..3eda8867968 100644 --- a/core/services/ocr2/plugins/ocr2keeper/integration_test.go +++ b/core/services/ocr2/plugins/ocr2keeper/integration_test.go @@ -1,7 +1,6 @@ package ocr2keeper_test import ( - "context" "crypto/rand" "encoding/hex" "encoding/json" @@ -171,14 +170,14 @@ func (node *Node) AddJob(t *testing.T, spec string) { c := node.App.GetConfig() jb, err := validate.ValidatedOracleSpecToml(c.OCR2(), c.Insecure(), spec) require.NoError(t, err) - err = node.App.AddJobV2(context.Background(), &jb) + err = node.App.AddJobV2(testutils.Context(t), &jb) require.NoError(t, err) } func (node *Node) AddBootstrapJob(t *testing.T, spec string) { jb, err := ocrbootstrap.ValidatedBootstrapSpecToml(spec) require.NoError(t, err) - err = node.App.AddJobV2(context.Background(), &jb) + err = node.App.AddJobV2(testutils.Context(t), &jb) require.NoError(t, err) } diff --git a/core/services/ocr2/plugins/ocr2vrf/internal/ocr2vrf_integration_test.go b/core/services/ocr2/plugins/ocr2vrf/internal/ocr2vrf_integration_test.go index 57d13a69ec5..38d7acf7e9b 100644 --- a/core/services/ocr2/plugins/ocr2vrf/internal/ocr2vrf_integration_test.go +++ b/core/services/ocr2/plugins/ocr2vrf/internal/ocr2vrf_integration_test.go @@ -1,7 +1,6 @@ package internal_test import ( - "context" "crypto/rand" "encoding/hex" "errors" @@ -336,6 +335,7 @@ func TestIntegration_OCR2VRF(t *testing.T) { } func runOCR2VRFTest(t *testing.T, useForwarders bool) { + ctx := testutils.Context(t) keyID := randomKeyID(t) uni := setupOCR2VRFContracts(t, 5, keyID, false) @@ -409,7 +409,7 @@ func runOCR2VRFTest(t *testing.T, useForwarders bool) { } }() - blockBeforeConfig, err := uni.backend.BlockByNumber(context.Background(), nil) + blockBeforeConfig, err := uni.backend.BlockByNumber(ctx, nil) require.NoError(t, err) t.Log("Setting DKG config before block:", blockBeforeConfig.Number().String()) @@ -447,7 +447,7 @@ fromBlock = %d t.Log("Creating bootstrap job:", bootstrapJobSpec) ocrJob, err := ocrbootstrap.ValidatedBootstrapSpecToml(bootstrapJobSpec) require.NoError(t, err) - err = bootstrapNode.app.AddJobV2(context.Background(), &ocrJob) + err = bootstrapNode.app.AddJobV2(ctx, &ocrJob) require.NoError(t, err) t.Log("Creating OCR2VRF jobs") @@ -499,7 +499,7 @@ linkEthFeedAddress = "%s" t.Log("Creating OCR2VRF job with spec:", jobSpec) ocrJob2, err2 := validate.ValidatedOracleSpecToml(apps[i].Config.OCR2(), apps[i].Config.Insecure(), jobSpec) require.NoError(t, err2) - err2 = apps[i].AddJobV2(context.Background(), &ocrJob2) + err2 = apps[i].AddJobV2(ctx, &ocrJob2) require.NoError(t, err2) } diff --git a/core/services/ocr2/plugins/promwrapper/plugin_test.go b/core/services/ocr2/plugins/promwrapper/plugin_test.go index 5c12c18f852..b4de7f027f3 100644 --- a/core/services/ocr2/plugins/promwrapper/plugin_test.go +++ b/core/services/ocr2/plugins/promwrapper/plugin_test.go @@ -8,10 +8,12 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" - "github.com/smartcontractkit/libocr/offchainreporting2plus/types" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + "github.com/smartcontractkit/libocr/offchainreporting2plus/types" + + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/promwrapper/mocks" ) @@ -194,14 +196,16 @@ func TestPlugin_GetLatencies(t *testing.T) { ).(*promPlugin) require.NotEqual(t, nil, promPlugin) + ctx := testutils.Context(t) + // Run OCR methods. - _, err := promPlugin.Query(context.Background(), reportTimestamp) + _, err := promPlugin.Query(ctx, reportTimestamp) require.NoError(t, err) _, ok := promPlugin.queryEndTimes.Load(reportTimestamp) require.Equal(t, true, ok) time.Sleep(qToOLatency) - _, err = promPlugin.Observation(context.Background(), reportTimestamp, nil) + _, err = promPlugin.Observation(ctx, reportTimestamp, nil) require.NoError(t, err) _, ok = promPlugin.queryEndTimes.Load(reportTimestamp) require.Equal(t, false, ok) @@ -209,7 +213,7 @@ func TestPlugin_GetLatencies(t *testing.T) { require.Equal(t, true, ok) time.Sleep(oToRLatency) - _, _, err = promPlugin.Report(context.Background(), reportTimestamp, nil, nil) + _, _, err = promPlugin.Report(ctx, reportTimestamp, nil, nil) require.NoError(t, err) _, ok = promPlugin.observationEndTimes.Load(reportTimestamp) require.Equal(t, false, ok) @@ -217,7 +221,7 @@ func TestPlugin_GetLatencies(t *testing.T) { require.Equal(t, true, ok) time.Sleep(rToALatency) - _, err = promPlugin.ShouldAcceptFinalizedReport(context.Background(), reportTimestamp, nil) + _, err = promPlugin.ShouldAcceptFinalizedReport(ctx, reportTimestamp, nil) require.NoError(t, err) _, ok = promPlugin.reportEndTimes.Load(reportTimestamp) require.Equal(t, false, ok) @@ -225,7 +229,7 @@ func TestPlugin_GetLatencies(t *testing.T) { require.Equal(t, true, ok) time.Sleep(aToTLatency) - _, err = promPlugin.ShouldTransmitAcceptedReport(context.Background(), reportTimestamp, nil) + _, err = promPlugin.ShouldTransmitAcceptedReport(ctx, reportTimestamp, nil) require.NoError(t, err) _, ok = promPlugin.acceptFinalizedReportEndTimes.Load(reportTimestamp) require.Equal(t, false, ok) diff --git a/core/services/relay/evm/mercury/persistence_manager_test.go b/core/services/relay/evm/mercury/persistence_manager_test.go index dbdb9777252..755d64a5a23 100644 --- a/core/services/relay/evm/mercury/persistence_manager_test.go +++ b/core/services/relay/evm/mercury/persistence_manager_test.go @@ -1,18 +1,18 @@ package mercury import ( - "context" "testing" "time" "github.com/cometbft/cometbft/libs/rand" "github.com/jmoiron/sqlx" - ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.uber.org/zap/zapcore" "go.uber.org/zap/zaptest/observer" + ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" @@ -30,7 +30,7 @@ func TestPersistenceManager(t *testing.T) { jobID1 := rand.Int32() jobID2 := jobID1 + 1 - ctx := context.Background() + ctx := testutils.Context(t) db := pgtest.NewSqlxDB(t) pgtest.MustExec(t, db, `SET CONSTRAINTS mercury_transmit_requests_job_id_fkey DEFERRED`) pgtest.MustExec(t, db, `SET CONSTRAINTS feed_latest_reports_job_id_fkey DEFERRED`) @@ -69,7 +69,7 @@ func TestPersistenceManager(t *testing.T) { } func TestPersistenceManagerAsyncDelete(t *testing.T) { - ctx := context.Background() + ctx := testutils.Context(t) jobID := rand.Int32() db := pgtest.NewSqlxDB(t) pgtest.MustExec(t, db, `SET CONSTRAINTS mercury_transmit_requests_job_id_fkey DEFERRED`) @@ -120,7 +120,7 @@ func TestPersistenceManagerPrune(t *testing.T) { pgtest.MustExec(t, db, `SET CONSTRAINTS mercury_transmit_requests_job_id_fkey DEFERRED`) pgtest.MustExec(t, db, `SET CONSTRAINTS feed_latest_reports_job_id_fkey DEFERRED`) - ctx := context.Background() + ctx := testutils.Context(t) reports := make([][]byte, 25) for i := 0; i < 25; i++ { diff --git a/core/services/relay/evm/mercury/v1/data_source_test.go b/core/services/relay/evm/mercury/v1/data_source_test.go index 635658d7863..6eb9f430c60 100644 --- a/core/services/relay/evm/mercury/v1/data_source_test.go +++ b/core/services/relay/evm/mercury/v1/data_source_test.go @@ -432,7 +432,7 @@ func TestMercury_SetLatestBlocks(t *testing.T) { ds.chainReader = evm.NewChainReader(headTracker) obs := relaymercuryv1.Observation{} - err := ds.setLatestBlocks(context.Background(), &obs) + err := ds.setLatestBlocks(testutils.Context(t), &obs) assert.NoError(t, err) assert.Equal(t, h.Number, obs.CurrentBlockNum.Val) @@ -450,7 +450,7 @@ func TestMercury_SetLatestBlocks(t *testing.T) { ds.chainReader = evm.NewChainReader(headTracker) obs := relaymercuryv1.Observation{} - err := ds.setLatestBlocks(context.Background(), &obs) + err := ds.setLatestBlocks(testutils.Context(t), &obs) assert.NoError(t, err) assert.Zero(t, obs.CurrentBlockNum.Val) diff --git a/core/services/relay/grpc_provider_server_test.go b/core/services/relay/grpc_provider_server_test.go index fafe20ef12a..6aff32f5e32 100644 --- a/core/services/relay/grpc_provider_server_test.go +++ b/core/services/relay/grpc_provider_server_test.go @@ -1,19 +1,19 @@ package relay import ( - "context" "testing" "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink-common/pkg/types" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/logger" ) func TestProviderServer(t *testing.T) { r := &mockRelayer{} sa := NewServerAdapter(r, mockRelayerExt{}) - mp, _ := sa.NewPluginProvider(context.Background(), types.RelayArgs{ProviderType: string(types.Median)}, types.PluginArgs{}) + mp, _ := sa.NewPluginProvider(testutils.Context(t), types.RelayArgs{ProviderType: string(types.Median)}, types.PluginArgs{}) lggr := logger.TestLogger(t) _, err := NewProviderServer(mp, "unsupported-type", lggr) diff --git a/core/services/relay/relay_test.go b/core/services/relay/relay_test.go index fc9e273e302..18a7b1b44ea 100644 --- a/core/services/relay/relay_test.go +++ b/core/services/relay/relay_test.go @@ -1,7 +1,6 @@ package relay import ( - "context" "testing" "github.com/stretchr/testify/assert" @@ -11,6 +10,7 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/loop" "github.com/smartcontractkit/chainlink-common/pkg/types" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" ) func TestIdentifier_UnmarshalString(t *testing.T) { @@ -160,9 +160,10 @@ func TestRelayerServerAdapter(t *testing.T) { }, } + ctx := testutils.Context(t) for _, tc := range testCases { pp, err := sa.NewPluginProvider( - context.Background(), + ctx, types.RelayArgs{ProviderType: tc.ProviderType}, types.PluginArgs{}, ) diff --git a/core/services/telemetry/manager_test.go b/core/services/telemetry/manager_test.go index d24fb348b75..31f7ea74c19 100644 --- a/core/services/telemetry/manager_test.go +++ b/core/services/telemetry/manager_test.go @@ -1,7 +1,6 @@ package telemetry import ( - "context" "fmt" "math/big" "net/url" @@ -190,7 +189,7 @@ func TestNewManager(t *testing.T) { require.Equal(t, "TelemetryManager", m.Name()) - require.Nil(t, m.Start(context.Background())) + require.Nil(t, m.Start(testutils.Context(t))) testutils.WaitForLogMessageCount(t, logObs, "error connecting error while dialing dial tcp", 3) hr := m.HealthReport() diff --git a/core/services/transmission/integration_test.go b/core/services/transmission/integration_test.go index 58521dcdf84..c8c6137cad7 100644 --- a/core/services/transmission/integration_test.go +++ b/core/services/transmission/integration_test.go @@ -1,7 +1,6 @@ package transmission_test import ( - "context" "math/big" "testing" @@ -398,7 +397,7 @@ func Test4337WithLinkTokenVRFRequestAndPaymaster(t *testing.T) { ) require.NoError(t, err) backend.Commit() - _, err = bind.WaitMined(context.Background(), backend, tx) + _, err = bind.WaitMined(testutils.Context(t), backend, tx) require.NoError(t, err) // Generate encoded paymaster data to fund the VRF consumer. diff --git a/core/services/vrf/v2/integration_v2_test.go b/core/services/vrf/v2/integration_v2_test.go index 15121ba306c..6880fa17992 100644 --- a/core/services/vrf/v2/integration_v2_test.go +++ b/core/services/vrf/v2/integration_v2_test.go @@ -1,7 +1,6 @@ package v2_test import ( - "context" "encoding/hex" "encoding/json" "fmt" @@ -422,21 +421,22 @@ func deployOldCoordinator( common.Address, *vrf_coordinator_v2.VRFCoordinatorV2, ) { + ctx := testutils.Context(t) bytecode := hexutil.MustDecode("0x60e06040523480156200001157600080fd5b506040516200608c3803806200608c8339810160408190526200003491620001b1565b33806000816200008b5760405162461bcd60e51b815260206004820152601860248201527f43616e6e6f7420736574206f776e657220746f207a65726f000000000000000060448201526064015b60405180910390fd5b600080546001600160a01b0319166001600160a01b0384811691909117909155811615620000be57620000be81620000e8565b5050506001600160601b0319606093841b811660805290831b811660a052911b1660c052620001fb565b6001600160a01b038116331415620001435760405162461bcd60e51b815260206004820152601760248201527f43616e6e6f74207472616e7366657220746f2073656c66000000000000000000604482015260640162000082565b600180546001600160a01b0319166001600160a01b0383811691821790925560008054604051929316917fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae12789190a350565b80516001600160a01b0381168114620001ac57600080fd5b919050565b600080600060608486031215620001c757600080fd5b620001d28462000194565b9250620001e26020850162000194565b9150620001f26040850162000194565b90509250925092565b60805160601c60a05160601c60c05160601c615e2762000265600039600081816105260152613bd901526000818161061d015261402401526000818161036d01528181611599015281816125960152818161302c0152818161318201526138360152615e276000f3fe608060405234801561001057600080fd5b506004361061025b5760003560e01c80636f64f03f11610145578063ad178361116100bd578063d2f9f9a71161008c578063e72f6e3011610071578063e72f6e30146106fa578063e82ad7d41461070d578063f2fde38b1461073057600080fd5b8063d2f9f9a7146106d4578063d7ae1d30146106e757600080fd5b8063ad17836114610618578063af198b971461063f578063c3f909d41461066f578063caf70c4a146106c157600080fd5b80638da5cb5b11610114578063a21a23e4116100f9578063a21a23e4146105da578063a47c7696146105e2578063a4c0ed361461060557600080fd5b80638da5cb5b146105a95780639f87fad7146105c757600080fd5b80636f64f03f146105685780637341c10c1461057b57806379ba50971461058e578063823597401461059657600080fd5b8063356dac71116101d85780635fbbc0d2116101a757806366316d8d1161018c57806366316d8d1461050e578063689c45171461052157806369bcdb7d1461054857600080fd5b80635fbbc0d21461040057806364d51a2a1461050657600080fd5b8063356dac71146103b457806340d6bb82146103bc5780634cb48a54146103da5780635d3b1d30146103ed57600080fd5b806308821d581161022f57806315c48b841161021457806315c48b841461030e578063181f5a77146103295780631b6b6d231461036857600080fd5b806308821d58146102cf57806312b58349146102e257600080fd5b80620122911461026057806302bcc5b61461028057806304c357cb1461029557806306bfa637146102a8575b600080fd5b610268610743565b60405161027793929190615964565b60405180910390f35b61029361028e366004615792565b6107bf565b005b6102936102a33660046157ad565b61086b565b60055467ffffffffffffffff165b60405167ffffffffffffffff9091168152602001610277565b6102936102dd3660046154a3565b610a60565b6005546801000000000000000090046bffffffffffffffffffffffff165b604051908152602001610277565b61031660c881565b60405161ffff9091168152602001610277565b604080518082018252601681527f565246436f6f7264696e61746f72563220312e302e30000000000000000000006020820152905161027791906158f1565b61038f7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610277565b600a54610300565b6103c56101f481565b60405163ffffffff9091168152602001610277565b6102936103e836600461563c565b610c3f565b6103006103fb366004615516565b611036565b600c546040805163ffffffff80841682526401000000008404811660208301526801000000000000000084048116928201929092526c010000000000000000000000008304821660608201527001000000000000000000000000000000008304909116608082015262ffffff740100000000000000000000000000000000000000008304811660a0830152770100000000000000000000000000000000000000000000008304811660c08301527a0100000000000000000000000000000000000000000000000000008304811660e08301527d01000000000000000000000000000000000000000000000000000000000090920490911661010082015261012001610277565b610316606481565b61029361051c36600461545b565b611444565b61038f7f000000000000000000000000000000000000000000000000000000000000000081565b610300610556366004615779565b60009081526009602052604090205490565b6102936105763660046153a0565b6116ad565b6102936105893660046157ad565b6117f7565b610293611a85565b6102936105a4366004615792565b611b82565b60005473ffffffffffffffffffffffffffffffffffffffff1661038f565b6102936105d53660046157ad565b611d7c565b6102b66121fd565b6105f56105f0366004615792565b6123ed565b6040516102779493929190615b02565b6102936106133660046153d4565b612537565b61038f7f000000000000000000000000000000000000000000000000000000000000000081565b61065261064d366004615574565b6127a8565b6040516bffffffffffffffffffffffff9091168152602001610277565b600b546040805161ffff8316815263ffffffff6201000084048116602083015267010000000000000084048116928201929092526b010000000000000000000000909204166060820152608001610277565b6103006106cf3660046154bf565b612c6d565b6103c56106e2366004615792565b612c9d565b6102936106f53660046157ad565b612e92565b610293610708366004615385565b612ff3565b61072061071b366004615792565b613257565b6040519015158152602001610277565b61029361073e366004615385565b6134ae565b600b546007805460408051602080840282018101909252828152600094859460609461ffff8316946201000090930463ffffffff169391928391908301828280156107ad57602002820191906000526020600020905b815481526020019060010190808311610799575b50505050509050925092509250909192565b6107c76134bf565b67ffffffffffffffff811660009081526003602052604090205473ffffffffffffffffffffffffffffffffffffffff1661082d576040517f1f6a65b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b67ffffffffffffffff811660009081526003602052604090205461086890829073ffffffffffffffffffffffffffffffffffffffff16613542565b50565b67ffffffffffffffff8216600090815260036020526040902054829073ffffffffffffffffffffffffffffffffffffffff16806108d4576040517f1f6a65b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff821614610940576040517fd8a3fb5200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024015b60405180910390fd5b600b546601000000000000900460ff1615610987576040517fed3ba6a600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b67ffffffffffffffff841660009081526003602052604090206001015473ffffffffffffffffffffffffffffffffffffffff848116911614610a5a5767ffffffffffffffff841660008181526003602090815260409182902060010180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff88169081179091558251338152918201527f69436ea6df009049404f564eff6622cd00522b0bd6a89efd9e52a355c4a879be91015b60405180910390a25b50505050565b610a686134bf565b604080518082018252600091610a97919084906002908390839080828437600092019190915250612c6d915050565b60008181526006602052604090205490915073ffffffffffffffffffffffffffffffffffffffff1680610af9576040517f77f5b84c00000000000000000000000000000000000000000000000000000000815260048101839052602401610937565b600082815260066020526040812080547fffffffffffffffffffffffff00000000000000000000000000000000000000001690555b600754811015610be9578260078281548110610b4c57610b4c615dbc565b90600052602060002001541415610bd7576007805460009190610b7190600190615c76565b81548110610b8157610b81615dbc565b906000526020600020015490508060078381548110610ba257610ba2615dbc565b6000918252602090912001556007805480610bbf57610bbf615d8d565b60019003818190600052602060002001600090559055505b80610be181615cba565b915050610b2e565b508073ffffffffffffffffffffffffffffffffffffffff167f72be339577868f868798bac2c93e52d6f034fef4689a9848996c14ebb7416c0d83604051610c3291815260200190565b60405180910390a2505050565b610c476134bf565b60c861ffff87161115610c9a576040517fa738697600000000000000000000000000000000000000000000000000000000815261ffff871660048201819052602482015260c86044820152606401610937565b60008213610cd7576040517f43d4cf6600000000000000000000000000000000000000000000000000000000815260048101839052602401610937565b6040805160a0808201835261ffff891680835263ffffffff89811660208086018290526000868801528a831660608088018290528b85166080988901819052600b80547fffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000001690971762010000909502949094177fffffffffffffffffffffffffffffffffff000000000000000000ffffffffffff166701000000000000009092027fffffffffffffffffffffffffffffffffff00000000ffffffffffffffffffffff16919091176b010000000000000000000000909302929092179093558651600c80549489015189890151938a0151978a0151968a015160c08b015160e08c01516101008d01519588167fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000009099169890981764010000000093881693909302929092177fffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff1668010000000000000000958716959095027fffffffffffffffffffffffffffffffff00000000ffffffffffffffffffffffff16949094176c0100000000000000000000000098861698909802979097177fffffffffffffffffff00000000000000ffffffffffffffffffffffffffffffff1670010000000000000000000000000000000096909416959095027fffffffffffffffffff000000ffffffffffffffffffffffffffffffffffffffff16929092177401000000000000000000000000000000000000000062ffffff92831602177fffffff000000000000ffffffffffffffffffffffffffffffffffffffffffffff1677010000000000000000000000000000000000000000000000958216959095027fffffff000000ffffffffffffffffffffffffffffffffffffffffffffffffffff16949094177a01000000000000000000000000000000000000000000000000000092851692909202919091177cffffffffffffffffffffffffffffffffffffffffffffffffffffffffff167d0100000000000000000000000000000000000000000000000000000000009390911692909202919091178155600a84905590517fc21e3bd2e0b339d2848f0dd956947a88966c242c0c0c582a33137a5c1ceb5cb2916110269189918991899189918991906159c3565b60405180910390a1505050505050565b600b546000906601000000000000900460ff1615611080576040517fed3ba6a600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b67ffffffffffffffff851660009081526003602052604090205473ffffffffffffffffffffffffffffffffffffffff166110e6576040517f1f6a65b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b33600090815260026020908152604080832067ffffffffffffffff808a1685529252909120541680611156576040517ff0019fe600000000000000000000000000000000000000000000000000000000815267ffffffffffffffff87166004820152336024820152604401610937565b600b5461ffff9081169086161080611172575060c861ffff8616115b156111c257600b546040517fa738697600000000000000000000000000000000000000000000000000000000815261ffff8088166004830152909116602482015260c86044820152606401610937565b600b5463ffffffff620100009091048116908516111561122957600b546040517ff5d7e01e00000000000000000000000000000000000000000000000000000000815263ffffffff8087166004830152620100009092049091166024820152604401610937565b6101f463ffffffff8416111561127b576040517f47386bec00000000000000000000000000000000000000000000000000000000815263ffffffff841660048201526101f46024820152604401610937565b6000611288826001615bd2565b6040805160208082018c9052338284015267ffffffffffffffff808c16606084015284166080808401919091528351808403909101815260a08301845280519082012060c083018d905260e080840182905284518085039091018152610100909301909352815191012091925060009182916040805160208101849052439181019190915267ffffffffffffffff8c16606082015263ffffffff808b166080830152891660a08201523360c0820152919350915060e001604080518083037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0018152828252805160209182012060008681526009835283902055848352820183905261ffff8a169082015263ffffffff808916606083015287166080820152339067ffffffffffffffff8b16908c907f63373d1c4696214b898952999c9aaec57dac1ee2723cec59bea6888f489a97729060a00160405180910390a45033600090815260026020908152604080832067ffffffffffffffff808d16855292529091208054919093167fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000009091161790915591505095945050505050565b600b546601000000000000900460ff161561148b576040517fed3ba6a600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336000908152600860205260409020546bffffffffffffffffffffffff808316911610156114e5576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b33600090815260086020526040812080548392906115129084906bffffffffffffffffffffffff16615c8d565b92506101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff16021790555080600560088282829054906101000a90046bffffffffffffffffffffffff166115699190615c8d565b92506101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff1602179055507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb83836040518363ffffffff1660e01b815260040161162192919073ffffffffffffffffffffffffffffffffffffffff9290921682526bffffffffffffffffffffffff16602082015260400190565b602060405180830381600087803b15801561163b57600080fd5b505af115801561164f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061167391906154db565b6116a9576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050565b6116b56134bf565b6040805180820182526000916116e4919084906002908390839080828437600092019190915250612c6d915050565b60008181526006602052604090205490915073ffffffffffffffffffffffffffffffffffffffff1615611746576040517f4a0b8fa700000000000000000000000000000000000000000000000000000000815260048101829052602401610937565b600081815260066020908152604080832080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff88169081179091556007805460018101825594527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688909301849055518381527fe729ae16526293f74ade739043022254f1489f616295a25bf72dfb4511ed73b89101610c32565b67ffffffffffffffff8216600090815260036020526040902054829073ffffffffffffffffffffffffffffffffffffffff1680611860576040517f1f6a65b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff8216146118c7576040517fd8a3fb5200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82166004820152602401610937565b600b546601000000000000900460ff161561190e576040517fed3ba6a600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b67ffffffffffffffff841660009081526003602052604090206002015460641415611965576040517f05a48e0f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8316600090815260026020908152604080832067ffffffffffffffff808916855292529091205416156119ac57610a5a565b73ffffffffffffffffffffffffffffffffffffffff8316600081815260026020818152604080842067ffffffffffffffff8a1680865290835281852080547fffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000166001908117909155600384528286209094018054948501815585529382902090920180547fffffffffffffffffffffffff00000000000000000000000000000000000000001685179055905192835290917f43dc749a04ac8fb825cbd514f7c0e13f13bc6f2ee66043b76629d51776cff8e09101610a51565b60015473ffffffffffffffffffffffffffffffffffffffff163314611b06576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4d7573742062652070726f706f736564206f776e6572000000000000000000006044820152606401610937565b60008054337fffffffffffffffffffffffff00000000000000000000000000000000000000008083168217845560018054909116905560405173ffffffffffffffffffffffffffffffffffffffff90921692909183917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a350565b600b546601000000000000900460ff1615611bc9576040517fed3ba6a600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b67ffffffffffffffff811660009081526003602052604090205473ffffffffffffffffffffffffffffffffffffffff16611c2f576040517f1f6a65b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b67ffffffffffffffff811660009081526003602052604090206001015473ffffffffffffffffffffffffffffffffffffffff163314611cd15767ffffffffffffffff8116600090815260036020526040908190206001015490517fd084e97500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091166004820152602401610937565b67ffffffffffffffff81166000818152600360209081526040918290208054337fffffffffffffffffffffffff00000000000000000000000000000000000000008083168217845560019093018054909316909255835173ffffffffffffffffffffffffffffffffffffffff909116808252928101919091529092917f6f1dc65165ffffedfd8e507b4a0f1fcfdada045ed11f6c26ba27cedfe87802f0910160405180910390a25050565b67ffffffffffffffff8216600090815260036020526040902054829073ffffffffffffffffffffffffffffffffffffffff1680611de5576040517f1f6a65b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff821614611e4c576040517fd8a3fb5200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82166004820152602401610937565b600b546601000000000000900460ff1615611e93576040517fed3ba6a600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8316600090815260026020908152604080832067ffffffffffffffff808916855292529091205416611f2e576040517ff0019fe600000000000000000000000000000000000000000000000000000000815267ffffffffffffffff8516600482015273ffffffffffffffffffffffffffffffffffffffff84166024820152604401610937565b67ffffffffffffffff8416600090815260036020908152604080832060020180548251818502810185019093528083529192909190830182828015611fa957602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311611f7e575b50505050509050600060018251611fc09190615c76565b905060005b825181101561215f578573ffffffffffffffffffffffffffffffffffffffff16838281518110611ff757611ff7615dbc565b602002602001015173ffffffffffffffffffffffffffffffffffffffff16141561214d57600083838151811061202f5761202f615dbc565b6020026020010151905080600360008a67ffffffffffffffff1667ffffffffffffffff168152602001908152602001600020600201838154811061207557612075615dbc565b600091825260208083209190910180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff949094169390931790925567ffffffffffffffff8a1681526003909152604090206002018054806120ef576120ef615d8d565b60008281526020902081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90810180547fffffffffffffffffffffffff00000000000000000000000000000000000000001690550190555061215f565b8061215781615cba565b915050611fc5565b5073ffffffffffffffffffffffffffffffffffffffff8516600081815260026020908152604080832067ffffffffffffffff8b168085529083529281902080547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001690555192835290917f182bff9831466789164ca77075fffd84916d35a8180ba73c27e45634549b445b91015b60405180910390a2505050505050565b600b546000906601000000000000900460ff1615612247576040517fed3ba6a600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6005805467ffffffffffffffff1690600061226183615cf3565b82546101009290920a67ffffffffffffffff8181021990931691831602179091556005541690506000806040519080825280602002602001820160405280156122b4578160200160208202803683370190505b506040805180820182526000808252602080830182815267ffffffffffffffff888116808552600484528685209551865493516bffffffffffffffffffffffff9091167fffffffffffffffffffffffff0000000000000000000000000000000000000000948516176c010000000000000000000000009190931602919091179094558451606081018652338152808301848152818701888152958552600384529590932083518154831673ffffffffffffffffffffffffffffffffffffffff918216178255955160018201805490931696169590951790559151805194955090936123a592600285019201906150c5565b505060405133815267ffffffffffffffff841691507f464722b4166576d3dcbba877b999bc35cf911f4eaf434b7eba68fa113951d0bf9060200160405180910390a250905090565b67ffffffffffffffff81166000908152600360205260408120548190819060609073ffffffffffffffffffffffffffffffffffffffff1661245a576040517f1f6a65b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b67ffffffffffffffff80861660009081526004602090815260408083205460038352928190208054600290910180548351818602810186019094528084526bffffffffffffffffffffffff8616966c010000000000000000000000009096049095169473ffffffffffffffffffffffffffffffffffffffff90921693909291839183018282801561252157602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff1681526001909101906020018083116124f6575b5050505050905093509350935093509193509193565b600b546601000000000000900460ff161561257e576040517fed3ba6a600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016146125ed576040517f44b0e3c300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60208114612627576040517f8129bbcd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061263582840184615792565b67ffffffffffffffff811660009081526003602052604090205490915073ffffffffffffffffffffffffffffffffffffffff1661269e576040517f1f6a65b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b67ffffffffffffffff8116600090815260046020526040812080546bffffffffffffffffffffffff16918691906126d58385615bfe565b92506101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff16021790555084600560088282829054906101000a90046bffffffffffffffffffffffff1661272c9190615bfe565b92506101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff1602179055508167ffffffffffffffff167fd39ec07f4e209f627a4c427971473820dc129761ba28de8906bd56f57101d4f88287846127939190615bba565b604080519283526020830191909152016121ed565b600b546000906601000000000000900460ff16156127f2576040517fed3ba6a600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005a9050600080600061280687876139b5565b9250925092506000866060015163ffffffff1667ffffffffffffffff81111561283157612831615deb565b60405190808252806020026020018201604052801561285a578160200160208202803683370190505b50905060005b876060015163ffffffff168110156128ce5760408051602081018590529081018290526060016040516020818303038152906040528051906020012060001c8282815181106128b1576128b1615dbc565b6020908102919091010152806128c681615cba565b915050612860565b506000838152600960205260408082208290555181907f1fe543e300000000000000000000000000000000000000000000000000000000906129169087908690602401615ab4565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090941693909317909252600b80547fffffffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffff166601000000000000179055908a015160808b01519192506000916129e49163ffffffff169084613d04565b600b80547fffffffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffff1690556020808c01805167ffffffffffffffff9081166000908152600490935260408084205492518216845290922080549394506c01000000000000000000000000918290048316936001939192600c92612a68928692900416615bd2565b92506101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055506000612abf8a600b600001600b9054906101000a900463ffffffff1663ffffffff16612ab985612c9d565b3a613d52565b6020808e015167ffffffffffffffff166000908152600490915260409020549091506bffffffffffffffffffffffff80831691161015612b2b576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6020808d015167ffffffffffffffff1660009081526004909152604081208054839290612b679084906bffffffffffffffffffffffff16615c8d565b82546101009290920a6bffffffffffffffffffffffff81810219909316918316021790915560008b81526006602090815260408083205473ffffffffffffffffffffffffffffffffffffffff1683526008909152812080548594509092612bd091859116615bfe565b92506101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff160217905550877f7dffc5ae5ee4e2e4df1651cf6ad329a73cebdb728f37ea0187b9b17e036756e4888386604051612c53939291909283526bffffffffffffffffffffffff9190911660208301521515604082015260600190565b60405180910390a299505050505050505050505b92915050565b600081604051602001612c8091906158e3565b604051602081830303815290604052805190602001209050919050565b6040805161012081018252600c5463ffffffff80821683526401000000008204811660208401526801000000000000000082048116938301939093526c010000000000000000000000008104831660608301527001000000000000000000000000000000008104909216608082015262ffffff740100000000000000000000000000000000000000008304811660a08301819052770100000000000000000000000000000000000000000000008404821660c08401527a0100000000000000000000000000000000000000000000000000008404821660e08401527d0100000000000000000000000000000000000000000000000000000000009093041661010082015260009167ffffffffffffffff841611612dbb575192915050565b8267ffffffffffffffff168160a0015162ffffff16108015612df057508060c0015162ffffff168367ffffffffffffffff1611155b15612dff576020015192915050565b8267ffffffffffffffff168160c0015162ffffff16108015612e3457508060e0015162ffffff168367ffffffffffffffff1611155b15612e43576040015192915050565b8267ffffffffffffffff168160e0015162ffffff16108015612e79575080610100015162ffffff168367ffffffffffffffff1611155b15612e88576060015192915050565b6080015192915050565b67ffffffffffffffff8216600090815260036020526040902054829073ffffffffffffffffffffffffffffffffffffffff1680612efb576040517f1f6a65b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff821614612f62576040517fd8a3fb5200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82166004820152602401610937565b600b546601000000000000900460ff1615612fa9576040517fed3ba6a600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612fb284613257565b15612fe9576040517fb42f66e800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610a5a8484613542565b612ffb6134bf565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16906370a082319060240160206040518083038186803b15801561308357600080fd5b505afa158015613097573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130bb91906154fd565b6005549091506801000000000000000090046bffffffffffffffffffffffff168181111561311f576040517fa99da3020000000000000000000000000000000000000000000000000000000081526004810182905260248101839052604401610937565b818110156132525760006131338284615c76565b6040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8681166004830152602482018390529192507f00000000000000000000000000000000000000000000000000000000000000009091169063a9059cbb90604401602060405180830381600087803b1580156131c857600080fd5b505af11580156131dc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061320091906154db565b506040805173ffffffffffffffffffffffffffffffffffffffff86168152602081018390527f59bfc682b673f8cbf945f1e454df9334834abf7dfe7f92237ca29ecb9b436600910160405180910390a1505b505050565b67ffffffffffffffff811660009081526003602090815260408083208151606081018352815473ffffffffffffffffffffffffffffffffffffffff9081168252600183015416818501526002820180548451818702810187018652818152879693958601939092919083018282801561330657602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff1681526001909101906020018083116132db575b505050505081525050905060005b8160400151518110156134a45760005b60075481101561349157600061345a6007838154811061334657613346615dbc565b90600052602060002001548560400151858151811061336757613367615dbc565b602002602001015188600260008960400151898151811061338a5761338a615dbc565b60209081029190910181015173ffffffffffffffffffffffffffffffffffffffff168252818101929092526040908101600090812067ffffffffffffffff808f168352935220541660408051602080820187905273ffffffffffffffffffffffffffffffffffffffff959095168183015267ffffffffffffffff9384166060820152919092166080808301919091528251808303909101815260a08201835280519084012060c082019490945260e080820185905282518083039091018152610100909101909152805191012091565b506000818152600960205260409020549091501561347e5750600195945050505050565b508061348981615cba565b915050613324565b508061349c81615cba565b915050613314565b5060009392505050565b6134b66134bf565b61086881613e5a565b60005473ffffffffffffffffffffffffffffffffffffffff163314613540576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e6572000000000000000000006044820152606401610937565b565b600b546601000000000000900460ff1615613589576040517fed3ba6a600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b67ffffffffffffffff821660009081526003602090815260408083208151606081018352815473ffffffffffffffffffffffffffffffffffffffff90811682526001830154168185015260028201805484518187028101870186528181529295939486019383018282801561363457602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311613609575b5050509190925250505067ffffffffffffffff80851660009081526004602090815260408083208151808301909252546bffffffffffffffffffffffff81168083526c01000000000000000000000000909104909416918101919091529293505b83604001515181101561373b5760026000856040015183815181106136bc576136bc615dbc565b60209081029190910181015173ffffffffffffffffffffffffffffffffffffffff168252818101929092526040908101600090812067ffffffffffffffff8a168252909252902080547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001690558061373381615cba565b915050613695565b5067ffffffffffffffff8516600090815260036020526040812080547fffffffffffffffffffffffff00000000000000000000000000000000000000009081168255600182018054909116905590613796600283018261514f565b505067ffffffffffffffff8516600090815260046020526040902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055600580548291906008906138069084906801000000000000000090046bffffffffffffffffffffffff16615c8d565b92506101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff1602179055507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb85836bffffffffffffffffffffffff166040518363ffffffff1660e01b81526004016138be92919073ffffffffffffffffffffffffffffffffffffffff929092168252602082015260400190565b602060405180830381600087803b1580156138d857600080fd5b505af11580156138ec573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061391091906154db565b613946576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff861681526bffffffffffffffffffffffff8316602082015267ffffffffffffffff8716917fe8ed5b475a5b5987aa9165e8731bb78043f39eee32ec5a1169a89e27fcd49815910160405180910390a25050505050565b60008060006139c78560000151612c6d565b60008181526006602052604090205490935073ffffffffffffffffffffffffffffffffffffffff1680613a29576040517f77f5b84c00000000000000000000000000000000000000000000000000000000815260048101859052602401610937565b6080860151604051613a48918691602001918252602082015260400190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291815281516020928301206000818152600990935291205490935080613ac5576040517f3688124a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b85516020808801516040808a015160608b015160808c01519251613b3e968b96909594910195865267ffffffffffffffff948516602087015292909316604085015263ffffffff908116606085015291909116608083015273ffffffffffffffffffffffffffffffffffffffff1660a082015260c00190565b604051602081830303815290604052805190602001208114613b8c576040517fd529142c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b855167ffffffffffffffff164080613cb05786516040517fe9413d3800000000000000000000000000000000000000000000000000000000815267ffffffffffffffff90911660048201527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063e9413d389060240160206040518083038186803b158015613c3057600080fd5b505afa158015613c44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c6891906154fd565b905080613cb05786516040517f175dadad00000000000000000000000000000000000000000000000000000000815267ffffffffffffffff9091166004820152602401610937565b6000886080015182604051602001613cd2929190918252602082015260400190565b6040516020818303038152906040528051906020012060001c9050613cf78982613f50565b9450505050509250925092565b60005a611388811015613d1657600080fd5b611388810390508460408204820311613d2e57600080fd5b50823b613d3a57600080fd5b60008083516020850160008789f190505b9392505050565b600080613d5d613fd9565b905060008113613d9c576040517f43d4cf6600000000000000000000000000000000000000000000000000000000815260048101829052602401610937565b6000815a613daa8989615bba565b613db49190615c76565b613dc686670de0b6b3a7640000615c39565b613dd09190615c39565b613dda9190615c25565b90506000613df363ffffffff871664e8d4a51000615c39565b9050613e0b816b033b2e3c9fd0803ce8000000615c76565b821115613e44576040517fe80fa38100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b613e4e8183615bba565b98975050505050505050565b73ffffffffffffffffffffffffffffffffffffffff8116331415613eda576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f43616e6e6f74207472616e7366657220746f2073656c660000000000000000006044820152606401610937565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83811691821790925560008054604051929316917fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae12789190a350565b6000613f848360000151846020015185604001518660600151868860a001518960c001518a60e001518b61010001516140ed565b60038360200151604051602001613f9c929190615aa0565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291905280516020909101209392505050565b600b54604080517ffeaf968c0000000000000000000000000000000000000000000000000000000081529051600092670100000000000000900463ffffffff169182151591849182917f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169163feaf968c9160048083019260a0929190829003018186803b15801561407f57600080fd5b505afa158015614093573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140b791906157d7565b5094509092508491505080156140db57506140d28242615c76565b8463ffffffff16105b156140e55750600a545b949350505050565b6140f6896143c4565b61415c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f7075626c6963206b6579206973206e6f74206f6e2063757276650000000000006044820152606401610937565b614165886143c4565b6141cb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f67616d6d61206973206e6f74206f6e20637572766500000000000000000000006044820152606401610937565b6141d4836143c4565b61423a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f6347616d6d615769746e657373206973206e6f74206f6e2063757276650000006044820152606401610937565b614243826143c4565b6142a9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f73486173685769746e657373206973206e6f74206f6e206375727665000000006044820152606401610937565b6142b5878a888761451f565b61431b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f6164647228632a706b2b732a6729213d5f755769746e657373000000000000006044820152606401610937565b60006143278a876146c2565b9050600061433a898b878b868989614726565b9050600061434b838d8d8a866148ae565b9050808a146143b6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600d60248201527f696e76616c69642070726f6f66000000000000000000000000000000000000006044820152606401610937565b505050505050505050505050565b80516000907ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f11614451576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f696e76616c696420782d6f7264696e61746500000000000000000000000000006044820152606401610937565b60208201517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f116144de576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f696e76616c696420792d6f7264696e61746500000000000000000000000000006044820152606401610937565b60208201517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f9080096145188360005b602002015161490c565b1492915050565b600073ffffffffffffffffffffffffffffffffffffffff821661459e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600b60248201527f626164207769746e6573730000000000000000000000000000000000000000006044820152606401610937565b6020840151600090600116156145b557601c6145b8565b601b5b905060007ffffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd03641418587600060200201510986517ffffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141918203925060009190890987516040805160008082526020820180845287905260ff88169282019290925260608101929092526080820183905291925060019060a0016020604051602081039080840390855afa15801561466f573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015173ffffffffffffffffffffffffffffffffffffffff9081169088161495505050505050949350505050565b6146ca61516d565b6146f7600184846040516020016146e3939291906158c2565b604051602081830303815290604052614964565b90505b614703816143c4565b612c6757805160408051602081019290925261471f91016146e3565b90506146fa565b61472e61516d565b825186517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f90819006910614156147c1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f706f696e747320696e2073756d206d7573742062652064697374696e637400006044820152606401610937565b6147cc8789886149cd565b614832576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4669727374206d756c20636865636b206661696c6564000000000000000000006044820152606401610937565b61483d8486856149cd565b6148a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f5365636f6e64206d756c20636865636b206661696c65640000000000000000006044820152606401610937565b613e4e868484614b5a565b6000600286868685876040516020016148cc96959493929190615850565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291905280516020909101209695505050505050565b6000807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f80848509840990507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f600782089392505050565b61496c61516d565b61497582614c89565b815261498a61498582600061450e565b614cde565b6020820181905260029006600114156149c8576020810180517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f0390525b919050565b600082614a36576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600b60248201527f7a65726f207363616c61720000000000000000000000000000000000000000006044820152606401610937565b83516020850151600090614a4c90600290615d1b565b15614a5857601c614a5b565b601b5b905060007ffffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd03641418387096040805160008082526020820180845281905260ff86169282019290925260608101869052608081018390529192509060019060a0016020604051602081039080840390855afa158015614adb573d6000803e3d6000fd5b505050602060405103519050600086604051602001614afa919061583e565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152919052805160209091012073ffffffffffffffffffffffffffffffffffffffff92831692169190911498975050505050505050565b614b6261516d565b835160208086015185519186015160009384938493614b8393909190614d18565b919450925090507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f858209600114614c17576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f696e765a206d75737420626520696e7665727365206f66207a000000000000006044820152606401610937565b60405180604001604052807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f80614c5057614c50615d5e565b87860981526020017ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f8785099052979650505050505050565b805160208201205b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f81106149c857604080516020808201939093528151808203840181529082019091528051910120614c91565b6000612c67826002614d117ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f6001615bba565b901c614eae565b60008080600180827ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f897ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f038808905060007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f8b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f038a0890506000614dc083838585614fa2565b9098509050614dd188828e88614ffa565b9098509050614de288828c87614ffa565b90985090506000614df58d878b85614ffa565b9098509050614e0688828686614fa2565b9098509050614e1788828e89614ffa565b9098509050818114614e9a577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f818a0998507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f82890997507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f8183099650614e9e565b8196505b5050505050509450945094915050565b600080614eb961518b565b6020808252818101819052604082015260608101859052608081018490527ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f60a0820152614f056151a9565b60208160c08460057ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa925082614f98576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f6269674d6f64457870206661696c7572652100000000000000000000000000006044820152606401610937565b5195945050505050565b6000807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f8487097ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f8487099097909650945050505050565b600080807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f878509905060007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f87877ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f030990507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f8183087ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f86890990999098509650505050505050565b82805482825590600052602060002090810192821561513f579160200282015b8281111561513f57825182547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9091161782556020909201916001909101906150e5565b5061514b9291506151c7565b5090565b508054600082559060005260206000209081019061086891906151c7565b60405180604001604052806002906020820280368337509192915050565b6040518060c001604052806006906020820280368337509192915050565b60405180602001604052806001906020820280368337509192915050565b5b8082111561514b57600081556001016151c8565b803573ffffffffffffffffffffffffffffffffffffffff811681146149c857600080fd5b8060408101831015612c6757600080fd5b600082601f83011261522257600080fd5b6040516040810181811067ffffffffffffffff8211171561524557615245615deb565b806040525080838560408601111561525c57600080fd5b60005b600281101561527e57813583526020928301929091019060010161525f565b509195945050505050565b600060a0828403121561529b57600080fd5b60405160a0810181811067ffffffffffffffff821117156152be576152be615deb565b6040529050806152cd83615353565b81526152db60208401615353565b60208201526152ec6040840161533f565b60408201526152fd6060840161533f565b606082015261530e608084016151dc565b60808201525092915050565b803561ffff811681146149c857600080fd5b803562ffffff811681146149c857600080fd5b803563ffffffff811681146149c857600080fd5b803567ffffffffffffffff811681146149c857600080fd5b805169ffffffffffffffffffff811681146149c857600080fd5b60006020828403121561539757600080fd5b613d4b826151dc565b600080606083850312156153b357600080fd5b6153bc836151dc565b91506153cb8460208501615200565b90509250929050565b600080600080606085870312156153ea57600080fd5b6153f3856151dc565b935060208501359250604085013567ffffffffffffffff8082111561541757600080fd5b818701915087601f83011261542b57600080fd5b81358181111561543a57600080fd5b88602082850101111561544c57600080fd5b95989497505060200194505050565b6000806040838503121561546e57600080fd5b615477836151dc565b915060208301356bffffffffffffffffffffffff8116811461549857600080fd5b809150509250929050565b6000604082840312156154b557600080fd5b613d4b8383615200565b6000604082840312156154d157600080fd5b613d4b8383615211565b6000602082840312156154ed57600080fd5b81518015158114613d4b57600080fd5b60006020828403121561550f57600080fd5b5051919050565b600080600080600060a0868803121561552e57600080fd5b8535945061553e60208701615353565b935061554c6040870161531a565b925061555a6060870161533f565b91506155686080870161533f565b90509295509295909350565b60008082840361024081121561558957600080fd5b6101a08082121561559957600080fd5b6155a1615b90565b91506155ad8686615211565b82526155bc8660408701615211565b60208301526080850135604083015260a0850135606083015260c085013560808301526155eb60e086016151dc565b60a08301526101006155ff87828801615211565b60c0840152615612876101408801615211565b60e0840152610180860135818401525081935061563186828701615289565b925050509250929050565b6000806000806000808688036101c081121561565757600080fd5b6156608861531a565b965061566e6020890161533f565b955061567c6040890161533f565b945061568a6060890161533f565b935060808801359250610120807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60830112156156c557600080fd5b6156cd615b90565b91506156db60a08a0161533f565b82526156e960c08a0161533f565b60208301526156fa60e08a0161533f565b604083015261010061570d818b0161533f565b606084015261571d828b0161533f565b608084015261572f6101408b0161532c565b60a08401526157416101608b0161532c565b60c08401526157536101808b0161532c565b60e08401526157656101a08b0161532c565b818401525050809150509295509295509295565b60006020828403121561578b57600080fd5b5035919050565b6000602082840312156157a457600080fd5b613d4b82615353565b600080604083850312156157c057600080fd5b6157c983615353565b91506153cb602084016151dc565b600080600080600060a086880312156157ef57600080fd5b6157f88661536b565b94506020860151935060408601519250606086015191506155686080870161536b565b8060005b6002811015610a5a57815184526020938401939091019060010161581f565b615848818361581b565b604001919050565b868152615860602082018761581b565b61586d606082018661581b565b61587a60a082018561581b565b61588760e082018461581b565b60609190911b7fffffffffffffffffffffffffffffffffffffffff000000000000000000000000166101208201526101340195945050505050565b8381526158d2602082018461581b565b606081019190915260800192915050565b60408101612c67828461581b565b600060208083528351808285015260005b8181101561591e57858101830151858201604001528201615902565b81811115615930576000604083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016929092016040019392505050565b60006060820161ffff86168352602063ffffffff86168185015260606040850152818551808452608086019150828701935060005b818110156159b557845183529383019391830191600101615999565b509098975050505050505050565b60006101c08201905061ffff8816825263ffffffff808816602084015280871660408401528086166060840152846080840152835481811660a0850152615a1760c08501838360201c1663ffffffff169052565b615a2e60e08501838360401c1663ffffffff169052565b615a466101008501838360601c1663ffffffff169052565b615a5e6101208501838360801c1663ffffffff169052565b62ffffff60a082901c811661014086015260b882901c811661016086015260d082901c1661018085015260e81c6101a090930192909252979650505050505050565b82815260608101613d4b602083018461581b565b6000604082018483526020604081850152818551808452606086019150828701935060005b81811015615af557845183529383019391830191600101615ad9565b5090979650505050505050565b6000608082016bffffffffffffffffffffffff87168352602067ffffffffffffffff87168185015273ffffffffffffffffffffffffffffffffffffffff80871660408601526080606086015282865180855260a087019150838801945060005b81811015615b80578551841683529484019491840191600101615b62565b50909a9950505050505050505050565b604051610120810167ffffffffffffffff81118282101715615bb457615bb4615deb565b60405290565b60008219821115615bcd57615bcd615d2f565b500190565b600067ffffffffffffffff808316818516808303821115615bf557615bf5615d2f565b01949350505050565b60006bffffffffffffffffffffffff808316818516808303821115615bf557615bf5615d2f565b600082615c3457615c34615d5e565b500490565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615615c7157615c71615d2f565b500290565b600082821015615c8857615c88615d2f565b500390565b60006bffffffffffffffffffffffff83811690831681811015615cb257615cb2615d2f565b039392505050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415615cec57615cec615d2f565b5060010190565b600067ffffffffffffffff80831681811415615d1157615d11615d2f565b6001019392505050565b600082615d2a57615d2a615d5e565b500690565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fdfea164736f6c6343000806000a") ctorArgs, err := utils.ABIEncode(`[{"type":"address"}, {"type":"address"}, {"type":"address"}]`, linkAddress, bhsAddress, linkEthFeed) require.NoError(t, err) bytecode = append(bytecode, ctorArgs...) - nonce, err := backend.PendingNonceAt(context.Background(), neil.From) + nonce, err := backend.PendingNonceAt(ctx, neil.From) require.NoError(t, err) - gasPrice, err := backend.SuggestGasPrice(context.Background()) + gasPrice, err := backend.SuggestGasPrice(ctx) require.NoError(t, err) unsignedTx := gethtypes.NewContractCreation(nonce, big.NewInt(0), 15e6, gasPrice, bytecode) signedTx, err := neil.Signer(neil.From, unsignedTx) require.NoError(t, err) - err = backend.SendTransaction(context.Background(), signedTx) + err = backend.SendTransaction(ctx, signedTx) require.NoError(t, err, "could not deploy old vrf coordinator to simulated blockchain") backend.Commit() - receipt, err := backend.TransactionReceipt(context.Background(), signedTx.Hash()) + receipt, err := backend.TransactionReceipt(ctx, signedTx.Hash()) require.NoError(t, err) oldRootContractAddress := receipt.ContractAddress require.NotEqual(t, common.HexToAddress("0x0"), oldRootContractAddress, "old vrf coordinator address equal to zero address, deployment failed") diff --git a/core/web/jobs_controller.go b/core/web/jobs_controller.go index 4c8a77d370e..0f97e0b53d3 100644 --- a/core/web/jobs_controller.go +++ b/core/web/jobs_controller.go @@ -71,7 +71,7 @@ func (jc *JobsController) Show(c *gin.Context) { jobSpec, err = jc.App.JobORM().FindJobByExternalJobID(externalJobID, pg.WithParentCtx(c.Request.Context())) } else if pErr = jobSpec.SetID(c.Param("ID")); pErr == nil { // Find a job by job ID - jobSpec, err = jc.App.JobORM().FindJobTx(jobSpec.ID) + jobSpec, err = jc.App.JobORM().FindJobTx(c, jobSpec.ID) } else { jsonAPIError(c, http.StatusUnprocessableEntity, pErr) return diff --git a/integration-tests/load/automationv2_1/automationv2_1_test.go b/integration-tests/load/automationv2_1/automationv2_1_test.go index dfef099c175..06c2624d0f0 100644 --- a/integration-tests/load/automationv2_1/automationv2_1_test.go +++ b/integration-tests/load/automationv2_1/automationv2_1_test.go @@ -15,11 +15,13 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/slack-go/slack" + "github.com/stretchr/testify/require" + ocr3 "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3confighelper" ocr2keepers30config "github.com/smartcontractkit/ocr2keepers/pkg/v3/config" "github.com/smartcontractkit/wasp" - "github.com/stretchr/testify/require" + "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/chainlink-testing-framework/k8s/config" "github.com/smartcontractkit/chainlink-testing-framework/k8s/environment" @@ -125,6 +127,7 @@ var ( ) func TestLogTrigger(t *testing.T) { + ctx := tests.Context(t) l := logging.GetTestLogger(t) l.Info().Msg("Starting automation v2.1 log trigger load test") @@ -467,7 +470,7 @@ func TestLogTrigger(t *testing.T) { l.Info().Str("STARTUP_WAIT_TIME", StartupWaitTime.String()).Msg("Waiting for plugin to start") time.Sleep(StartupWaitTime) - startBlock, err := chainClient.LatestBlockNumber(context.Background()) + startBlock, err := chainClient.LatestBlockNumber(ctx) require.NoError(t, err, "Error getting latest block number") p := wasp.NewProfile() @@ -511,7 +514,7 @@ func TestLogTrigger(t *testing.T) { endTime := time.Now() testDuration := endTime.Sub(startTime) l.Info().Str("Duration", testDuration.String()).Msg("Test Duration") - endBlock, err := chainClient.LatestBlockNumber(context.Background()) + endBlock, err := chainClient.LatestBlockNumber(ctx) require.NoError(t, err, "Error getting latest block number") l.Info().Uint64("Starting Block", startBlock).Uint64("Ending Block", endBlock).Msg("Test Block Range") @@ -544,7 +547,8 @@ func TestLogTrigger(t *testing.T) { Topics: [][]common.Hash{{consumerABI.Events["PerformingUpkeep"].ID}}, } ) - ctx, cancel := context.WithTimeout(context.Background(), timeout) + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, timeout) logsInBatch, err := chainClient.FilterLogs(ctx, filterQuery) cancel() if err != nil { diff --git a/plugins/medianpoc/data_source_test.go b/plugins/medianpoc/data_source_test.go index 5848705b7b9..9977daef3d0 100644 --- a/plugins/medianpoc/data_source_test.go +++ b/plugins/medianpoc/data_source_test.go @@ -11,6 +11,7 @@ import ( ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types" + "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink-common/pkg/types" @@ -60,7 +61,7 @@ func TestDataSource(t *testing.T) { spec: spec, lggr: lggr, } - res, err := ds.Observe(context.Background(), ocrtypes.ReportTimestamp{}) + res, err := ds.Observe(tests.Context(t), ocrtypes.ReportTimestamp{}) require.NoError(t, err) assert.Equal(t, big.NewInt(expect), res) assert.Equal(t, spec, pr.spec) @@ -86,7 +87,7 @@ func TestDataSource_ResultErrors(t *testing.T) { spec: spec, lggr: lggr, } - _, err := ds.Observe(context.Background(), ocrtypes.ReportTimestamp{}) + _, err := ds.Observe(tests.Context(t), ocrtypes.ReportTimestamp{}) assert.ErrorContains(t, err, "something went wrong") } @@ -111,6 +112,6 @@ func TestDataSource_ResultNotAnInt(t *testing.T) { spec: spec, lggr: lggr, } - _, err := ds.Observe(context.Background(), ocrtypes.ReportTimestamp{}) + _, err := ds.Observe(tests.Context(t), ocrtypes.ReportTimestamp{}) assert.ErrorContains(t, err, "cannot convert observation to decimal") } diff --git a/plugins/medianpoc/plugin_test.go b/plugins/medianpoc/plugin_test.go index 569fcb464bc..bc6af7ae5d3 100644 --- a/plugins/medianpoc/plugin_test.go +++ b/plugins/medianpoc/plugin_test.go @@ -1,7 +1,6 @@ package medianpoc import ( - "context" "fmt" "testing" @@ -13,6 +12,7 @@ import ( "github.com/smartcontractkit/libocr/offchainreporting2/reportingplugin/median" "github.com/smartcontractkit/chainlink-common/pkg/types" + "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" "github.com/smartcontractkit/chainlink/v2/core/logger" ) @@ -89,7 +89,7 @@ func TestNewPlugin(t *testing.T) { prov := provider{} f, err := p.newFactory( - context.Background(), + tests.Context(t), config, prov, pr,