From 24926bbe8864ce00138790be0e72ebe2017c7aa7 Mon Sep 17 00:00:00 2001 From: Evgenii Baidakov Date: Wed, 25 Oct 2023 14:03:07 +0400 Subject: [PATCH] linter: Fix revive - should not use dot imports Signed-off-by: Evgenii Baidakov --- netmap/network_info_test.go | 72 ++++++++++++++++++------------------- netmap/policy_test.go | 8 ++--- user/id_test.go | 12 +++---- 3 files changed, 46 insertions(+), 46 deletions(-) diff --git a/netmap/network_info_test.go b/netmap/network_info_test.go index c862077d..87db6fa2 100644 --- a/netmap/network_info_test.go +++ b/netmap/network_info_test.go @@ -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()) @@ -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()) @@ -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()) @@ -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()) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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() } @@ -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() } @@ -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) diff --git a/netmap/policy_test.go b/netmap/policy_test.go index 65f46c66..4efaa3dd 100644 --- a/netmap/policy_test.go +++ b/netmap/policy_test.go @@ -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" ) @@ -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)) @@ -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) @@ -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) diff --git a/user/id_test.go b/user/id_test.go index df5fd5bd..525164df 100644 --- a/user/id_test.go +++ b/user/id_test.go @@ -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" ) @@ -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() @@ -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) @@ -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) @@ -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)