Skip to content

Commit 2aa48f2

Browse files
JonathanOppenheimeralarso16StephenButtolph
authored
sync: coreth PR #1271: style: enable depguard linter (#1886)
Signed-off-by: Jonathan Oppenheimer <[email protected]> Signed-off-by: Jonathan Oppenheimer <[email protected]> Co-authored-by: Austin Larson <[email protected]> Co-authored-by: Austin Larson <[email protected]> Co-authored-by: Stephen Buttolph <[email protected]>
1 parent 718aee3 commit 2aa48f2

File tree

22 files changed

+286
-311
lines changed

22 files changed

+286
-311
lines changed

.avalanche-golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ linters:
5454
- asciicheck
5555
- bodyclose
5656
- copyloopvar
57-
# - depguard
57+
- depguard
5858
# - errcheck
5959
- errorlint
6060
- forbidigo

core/blockchain_ext_test.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"github.com/ava-labs/libevm/crypto"
1919
"github.com/ava-labs/libevm/ethdb"
2020
"github.com/holiman/uint256"
21-
"github.com/stretchr/testify/assert"
2221
"github.com/stretchr/testify/require"
2322

2423
"github.com/ava-labs/subnet-evm/commontype"
@@ -1439,7 +1438,6 @@ func StatefulPrecompiles(t *testing.T, create createFunc) {
14391438
MaxBlockGasCost: big.NewInt(4_000_000),
14401439
BlockGasCostStep: big.NewInt(500_000),
14411440
}
1442-
assert := assert.New(t)
14431441
tests := map[string]test{
14441442
"allow list": {
14451443
addTx: func(gen *BlockGen) {
@@ -1501,23 +1499,23 @@ func StatefulPrecompiles(t *testing.T, create createFunc) {
15011499
},
15021500
verifyState: func(sdb *state.StateDB) error {
15031501
res := feemanager.GetFeeManagerStatus(sdb, addr1)
1504-
assert.Equal(allowlist.AdminRole, res)
1502+
require.Equal(t, allowlist.AdminRole, res)
15051503

15061504
storedConfig := feemanager.GetStoredFeeConfig(sdb)
1507-
assert.Equal(testFeeConfig, storedConfig)
1505+
require.Equal(t, testFeeConfig, storedConfig)
15081506

15091507
feeConfig, _, err := blockchain.GetFeeConfigAt(blockchain.CurrentHeader())
15101508
require.NoError(t, err)
1511-
assert.Equal(testFeeConfig, feeConfig)
1509+
require.Equal(t, testFeeConfig, feeConfig)
15121510
return nil
15131511
},
15141512
verifyGenesis: func(sdb *state.StateDB) {
15151513
res := feemanager.GetFeeManagerStatus(sdb, addr1)
1516-
assert.Equal(allowlist.AdminRole, res)
1514+
require.Equal(t, allowlist.AdminRole, res)
15171515

15181516
feeConfig, _, err := blockchain.GetFeeConfigAt(blockchain.Genesis().Header())
15191517
require.NoError(t, err)
1520-
assert.Equal(params.GetExtra(&config).FeeConfig, feeConfig)
1518+
require.Equal(t, params.GetExtra(&config).FeeConfig, feeConfig)
15211519
},
15221520
},
15231521
}

core/coretest/test_indices.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
"github.com/ava-labs/libevm/core/rawdb"
1111
"github.com/ava-labs/libevm/ethdb"
12-
"github.com/stretchr/testify/assert"
1312
"github.com/stretchr/testify/require"
1413
)
1514

@@ -25,10 +24,10 @@ func CheckTxIndices(t *testing.T, expectedTail *uint64, indexedFrom uint64, inde
2524
var stored uint64
2625
tailValue := *expectedTail
2726

28-
require.EventuallyWithTf(t,
29-
func(c *assert.CollectT) {
27+
require.Eventually(t,
28+
func() bool {
3029
stored = *rawdb.ReadTxIndexTail(db)
31-
assert.Equalf(c, tailValue, stored, "expected tail to be %d, found %d", tailValue, stored)
30+
return tailValue == stored
3231
},
3332
30*time.Second, 500*time.Millisecond, "expected tail to be %d eventually", tailValue)
3433
}

internal/ethapi/api_extra_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"github.com/ava-labs/libevm/common"
1313
"github.com/ava-labs/libevm/common/hexutil"
1414
"github.com/ava-labs/libevm/core/types"
15-
"github.com/stretchr/testify/assert"
1615
"github.com/stretchr/testify/require"
1716
"go.uber.org/mock/gomock"
1817

@@ -47,7 +46,7 @@ func TestBlockchainAPI_GetChainConfig(t *testing.T) {
4746
api := NewBlockChainAPI(backend)
4847

4948
gotConfig := api.GetChainConfig(t.Context())
50-
assert.Equal(t, params.ToWithUpgradesJSON(wantConfig), gotConfig)
49+
require.Equal(t, params.ToWithUpgradesJSON(wantConfig), gotConfig)
5150
}
5251

5352
// Copy one test case from TestCall
@@ -204,9 +203,9 @@ func TestBlockChainAPI_stateQueryBlockNumberAllowed(t *testing.T) {
204203

205204
err := api.stateQueryBlockNumberAllowed(testCase.blockNumOrHash)
206205
if testCase.wantErrMessage == "" {
207-
assert.NoError(t, err)
206+
require.NoError(t, err)
208207
} else {
209-
assert.EqualError(t, err, testCase.wantErrMessage)
208+
require.EqualError(t, err, testCase.wantErrMessage)
210209
}
211210
})
212211
}

0 commit comments

Comments
 (0)