Skip to content

Commit

Permalink
linter: Fix revive - should not use dot imports
Browse files Browse the repository at this point in the history
Signed-off-by: Evgenii Baidakov <[email protected]>
  • Loading branch information
smallhive committed Oct 27, 2023
1 parent 1521113 commit 24926bb
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 46 deletions.
72 changes: 36 additions & 36 deletions netmap/network_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"math"
"testing"

"github.com/nspcc-dev/neofs-api-go/v2/netmap"
. "github.com/nspcc-dev/neofs-sdk-go/netmap"
netmapv2 "github.com/nspcc-dev/neofs-api-go/v2/netmap"
"github.com/nspcc-dev/neofs-sdk-go/netmap"
netmaptest "github.com/nspcc-dev/neofs-sdk-go/netmap/test"
"github.com/stretchr/testify/require"
)

func TestNetworkInfo_CurrentEpoch(t *testing.T) {
var x NetworkInfo
var x netmap.NetworkInfo

require.Zero(t, x.CurrentEpoch())

Expand All @@ -22,14 +22,14 @@ func TestNetworkInfo_CurrentEpoch(t *testing.T) {

require.EqualValues(t, e, x.CurrentEpoch())

var m netmap.NetworkInfo
var m netmapv2.NetworkInfo
x.WriteToV2(&m)

require.EqualValues(t, e, m.GetCurrentEpoch())
}

func TestNetworkInfo_MagicNumber(t *testing.T) {
var x NetworkInfo
var x netmap.NetworkInfo

require.Zero(t, x.MagicNumber())

Expand All @@ -39,14 +39,14 @@ func TestNetworkInfo_MagicNumber(t *testing.T) {

require.EqualValues(t, magic, x.MagicNumber())

var m netmap.NetworkInfo
var m netmapv2.NetworkInfo
x.WriteToV2(&m)

require.EqualValues(t, magic, m.GetMagicNumber())
}

func TestNetworkInfo_MsPerBlock(t *testing.T) {
var x NetworkInfo
var x netmap.NetworkInfo

require.Zero(t, x.MsPerBlock())

Expand All @@ -56,31 +56,31 @@ func TestNetworkInfo_MsPerBlock(t *testing.T) {

require.EqualValues(t, ms, x.MsPerBlock())

var m netmap.NetworkInfo
var m netmapv2.NetworkInfo
x.WriteToV2(&m)

require.EqualValues(t, ms, m.GetMsPerBlock())
}

func testConfigValue(t *testing.T,
getter func(x NetworkInfo) any,
setter func(x *NetworkInfo, val any),
getter func(x netmap.NetworkInfo) any,
setter func(x *netmap.NetworkInfo, val any),
val1, val2 any,
v2Key string, v2Val func(val any) []byte,
) {
var x NetworkInfo
var x netmap.NetworkInfo

require.Zero(t, getter(x))

checkVal := func(exp any) {
require.EqualValues(t, exp, getter(x))

var m netmap.NetworkInfo
var m netmapv2.NetworkInfo
x.WriteToV2(&m)

require.EqualValues(t, 1, m.GetNetworkConfig().NumberOfParameters())
found := false
m.GetNetworkConfig().IterateParameters(func(prm *netmap.NetworkParameter) bool {
m.GetNetworkConfig().IterateParameters(func(prm *netmapv2.NetworkParameter) bool {
require.False(t, found)
require.Equal(t, []byte(v2Key), prm.GetKey())
require.Equal(t, v2Val(exp), prm.GetValue())
Expand All @@ -99,8 +99,8 @@ func testConfigValue(t *testing.T,

func TestNetworkInfo_AuditFee(t *testing.T) {
testConfigValue(t,
func(x NetworkInfo) any { return x.AuditFee() },
func(info *NetworkInfo, val any) { info.SetAuditFee(val.(uint64)) },
func(x netmap.NetworkInfo) any { return x.AuditFee() },
func(info *netmap.NetworkInfo, val any) { info.SetAuditFee(val.(uint64)) },
uint64(1), uint64(2),
"AuditFee", func(val any) []byte {
data := make([]byte, 8)
Expand All @@ -112,8 +112,8 @@ func TestNetworkInfo_AuditFee(t *testing.T) {

func TestNetworkInfo_StoragePrice(t *testing.T) {
testConfigValue(t,
func(x NetworkInfo) any { return x.StoragePrice() },
func(info *NetworkInfo, val any) { info.SetStoragePrice(val.(uint64)) },
func(x netmap.NetworkInfo) any { return x.StoragePrice() },
func(info *netmap.NetworkInfo, val any) { info.SetStoragePrice(val.(uint64)) },
uint64(1), uint64(2),
"BasicIncomeRate", func(val any) []byte {
data := make([]byte, 8)
Expand All @@ -125,8 +125,8 @@ func TestNetworkInfo_StoragePrice(t *testing.T) {

func TestNetworkInfo_ContainerFee(t *testing.T) {
testConfigValue(t,
func(x NetworkInfo) any { return x.ContainerFee() },
func(info *NetworkInfo, val any) { info.SetContainerFee(val.(uint64)) },
func(x netmap.NetworkInfo) any { return x.ContainerFee() },
func(info *netmap.NetworkInfo, val any) { info.SetContainerFee(val.(uint64)) },
uint64(1), uint64(2),
"ContainerFee", func(val any) []byte {
data := make([]byte, 8)
Expand All @@ -138,8 +138,8 @@ func TestNetworkInfo_ContainerFee(t *testing.T) {

func TestNetworkInfo_NamedContainerFee(t *testing.T) {
testConfigValue(t,
func(x NetworkInfo) any { return x.NamedContainerFee() },
func(info *NetworkInfo, val any) { info.SetNamedContainerFee(val.(uint64)) },
func(x netmap.NetworkInfo) any { return x.NamedContainerFee() },
func(info *netmap.NetworkInfo, val any) { info.SetNamedContainerFee(val.(uint64)) },
uint64(1), uint64(2),
"ContainerAliasFee", func(val any) []byte {
data := make([]byte, 8)
Expand All @@ -151,8 +151,8 @@ func TestNetworkInfo_NamedContainerFee(t *testing.T) {

func TestNetworkInfo_EigenTrustAlpha(t *testing.T) {
testConfigValue(t,
func(x NetworkInfo) any { return x.EigenTrustAlpha() },
func(info *NetworkInfo, val any) { info.SetEigenTrustAlpha(val.(float64)) },
func(x netmap.NetworkInfo) any { return x.EigenTrustAlpha() },
func(info *netmap.NetworkInfo, val any) { info.SetEigenTrustAlpha(val.(float64)) },
0.1, 0.2,
"EigenTrustAlpha", func(val any) []byte {
data := make([]byte, 8)
Expand All @@ -164,8 +164,8 @@ func TestNetworkInfo_EigenTrustAlpha(t *testing.T) {

func TestNetworkInfo_NumberOfEigenTrustIterations(t *testing.T) {
testConfigValue(t,
func(x NetworkInfo) any { return x.NumberOfEigenTrustIterations() },
func(info *NetworkInfo, val any) { info.SetNumberOfEigenTrustIterations(val.(uint64)) },
func(x netmap.NetworkInfo) any { return x.NumberOfEigenTrustIterations() },
func(info *netmap.NetworkInfo, val any) { info.SetNumberOfEigenTrustIterations(val.(uint64)) },
uint64(1), uint64(2),
"EigenTrustIterations", func(val any) []byte {
data := make([]byte, 8)
Expand All @@ -177,8 +177,8 @@ func TestNetworkInfo_NumberOfEigenTrustIterations(t *testing.T) {

func TestNetworkInfo_IRCandidateFee(t *testing.T) {
testConfigValue(t,
func(x NetworkInfo) any { return x.IRCandidateFee() },
func(info *NetworkInfo, val any) { info.SetIRCandidateFee(val.(uint64)) },
func(x netmap.NetworkInfo) any { return x.IRCandidateFee() },
func(info *netmap.NetworkInfo, val any) { info.SetIRCandidateFee(val.(uint64)) },
uint64(1), uint64(2),
"InnerRingCandidateFee", func(val any) []byte {
data := make([]byte, 8)
Expand All @@ -190,8 +190,8 @@ func TestNetworkInfo_IRCandidateFee(t *testing.T) {

func TestNetworkInfo_MaxObjectSize(t *testing.T) {
testConfigValue(t,
func(x NetworkInfo) any { return x.MaxObjectSize() },
func(info *NetworkInfo, val any) { info.SetMaxObjectSize(val.(uint64)) },
func(x netmap.NetworkInfo) any { return x.MaxObjectSize() },
func(info *netmap.NetworkInfo, val any) { info.SetMaxObjectSize(val.(uint64)) },
uint64(1), uint64(2),
"MaxObjectSize", func(val any) []byte {
data := make([]byte, 8)
Expand All @@ -203,8 +203,8 @@ func TestNetworkInfo_MaxObjectSize(t *testing.T) {

func TestNetworkInfo_WithdrawalFee(t *testing.T) {
testConfigValue(t,
func(x NetworkInfo) any { return x.WithdrawalFee() },
func(info *NetworkInfo, val any) { info.SetWithdrawalFee(val.(uint64)) },
func(x netmap.NetworkInfo) any { return x.WithdrawalFee() },
func(info *netmap.NetworkInfo, val any) { info.SetWithdrawalFee(val.(uint64)) },
uint64(1), uint64(2),
"WithdrawFee", func(val any) []byte {
data := make([]byte, 8)
Expand All @@ -216,8 +216,8 @@ func TestNetworkInfo_WithdrawalFee(t *testing.T) {

func TestNetworkInfo_HomomorphicHashingDisabled(t *testing.T) {
testConfigValue(t,
func(x NetworkInfo) any { return x.HomomorphicHashingDisabled() },
func(info *NetworkInfo, val any) {
func(x netmap.NetworkInfo) any { return x.HomomorphicHashingDisabled() },
func(info *netmap.NetworkInfo, val any) {
if val.(bool) {
info.DisableHomomorphicHashing()
}
Expand All @@ -237,8 +237,8 @@ func TestNetworkInfo_HomomorphicHashingDisabled(t *testing.T) {

func TestNetworkInfo_MaintenanceModeAllowed(t *testing.T) {
testConfigValue(t,
func(x NetworkInfo) any { return x.MaintenanceModeAllowed() },
func(info *NetworkInfo, val any) {
func(x netmap.NetworkInfo) any { return x.MaintenanceModeAllowed() },
func(info *netmap.NetworkInfo, val any) {
if val.(bool) {
info.AllowMaintenanceMode()
}
Expand All @@ -256,7 +256,7 @@ func TestNetworkInfo_MaintenanceModeAllowed(t *testing.T) {
func TestNetworkInfo_Marshal(t *testing.T) {
v := netmaptest.NetworkInfo()

var v2 NetworkInfo
var v2 netmap.NetworkInfo
require.NoError(t, v2.Unmarshal(v.Marshal()))

require.Equal(t, v, v2)
Expand Down
8 changes: 4 additions & 4 deletions netmap/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"strings"
"testing"

. "github.com/nspcc-dev/neofs-sdk-go/netmap"
"github.com/nspcc-dev/neofs-sdk-go/netmap"
netmaptest "github.com/nspcc-dev/neofs-sdk-go/netmap/test"
"github.com/stretchr/testify/require"
)
Expand All @@ -25,7 +25,7 @@ SELECT 1 IN City FROM SPBSSD AS SPB
FILTER City EQ SPB AND SSD EQ true OR City EQ SPB AND Rating GE 5 AS SPBSSD`,
}

var p PlacementPolicy
var p netmap.PlacementPolicy

for _, testCase := range testCases {
require.NoError(t, p.DecodeString(testCase))
Expand All @@ -49,7 +49,7 @@ func TestPlacementPolicyEncoding(t *testing.T) {
v := netmaptest.PlacementPolicy()

t.Run("binary", func(t *testing.T) {
var v2 PlacementPolicy
var v2 netmap.PlacementPolicy
require.NoError(t, v2.Unmarshal(v.Marshal()))

require.Equal(t, v, v2)
Expand All @@ -59,7 +59,7 @@ func TestPlacementPolicyEncoding(t *testing.T) {
data, err := v.MarshalJSON()
require.NoError(t, err)

var v2 PlacementPolicy
var v2 netmap.PlacementPolicy
require.NoError(t, v2.UnmarshalJSON(data))

require.Equal(t, v, v2)
Expand Down
12 changes: 6 additions & 6 deletions user/id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/util/slice"
"github.com/nspcc-dev/neofs-api-go/v2/refs"
. "github.com/nspcc-dev/neofs-sdk-go/user"
"github.com/nspcc-dev/neofs-sdk-go/user"
usertest "github.com/nspcc-dev/neofs-sdk-go/user/test"
"github.com/stretchr/testify/require"
)
Expand All @@ -17,7 +17,7 @@ func TestID_WalletBytes(t *testing.T) {
var scriptHash util.Uint160
rand.Read(scriptHash[:])

var id ID
var id user.ID
id.SetScriptHash(scriptHash)

w := id.WalletBytes()
Expand All @@ -33,13 +33,13 @@ func TestID_SetScriptHash(t *testing.T) {
var scriptHash util.Uint160
rand.Read(scriptHash[:])

var id ID
var id user.ID
id.SetScriptHash(scriptHash)

var m refs.OwnerID
id.WriteToV2(&m)

var id2 ID
var id2 user.ID

err := id2.ReadFromV2(m)
require.NoError(t, err)
Expand All @@ -50,7 +50,7 @@ func TestID_SetScriptHash(t *testing.T) {
func TestV2_ID(t *testing.T) {
id := usertest.ID(t)
var m refs.OwnerID
var id2 ID
var id2 user.ID

t.Run("OK", func(t *testing.T) {
id.WriteToV2(&m)
Expand Down Expand Up @@ -98,7 +98,7 @@ func TestID_EncodeToString(t *testing.T) {
_, err := base58.Decode(s)
require.NoError(t, err)

var id2 ID
var id2 user.ID

err = id2.DecodeString(s)
require.NoError(t, err)
Expand Down

0 comments on commit 24926bb

Please sign in to comment.