Skip to content

Commit

Permalink
Decouple utils tests from core (#12993)
Browse files Browse the repository at this point in the history
* Add first version of evm utils

* Remove unused context util

* Add WSServer tests

* Add NewLegacyTransaction test

* Update NewTestChainScopedConfig to apply correct defaults

* Move testutils

* Decouple utils tests from core

* Add changeset
  • Loading branch information
dimriou authored May 10, 2024
1 parent fbd94c4 commit 2a8d1b1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
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

0 comments on commit 2a8d1b1

Please sign in to comment.