Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Decouple utils tests from core #12993

Merged
merged 9 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tender-pianos-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

Decouple utils tests from core #internal
17 changes: 9 additions & 8 deletions core/chains/evm/types/models_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ import (
"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink-common/pkg/utils/hex"
"github.com/smartcontractkit/chainlink-common/pkg/utils/tests"

"github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/testutils"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr"
evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils"
"github.com/smartcontractkit/chainlink/v2/core/internal/cltest"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest"
)

Expand Down Expand Up @@ -55,11 +56,11 @@ func TestHead_GreaterThan(t *testing.T) {
greater bool
}{
{"nil nil", nil, nil, false},
{"present nil", cltest.Head(1), nil, true},
{"nil present", nil, cltest.Head(1), false},
{"less", cltest.Head(1), cltest.Head(2), false},
{"equal", cltest.Head(2), cltest.Head(2), false},
{"greater", cltest.Head(2), cltest.Head(1), true},
{"present nil", testutils.Head(1), nil, true},
{"nil present", nil, testutils.Head(1), false},
{"less", testutils.Head(1), testutils.Head(2), false},
{"equal", testutils.Head(2), testutils.Head(2), false},
{"greater", testutils.Head(2), testutils.Head(1), true},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
Expand All @@ -76,7 +77,7 @@ func TestHead_NextInt(t *testing.T) {
want *big.Int
}{
{"nil", nil, nil},
{"one", cltest.Head(1), big.NewInt(2)},
{"one", testutils.Head(1), big.NewInt(2)},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
Expand All @@ -98,7 +99,7 @@ func TestEthTxAttempt_GetSignedTx(t *testing.T) {

chainID := big.NewInt(3)

signedTx, err := ethKeyStore.SignTx(testutils.Context(t), fromAddress, tx, chainID)
signedTx, err := ethKeyStore.SignTx(tests.Context(t), fromAddress, tx, chainID)
require.NoError(t, err)
rlp := new(bytes.Buffer)
require.NoError(t, signedTx.EncodeRLP(rlp))
Expand Down
8 changes: 5 additions & 3 deletions core/chains/evm/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ import (
"github.com/stretchr/testify/assert"
"go.uber.org/multierr"

"github.com/smartcontractkit/chainlink-common/pkg/utils/tests"

"github.com/smartcontractkit/chainlink/v2/core/chains/evm/testutils"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils"
)

func TestKeccak256(t *testing.T) {
Expand Down Expand Up @@ -208,7 +210,7 @@ func TestRetryWithBackoff(t *testing.T) {
t.Parallel()

var counter atomic.Int32
ctx, cancel := context.WithCancel(testutils.Context(t))
ctx, cancel := context.WithCancel(tests.Context(t))

utils.RetryWithBackoff(ctx, func() bool {
return false
Expand All @@ -222,7 +224,7 @@ func TestRetryWithBackoff(t *testing.T) {

assert.Eventually(t, func() bool {
return counter.Load() == 3
}, testutils.WaitTimeout(t), testutils.TestInterval)
}, tests.WaitTimeout(t), tests.TestInterval)

cancel()

Expand Down