From 408a0621bed65233f99f9d318e651bfbd4fa929a Mon Sep 17 00:00:00 2001 From: Sophia Koehler Date: Wed, 18 Dec 2024 11:59:20 +0100 Subject: [PATCH] chore: Sort imports, gofmt files Signed-off-by: Sophia Koehler --- apps/payment/app_internal_test.go | 2 +- apps/payment/randomizer.go | 1 + apps/payment/resolver_internal_test.go | 2 +- backend/sim/channel/init.go | 1 + backend/sim/wallet/wallet_internal_test.go | 14 +++++++------- channel/allocation.go | 1 + channel/allocation_test.go | 3 ++- channel/app.go | 3 ++- channel/backend.go | 1 + channel/errors.go | 1 + channel/errors_internal_test.go | 3 ++- channel/funder_internal_test.go | 6 +++--- channel/machine.go | 3 ++- channel/machine_test.go | 3 ++- channel/mock_app.go | 1 + channel/mock_app_internal_test.go | 3 ++- channel/multi/adjudicator.go | 1 + channel/multi/subscription.go | 1 + channel/params.go | 15 ++++++++------- channel/params_test.go | 3 ++- channel/persistence/keyvalue/cache.go | 1 + channel/persistence/keyvalue/persistedstate.go | 1 + channel/persistence/keyvalue/persister.go | 3 ++- .../keyvalue/persistrestorer_internal_test.go | 4 ++-- channel/persistence/nonpersister.go | 1 + channel/persistence/persistence.go | 1 + channel/persistence/statemachine_test.go | 3 ++- channel/persistence/test/peerchans.go | 1 + .../persistence/test/peerchans_internal_test.go | 3 ++- channel/persistence/test/persistrestorer.go | 3 ++- channel/persistence/test/persistrestorertest.go | 5 +++-- channel/state.go | 1 + channel/test/app_randomizer.go | 1 + channel/test/app_randomizer_internal_test.go | 4 ++-- channel/test/mock_app_randomizer.go | 1 + channel/test/randomopts.go | 5 +++-- channel/transaction_test.go | 3 ++- client/adjudicate.go | 1 + client/appchannel_test.go | 3 ++- client/channelconn.go | 1 + client/chanregistry.go | 3 ++- client/client_role_test.go | 3 ++- client/client_test.go | 3 ++- client/clientconn.go | 1 + client/payment_test.go | 3 ++- client/proposal_internal_test.go | 3 ++- client/restore.go | 1 + client/serialize.go | 1 + client/subchannel.go | 1 + client/subchannel_test.go | 3 ++- client/sync.go | 3 ++- client/syncmsgs.go | 1 + client/test/channel.go | 3 ++- client/test/fund.go | 3 ++- client/test/multiledger_dispute.go | 3 ++- client/test/multiledger_happy.go | 3 ++- client/test/persistence.go | 3 ++- client/test/subchannel_dispute.go | 3 ++- client/test/virtualchannel.go | 3 ++- client/updateinterception.go | 3 ++- log/logrus/logrus_internal_test.go | 2 +- watcher/local/registry.go | 3 ++- watcher/local/watcher.go | 3 ++- watcher/local/watcher_test.go | 3 ++- watcher/watcher.go | 1 + wire/account.go | 1 + wire/cache_internal_test.go | 2 +- wire/hybridbus.go | 1 + wire/hybridbus_test.go | 3 ++- wire/localbus.go | 3 ++- wire/localbus_test.go | 3 ++- wire/net/bus.go | 3 ++- wire/net/bus_test.go | 3 ++- wire/net/dialer.go | 1 + wire/net/endpoint.go | 1 + wire/net/endpoint_internal_test.go | 5 +++-- wire/net/endpoint_registry.go | 5 +++-- wire/net/endpoint_registry_external_test.go | 5 +++-- wire/net/endpoint_registry_internal_test.go | 3 ++- wire/net/exchange_addr.go | 1 + wire/net/exchange_addr_internal_test.go | 3 ++- wire/net/simple/account.go | 3 ++- wire/net/simple/address.go | 1 + wire/net/simple/dialer.go | 3 ++- wire/net/simple/dialer_internal_test.go | 3 ++- wire/net/simple/simple_exchange_addr_test.go | 3 ++- wire/net/test/connhub.go | 3 ++- wire/net/test/connhub_internal_test.go | 3 ++- wire/net/test/dialer.go | 3 ++- wire/net/test/dialerlist_internal_test.go | 2 +- wire/net/test/listenermap.go | 3 ++- wire/protobuf/proposalmsgs.go | 5 +++-- wire/protobuf/serializer.go | 1 + wire/protobuf/wire.pb.go | 5 +++-- wire/relay_internal_test.go | 2 +- wire/test/bustest.go | 2 +- wire/test/randomizer.go | 1 + 97 files changed, 174 insertions(+), 88 deletions(-) diff --git a/apps/payment/app_internal_test.go b/apps/payment/app_internal_test.go index 01eb8f477..8e7594bd7 100644 --- a/apps/payment/app_internal_test.go +++ b/apps/payment/app_internal_test.go @@ -42,7 +42,7 @@ func TestApp_ValidInit(t *testing.T) { assert.Panics(func() { app.ValidInit(nil, wrongdata) }) //nolint:errcheck data := &channel.State{Data: Data()} - assert.Nil(app.ValidInit(nil, data)) + assert.NoError(app.ValidInit(nil, data)) } func TestApp_ValidTransition(t *testing.T) { diff --git a/apps/payment/randomizer.go b/apps/payment/randomizer.go index 83245ac02..76bf93304 100644 --- a/apps/payment/randomizer.go +++ b/apps/payment/randomizer.go @@ -16,6 +16,7 @@ package payment import ( "math/rand" + "perun.network/go-perun/wallet" "perun.network/go-perun/channel" diff --git a/apps/payment/resolver_internal_test.go b/apps/payment/resolver_internal_test.go index 5a63afc79..add1f30bc 100644 --- a/apps/payment/resolver_internal_test.go +++ b/apps/payment/resolver_internal_test.go @@ -47,7 +47,7 @@ func TestData(t *testing.T) { assert.NotPanics(func() { data := Data() _, err := data.MarshalBinary() - assert.Nil(err) + assert.NoError(err) }) assert.NotPanics(func() { diff --git a/backend/sim/channel/init.go b/backend/sim/channel/init.go index 7d38b32b5..09dbbe956 100644 --- a/backend/sim/channel/init.go +++ b/backend/sim/channel/init.go @@ -16,6 +16,7 @@ package channel import ( "math/rand" + "perun.network/go-perun/channel" "perun.network/go-perun/channel/test" ) diff --git a/backend/sim/wallet/wallet_internal_test.go b/backend/sim/wallet/wallet_internal_test.go index b6f6a4d7f..7eb2c60de 100644 --- a/backend/sim/wallet/wallet_internal_test.go +++ b/backend/sim/wallet/wallet_internal_test.go @@ -45,11 +45,11 @@ func TestSignatureSerialize(t *testing.T) { s := new(big.Int).SetBytes(sBytes) sig, err1 := serializeSignature(r, s) - a.Nil(err1, "Serialization should not fail") - a.Equal(curve.Params().BitSize/4, len(sig), "Signature has wrong size") + a.NoError(err1, "Serialization should not fail") + a.Len(sig, curve.Params().BitSize/4, "Signature has wrong size") R, S, err2 := deserializeSignature(sig) - a.Nil(err2, "Deserialization should not fail") + a.NoError(err2, "Deserialization should not fail") a.Equal(r, R, "Serialized and deserialized r values should be equal") a.Equal(s, S, "Serialized and deserialized s values should be equal") } @@ -80,10 +80,10 @@ func TestGenericTests(t *testing.T) { addrStrLen := addrLen*2 + 2 // hex encoded and prefixed with 0x str0 := addr0.String() str1 := addr1.String() - assert.Equal( - t, addrStrLen, len(str0), "First address '%v' has wrong length", str0) - assert.Equal( - t, addrStrLen, len(str1), "Second address '%v' has wrong length", str1) + assert.Len( + t, str0, addrStrLen, "First address '%v' has wrong length", str0) + assert.Len( + t, str1, addrStrLen, "Second address '%v' has wrong length", str1) assert.NotEqual( t, str0, str1, "Printed addresses are unlikely to be identical") } diff --git a/channel/allocation.go b/channel/allocation.go index 0a8c7cf5c..f117705b6 100644 --- a/channel/allocation.go +++ b/channel/allocation.go @@ -19,6 +19,7 @@ import ( "io" "log" "math/big" + "perun.network/go-perun/wallet" "perun.network/go-perun/wire/perunio" diff --git a/channel/allocation_test.go b/channel/allocation_test.go index 85dfc46b5..74706df81 100644 --- a/channel/allocation_test.go +++ b/channel/allocation_test.go @@ -17,9 +17,10 @@ package channel_test import ( "math/big" "math/rand" - "perun.network/go-perun/wallet" "testing" + "perun.network/go-perun/wallet" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/channel/app.go b/channel/app.go index e853c354d..66fb7c8c2 100644 --- a/channel/app.go +++ b/channel/app.go @@ -16,9 +16,10 @@ package channel import ( "encoding" - "github.com/pkg/errors" "io" + "github.com/pkg/errors" + "perun.network/go-perun/wire/perunio" ) diff --git a/channel/backend.go b/channel/backend.go index 4a710d697..5c25782ac 100644 --- a/channel/backend.go +++ b/channel/backend.go @@ -16,6 +16,7 @@ package channel import ( "errors" + "perun.network/go-perun/wallet" ) diff --git a/channel/errors.go b/channel/errors.go index 6a7f98018..5e75bb99d 100644 --- a/channel/errors.go +++ b/channel/errors.go @@ -16,6 +16,7 @@ package channel import ( "fmt" + "perun.network/go-perun/wallet" "github.com/pkg/errors" diff --git a/channel/errors_internal_test.go b/channel/errors_internal_test.go index ad187d5ec..d3cdfb3e1 100644 --- a/channel/errors_internal_test.go +++ b/channel/errors_internal_test.go @@ -16,9 +16,10 @@ package channel import ( "errors" - "perun.network/go-perun/wallet" "testing" + "perun.network/go-perun/wallet" + "github.com/stretchr/testify/assert" ) diff --git a/channel/funder_internal_test.go b/channel/funder_internal_test.go index ee362113d..a547772df 100644 --- a/channel/funder_internal_test.go +++ b/channel/funder_internal_test.go @@ -34,8 +34,8 @@ func TestAssetFundingError(t *testing.T) { assert.Equal(Index(2), perr.TimedOutPeers[1]) assert.Equal(Index(3), perr.TimedOutPeers[2]) assert.Equal(Index(4), perr.TimedOutPeers[3]) - assert.Equal(4, len(perr.TimedOutPeers)) - assert.Equal(perr.Error(), "Funding Error on asset [42] peers: [1], [2], [3], [4], did not fund channel in time") + assert.Len(perr.TimedOutPeers, 4) + assert.Equal("Funding Error on asset [42] peers: [1], [2], [3], [4], did not fund channel in time", perr.Error()) assert.False(IsAssetFundingError(errors.New("not a asset funding error"))) } @@ -61,7 +61,7 @@ func TestFundingTimeoutError(t *testing.T) { assert.Equal(Index(1), perr.Errors[2].TimedOutPeers[0]) assert.Equal(Index(3), perr.Errors[2].TimedOutPeers[1]) assert.Equal(3, len(perr.Errors)) - assert.Equal(perr.Error(), "Funding Error on asset [42] peers: [1], [2], did not fund channel in time; Funding Error on asset [1337] peers: [0], [2], did not fund channel in time; Funding Error on asset [7531] peers: [1], [3], did not fund channel in time; ") + assert.Equal("Funding Error on asset [42] peers: [1], [2], did not fund channel in time; Funding Error on asset [1337] peers: [0], [2], did not fund channel in time; Funding Error on asset [7531] peers: [1], [3], did not fund channel in time; ", perr.Error()) // test no funding timeout error assert.False(IsFundingTimeoutError(errors.New("no FundingTimeoutError"))) // nil input should not return error diff --git a/channel/machine.go b/channel/machine.go index da17d5fe1..e8663ea56 100644 --- a/channel/machine.go +++ b/channel/machine.go @@ -16,9 +16,10 @@ package channel import ( "fmt" - "github.com/pkg/errors" stdio "io" + "github.com/pkg/errors" + "perun.network/go-perun/log" "perun.network/go-perun/wallet" "perun.network/go-perun/wire/perunio" diff --git a/channel/machine_test.go b/channel/machine_test.go index efced47b7..86e6020b2 100644 --- a/channel/machine_test.go +++ b/channel/machine_test.go @@ -15,9 +15,10 @@ package channel_test import ( - "perun.network/go-perun/wallet" "testing" + "perun.network/go-perun/wallet" + "github.com/stretchr/testify/require" "perun.network/go-perun/channel" "perun.network/go-perun/channel/test" diff --git a/channel/mock_app.go b/channel/mock_app.go index 8308bd633..8d9b03de1 100644 --- a/channel/mock_app.go +++ b/channel/mock_app.go @@ -17,6 +17,7 @@ package channel import ( "encoding/binary" "fmt" + "perun.network/go-perun/wallet" "github.com/pkg/errors" diff --git a/channel/mock_app_internal_test.go b/channel/mock_app_internal_test.go index a2b9e1a82..98bfc3ce0 100644 --- a/channel/mock_app_internal_test.go +++ b/channel/mock_app_internal_test.go @@ -15,9 +15,10 @@ package channel import ( - "perun.network/go-perun/wallet" "testing" + "perun.network/go-perun/wallet" + "github.com/stretchr/testify/assert" wiretest "perun.network/go-perun/wire/test" diff --git a/channel/multi/adjudicator.go b/channel/multi/adjudicator.go index 87d60052a..105090362 100644 --- a/channel/multi/adjudicator.go +++ b/channel/multi/adjudicator.go @@ -17,6 +17,7 @@ package multi import ( "context" "fmt" + "perun.network/go-perun/channel" ) diff --git a/channel/multi/subscription.go b/channel/multi/subscription.go index 956902b0c..cc518bb82 100644 --- a/channel/multi/subscription.go +++ b/channel/multi/subscription.go @@ -16,6 +16,7 @@ package multi import ( "context" + "perun.network/go-perun/channel" "perun.network/go-perun/wallet" ) diff --git a/channel/params.go b/channel/params.go index 5f04ddecf..6e6f3e38e 100644 --- a/channel/params.go +++ b/channel/params.go @@ -147,24 +147,25 @@ func sortIDMap(ids IDMap) ([]wallet.BackendID, []ID) { return sortedIndexes, sortedIDs } +//nolint:unused func FromIDKey(k string) IDMap { - buff := bytes.NewBuffer([]byte(k)) + reader := bytes.NewReader([]byte(k)) var numElements int32 // Manually decode the number of elements in the map. - if err := binary.Read(buff, binary.BigEndian, &numElements); err != nil { - log.Panicf("could not decode map length in FromIDKey: " + err.Error()) + if err := binary.Read(reader, binary.BigEndian, &numElements); err != nil { + log.Panicf("could not decode map length in FromIDKey: %v", err) } a := make(map[wallet.BackendID]ID, numElements) // Decode each key-value pair and insert them into the map. for i := 0; i < int(numElements); i++ { var key int32 - if err := binary.Read(buff, binary.BigEndian, &key); err != nil { - log.Panicf("could not decode map key in FromIDKey: " + err.Error()) + if err := binary.Read(reader, binary.BigEndian, &key); err != nil { + log.Panicf("could not decode map key in FromIDKey: %v", err) } id := ID{} - if err := perunio.Decode(buff, &id); err != nil { - log.Panicf("could not decode map[int]ID in FromIDKey: " + err.Error()) + if err := perunio.Decode(reader, &id); err != nil { + log.Panicf("could not decode map[int]ID in FromIDKey: %v", err) } a[wallet.BackendID(key)] = id } diff --git a/channel/params_test.go b/channel/params_test.go index 7aa12eebf..0c249c8e0 100644 --- a/channel/params_test.go +++ b/channel/params_test.go @@ -15,9 +15,10 @@ package channel_test import ( - "github.com/stretchr/testify/require" "testing" + "github.com/stretchr/testify/require" + "perun.network/go-perun/channel" "perun.network/go-perun/channel/test" "perun.network/go-perun/wire/perunio" diff --git a/channel/persistence/keyvalue/cache.go b/channel/persistence/keyvalue/cache.go index af667f4a4..6fbb875d1 100644 --- a/channel/persistence/keyvalue/cache.go +++ b/channel/persistence/keyvalue/cache.go @@ -31,6 +31,7 @@ func newChannelCache() *channelCache { } // channelCache contains all channels. +// //nolint:unused type channelCache struct { mutex stdsync.RWMutex diff --git a/channel/persistence/keyvalue/persistedstate.go b/channel/persistence/keyvalue/persistedstate.go index 719f3663c..00d670ef7 100644 --- a/channel/persistence/keyvalue/persistedstate.go +++ b/channel/persistence/keyvalue/persistedstate.go @@ -16,6 +16,7 @@ package keyvalue import ( "io" + "perun.network/go-perun/wallet" "perun.network/go-perun/channel" diff --git a/channel/persistence/keyvalue/persister.go b/channel/persistence/keyvalue/persister.go index 3ed6f2146..8b480ee38 100644 --- a/channel/persistence/keyvalue/persister.go +++ b/channel/persistence/keyvalue/persister.go @@ -19,11 +19,12 @@ import ( "context" "fmt" "math" - "perun.network/go-perun/wallet" "regexp" "strconv" "strings" + "perun.network/go-perun/wallet" + "github.com/pkg/errors" "perun.network/go-perun/channel" diff --git a/channel/persistence/keyvalue/persistrestorer_internal_test.go b/channel/persistence/keyvalue/persistrestorer_internal_test.go index bafd808c0..3fcf9c878 100644 --- a/channel/persistence/keyvalue/persistrestorer_internal_test.go +++ b/channel/persistence/keyvalue/persistrestorer_internal_test.go @@ -16,7 +16,7 @@ package keyvalue import ( "context" - "io/ioutil" + "os" "testing" "github.com/stretchr/testify/assert" @@ -31,7 +31,7 @@ import ( ) func TestPersistRestorer_Generic(t *testing.T) { - tmpdir, err := ioutil.TempDir("", "perun-test-kvpersistrestorer-db-*") + tmpdir, err := os.MkdirTemp("", "perun-test-kvpersistrestorer-db-*") require.NoError(t, err) lvldb, err := leveldb.LoadDatabase(tmpdir) require.NoError(t, err) diff --git a/channel/persistence/nonpersister.go b/channel/persistence/nonpersister.go index d37c6974a..2fca64124 100644 --- a/channel/persistence/nonpersister.go +++ b/channel/persistence/nonpersister.go @@ -16,6 +16,7 @@ package persistence import ( "context" + "perun.network/go-perun/wallet" "github.com/pkg/errors" diff --git a/channel/persistence/persistence.go b/channel/persistence/persistence.go index 52ce930b9..38b1f04eb 100644 --- a/channel/persistence/persistence.go +++ b/channel/persistence/persistence.go @@ -17,6 +17,7 @@ package persistence import ( "context" "io" + "perun.network/go-perun/wallet" "perun.network/go-perun/channel" diff --git a/channel/persistence/statemachine_test.go b/channel/persistence/statemachine_test.go index 648aa0afd..daf9d3d44 100644 --- a/channel/persistence/statemachine_test.go +++ b/channel/persistence/statemachine_test.go @@ -16,10 +16,11 @@ package persistence_test import ( "context" - "perun.network/go-perun/wallet" "testing" "time" + "perun.network/go-perun/wallet" + "github.com/stretchr/testify/require" "perun.network/go-perun/channel" diff --git a/channel/persistence/test/peerchans.go b/channel/persistence/test/peerchans.go index 18c90cc34..d54b8b6b8 100644 --- a/channel/persistence/test/peerchans.go +++ b/channel/persistence/test/peerchans.go @@ -17,6 +17,7 @@ package test import ( "bytes" "fmt" + "perun.network/go-perun/wallet" "perun.network/go-perun/channel" diff --git a/channel/persistence/test/peerchans_internal_test.go b/channel/persistence/test/peerchans_internal_test.go index f6b710032..d14802362 100644 --- a/channel/persistence/test/peerchans_internal_test.go +++ b/channel/persistence/test/peerchans_internal_test.go @@ -15,9 +15,10 @@ package test import ( - "perun.network/go-perun/wallet" "testing" + "perun.network/go-perun/wallet" + "github.com/stretchr/testify/assert" "perun.network/go-perun/channel" diff --git a/channel/persistence/test/persistrestorer.go b/channel/persistence/test/persistrestorer.go index c7fa5e977..77177b867 100644 --- a/channel/persistence/test/persistrestorer.go +++ b/channel/persistence/test/persistrestorer.go @@ -19,10 +19,11 @@ package test // import "perun.network/go-perun/channel/persistence/test" import ( "bytes" "context" - "perun.network/go-perun/wallet" "sync" "testing" + "perun.network/go-perun/wallet" + "github.com/pkg/errors" "github.com/stretchr/testify/assert" diff --git a/channel/persistence/test/persistrestorertest.go b/channel/persistence/test/persistrestorertest.go index f372cd45b..949cdb9d4 100644 --- a/channel/persistence/test/persistrestorertest.go +++ b/channel/persistence/test/persistrestorertest.go @@ -17,9 +17,10 @@ package test import ( "context" "math/rand" - "perun.network/go-perun/wallet" "testing" + "perun.network/go-perun/wallet" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -197,5 +198,5 @@ peerLoop: ps, err := pr.ActivePeers(ctx) require.NoError(t, err) - require.Len(t, ps, 0) + require.Empty(t, ps) } diff --git a/channel/state.go b/channel/state.go index d13cdf3f9..1a01ddbe1 100644 --- a/channel/state.go +++ b/channel/state.go @@ -17,6 +17,7 @@ package channel import ( "encoding" "io" + "perun.network/go-perun/wallet" "perun.network/go-perun/wire" diff --git a/channel/test/app_randomizer.go b/channel/test/app_randomizer.go index 99b651848..271f5ec25 100644 --- a/channel/test/app_randomizer.go +++ b/channel/test/app_randomizer.go @@ -16,6 +16,7 @@ package test import ( "math/rand" + "perun.network/go-perun/wallet" "perun.network/go-perun/channel" diff --git a/channel/test/app_randomizer_internal_test.go b/channel/test/app_randomizer_internal_test.go index 3416841a2..bfd194306 100644 --- a/channel/test/app_randomizer_internal_test.go +++ b/channel/test/app_randomizer_internal_test.go @@ -32,11 +32,11 @@ func TestAppRandomizerSet(t *testing.T) { assert.NotPanics(t, func() { SetAppRandomizer(NewMockAppRandomizer()) }, "first SetAppRandomizer() should work") assert.True(t, isAppRandomizerSet, "isAppRandomizerSet should be true") assert.NotNil(t, appRandomizer, "appRandomizer should not be nil") - assert.False(t, old == appRandomizer, "appRandomizer should have changed") + assert.NotEqualf(t, old, appRandomizer, "appRandomizer should have changed") old = appRandomizer assert.Panics(t, func() { SetAppRandomizer(NewMockAppRandomizer()) }, "second SetAppRandomizer() should panic") assert.True(t, isAppRandomizerSet, "isAppRandomizerSet should be true") assert.NotNil(t, appRandomizer, "appRandomizer should not be nil") - assert.True(t, old == appRandomizer, "appRandomizer should not have changed") + assert.Equal(t, old, appRandomizer, "appRandomizer should not have changed") } diff --git a/channel/test/mock_app_randomizer.go b/channel/test/mock_app_randomizer.go index 0e3b36c67..e2830acb9 100644 --- a/channel/test/mock_app_randomizer.go +++ b/channel/test/mock_app_randomizer.go @@ -16,6 +16,7 @@ package test import ( "math/rand" + "perun.network/go-perun/wallet" "github.com/google/uuid" diff --git a/channel/test/randomopts.go b/channel/test/randomopts.go index 0ce550159..2872d114b 100644 --- a/channel/test/randomopts.go +++ b/channel/test/randomopts.go @@ -15,6 +15,7 @@ package test import ( + "errors" "fmt" "io" "math/big" @@ -304,7 +305,7 @@ func (o RandomOpt) Assets() []channel.Asset { // Backend returns the `Backend` value of the `RandomOpt`. func (o RandomOpt) Backend() (wallet.BackendID, error) { if _, ok := o["backend"]; !ok { - return 0, fmt.Errorf("backend not set") + return 0, errors.New("backend not set") } return o["backend"].(wallet.BackendID), nil } @@ -312,7 +313,7 @@ func (o RandomOpt) Backend() (wallet.BackendID, error) { // BackendID returns the `BackendID` value from `Allocation` of the `RandomOpt`. func (o RandomOpt) BackendID() ([]wallet.BackendID, error) { if _, ok := o["backendIDs"]; !ok { - return []wallet.BackendID{0}, fmt.Errorf("backend not set") + return []wallet.BackendID{0}, errors.New("backend not set") } return o["backendIDs"].([]wallet.BackendID), nil } diff --git a/channel/transaction_test.go b/channel/transaction_test.go index b6a8e52a3..6a7ccc6a0 100644 --- a/channel/transaction_test.go +++ b/channel/transaction_test.go @@ -15,9 +15,10 @@ package channel_test import ( - "github.com/stretchr/testify/require" "testing" + "github.com/stretchr/testify/require" + "perun.network/go-perun/channel" "perun.network/go-perun/channel/test" peruniotest "perun.network/go-perun/wire/perunio/test" diff --git a/client/adjudicate.go b/client/adjudicate.go index 8957ad59e..d9061165b 100644 --- a/client/adjudicate.go +++ b/client/adjudicate.go @@ -16,6 +16,7 @@ package client import ( "context" + "perun.network/go-perun/wallet" "github.com/pkg/errors" diff --git a/client/appchannel_test.go b/client/appchannel_test.go index 427b8cad6..7911b0fbf 100644 --- a/client/appchannel_test.go +++ b/client/appchannel_test.go @@ -17,9 +17,10 @@ package client_test import ( "context" "math/big" - "perun.network/go-perun/wallet" "testing" + "perun.network/go-perun/wallet" + "perun.network/go-perun/channel" chtest "perun.network/go-perun/channel/test" "perun.network/go-perun/client" diff --git a/client/channelconn.go b/client/channelconn.go index 27c044497..c10446984 100644 --- a/client/channelconn.go +++ b/client/channelconn.go @@ -16,6 +16,7 @@ package client import ( "context" + "github.com/pkg/errors" "golang.org/x/sync/errgroup" "perun.network/go-perun/wallet" diff --git a/client/chanregistry.go b/client/chanregistry.go index afbf04124..4d7db3027 100644 --- a/client/chanregistry.go +++ b/client/chanregistry.go @@ -15,9 +15,10 @@ package client import ( - "perun.network/go-perun/wallet" "sync" + "perun.network/go-perun/wallet" + "perun.network/go-perun/channel" psync "polycry.pt/poly-go/sync" ) diff --git a/client/client_role_test.go b/client/client_role_test.go index aca1a16c9..65a4520b9 100644 --- a/client/client_role_test.go +++ b/client/client_role_test.go @@ -18,10 +18,11 @@ import ( "context" "math/big" "math/rand" - "perun.network/go-perun/wallet" "testing" "time" + "perun.network/go-perun/wallet" + "perun.network/go-perun/apps/payment" chtest "perun.network/go-perun/channel/test" "perun.network/go-perun/client" diff --git a/client/client_test.go b/client/client_test.go index 41a491838..f0f9db45f 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -16,10 +16,11 @@ package client_test import ( "context" - "perun.network/go-perun/wallet" "testing" "time" + "perun.network/go-perun/wallet" + "github.com/pkg/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/client/clientconn.go b/client/clientconn.go index 272bd1974..171cee100 100644 --- a/client/clientconn.go +++ b/client/clientconn.go @@ -16,6 +16,7 @@ package client import ( "context" + "perun.network/go-perun/wallet" "github.com/pkg/errors" diff --git a/client/payment_test.go b/client/payment_test.go index 56437fdc3..1b91bc555 100644 --- a/client/payment_test.go +++ b/client/payment_test.go @@ -18,9 +18,10 @@ import ( "context" "math/big" "math/rand" - "perun.network/go-perun/wallet" "testing" + "perun.network/go-perun/wallet" + chtest "perun.network/go-perun/channel/test" "perun.network/go-perun/client" ctest "perun.network/go-perun/client/test" diff --git a/client/proposal_internal_test.go b/client/proposal_internal_test.go index 59c503688..7c50ff213 100644 --- a/client/proposal_internal_test.go +++ b/client/proposal_internal_test.go @@ -16,9 +16,10 @@ package client import ( "math/rand" - "perun.network/go-perun/wallet" "testing" + "perun.network/go-perun/wallet" + "github.com/pkg/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/client/restore.go b/client/restore.go index 873814039..1e32bc67c 100644 --- a/client/restore.go +++ b/client/restore.go @@ -16,6 +16,7 @@ package client import ( "context" + "perun.network/go-perun/wallet" "github.com/pkg/errors" diff --git a/client/serialize.go b/client/serialize.go index 6278deaa1..95e4d903c 100644 --- a/client/serialize.go +++ b/client/serialize.go @@ -16,6 +16,7 @@ package client import ( "io" + "perun.network/go-perun/wallet" "github.com/pkg/errors" diff --git a/client/subchannel.go b/client/subchannel.go index c5724409f..bfeda2a12 100644 --- a/client/subchannel.go +++ b/client/subchannel.go @@ -16,6 +16,7 @@ package client import ( "context" + "perun.network/go-perun/wallet" "github.com/pkg/errors" diff --git a/client/subchannel_test.go b/client/subchannel_test.go index 063ba9404..ac03932fc 100644 --- a/client/subchannel_test.go +++ b/client/subchannel_test.go @@ -17,9 +17,10 @@ package client_test import ( "context" "math/big" - "perun.network/go-perun/wallet" "testing" + "perun.network/go-perun/wallet" + "perun.network/go-perun/apps/payment" chtest "perun.network/go-perun/channel/test" "perun.network/go-perun/client" diff --git a/client/sync.go b/client/sync.go index e1713b05c..a6c2d1dfa 100644 --- a/client/sync.go +++ b/client/sync.go @@ -17,9 +17,10 @@ package client import ( "context" "log" - "perun.network/go-perun/wallet" "time" + "perun.network/go-perun/wallet" + "github.com/pkg/errors" "perun.network/go-perun/channel" diff --git a/client/syncmsgs.go b/client/syncmsgs.go index b2ee38e99..ceb052a56 100644 --- a/client/syncmsgs.go +++ b/client/syncmsgs.go @@ -16,6 +16,7 @@ package client import ( "io" + "perun.network/go-perun/wallet" "perun.network/go-perun/channel" diff --git a/client/test/channel.go b/client/test/channel.go index 9cee1dec3..a812df0d5 100644 --- a/client/test/channel.go +++ b/client/test/channel.go @@ -19,9 +19,10 @@ import ( "errors" "io" "math/big" - "perun.network/go-perun/wallet" "time" + "perun.network/go-perun/wallet" + "perun.network/go-perun/channel" "perun.network/go-perun/client" "perun.network/go-perun/log" diff --git a/client/test/fund.go b/client/test/fund.go index 975ff11c2..2392894f3 100644 --- a/client/test/fund.go +++ b/client/test/fund.go @@ -19,9 +19,10 @@ import ( "errors" "math/big" "math/rand" - "perun.network/go-perun/wallet" "testing" + "perun.network/go-perun/wallet" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "perun.network/go-perun/channel" diff --git a/client/test/multiledger_dispute.go b/client/test/multiledger_dispute.go index d452c55d3..a19350d63 100644 --- a/client/test/multiledger_dispute.go +++ b/client/test/multiledger_dispute.go @@ -17,10 +17,11 @@ package test import ( "context" "math/big" - "perun.network/go-perun/wallet" "testing" "time" + "perun.network/go-perun/wallet" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/client/test/multiledger_happy.go b/client/test/multiledger_happy.go index 0e795905c..490df99c5 100644 --- a/client/test/multiledger_happy.go +++ b/client/test/multiledger_happy.go @@ -16,9 +16,10 @@ package test import ( "context" - "perun.network/go-perun/wallet" "testing" + "perun.network/go-perun/wallet" + "github.com/stretchr/testify/require" "perun.network/go-perun/channel" "perun.network/go-perun/client" diff --git a/client/test/persistence.go b/client/test/persistence.go index aadfb6d5a..80f58fdfb 100644 --- a/client/test/persistence.go +++ b/client/test/persistence.go @@ -17,10 +17,11 @@ package test import ( "context" "math/big" - "perun.network/go-perun/wallet" "testing" "time" + "perun.network/go-perun/wallet" + "perun.network/go-perun/channel" "perun.network/go-perun/client" "perun.network/go-perun/wire" diff --git a/client/test/subchannel_dispute.go b/client/test/subchannel_dispute.go index 2a10f2c5c..e0e1322f9 100644 --- a/client/test/subchannel_dispute.go +++ b/client/test/subchannel_dispute.go @@ -17,10 +17,11 @@ package test import ( "fmt" "math/big" - "perun.network/go-perun/wallet" "testing" "time" + "perun.network/go-perun/wallet" + "perun.network/go-perun/channel" "perun.network/go-perun/client" ) diff --git a/client/test/virtualchannel.go b/client/test/virtualchannel.go index af141bbfb..60eda7329 100644 --- a/client/test/virtualchannel.go +++ b/client/test/virtualchannel.go @@ -18,10 +18,11 @@ import ( "context" "math/big" "math/rand" - "perun.network/go-perun/wallet" "testing" "time" + "perun.network/go-perun/wallet" + "github.com/pkg/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/client/updateinterception.go b/client/updateinterception.go index 8f2c51c7d..2627c0413 100644 --- a/client/updateinterception.go +++ b/client/updateinterception.go @@ -16,9 +16,10 @@ package client import ( "context" - "perun.network/go-perun/wallet" "sync" + "perun.network/go-perun/wallet" + "perun.network/go-perun/channel" ) diff --git a/log/logrus/logrus_internal_test.go b/log/logrus/logrus_internal_test.go index a62c45a8e..03469734f 100644 --- a/log/logrus/logrus_internal_test.go +++ b/log/logrus/logrus_internal_test.go @@ -43,7 +43,7 @@ func testLogrusInfo(t *testing.T) { FromLogrus(logger).Println("Anton Ausdemhaus") assert.Equal(t, len(hook.Entries), 1) - assert.Equal(t, hook.LastEntry().Level, logrus.InfoLevel) + assert.Equal(t, logrus.InfoLevel, hook.LastEntry().Level) assert.Equal(t, hook.LastEntry().Message, "Anton Ausdemhaus") } diff --git a/watcher/local/registry.go b/watcher/local/registry.go index 9335aed74..6faeb572a 100644 --- a/watcher/local/registry.go +++ b/watcher/local/registry.go @@ -15,9 +15,10 @@ package local import ( - "perun.network/go-perun/wallet" "sync" + "perun.network/go-perun/wallet" + "github.com/pkg/errors" "perun.network/go-perun/channel" diff --git a/watcher/local/watcher.go b/watcher/local/watcher.go index a5135516f..344ab5a58 100644 --- a/watcher/local/watcher.go +++ b/watcher/local/watcher.go @@ -17,9 +17,10 @@ package local import ( "context" stderrors "errors" - "perun.network/go-perun/wallet" "time" + "perun.network/go-perun/wallet" + "github.com/pkg/errors" "perun.network/go-perun/channel" diff --git a/watcher/local/watcher_test.go b/watcher/local/watcher_test.go index 897c251d7..dc237f333 100644 --- a/watcher/local/watcher_test.go +++ b/watcher/local/watcher_test.go @@ -18,11 +18,12 @@ import ( "context" "fmt" "math/rand" - "perun.network/go-perun/wallet" "sync" "testing" "time" + "perun.network/go-perun/wallet" + "github.com/stretchr/testify/assert" testifyMock "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/watcher/watcher.go b/watcher/watcher.go index 7a28359b5..1e01a3358 100644 --- a/watcher/watcher.go +++ b/watcher/watcher.go @@ -16,6 +16,7 @@ package watcher import ( "context" + "perun.network/go-perun/wallet" "perun.network/go-perun/channel" diff --git a/wire/account.go b/wire/account.go index fd5202e66..616fa230a 100644 --- a/wire/account.go +++ b/wire/account.go @@ -18,6 +18,7 @@ import ( "encoding/binary" "fmt" "io" + "perun.network/go-perun/wallet" ) diff --git a/wire/cache_internal_test.go b/wire/cache_internal_test.go index 4de3acff7..10cb3c3d5 100644 --- a/wire/cache_internal_test.go +++ b/wire/cache_internal_test.go @@ -61,7 +61,7 @@ func TestCache(t *testing.T) { c.Release(&isPing) assert.False(c.Put(ping2), "Put into cache with canceled predicate") assert.Equal(2, c.Size()) - assert.Len(c.preds, 0, "internal: Put should have removed canceled predicate") + assert.Empty(c.preds, "internal: Put should have removed canceled predicate") msgs := c.Messages(func(e *Envelope) bool { return e.Msg.Type() == Ping && diff --git a/wire/hybridbus.go b/wire/hybridbus.go index 80aa60a86..0b30b0b14 100644 --- a/wire/hybridbus.go +++ b/wire/hybridbus.go @@ -17,6 +17,7 @@ package wire import ( "context" "fmt" + "perun.network/go-perun/wallet" "polycry.pt/poly-go/errors" diff --git a/wire/hybridbus_test.go b/wire/hybridbus_test.go index 18a0b8c7f..1b5265749 100644 --- a/wire/hybridbus_test.go +++ b/wire/hybridbus_test.go @@ -15,9 +15,10 @@ package wire_test import ( - "perun.network/go-perun/wallet" "testing" + "perun.network/go-perun/wallet" + "github.com/stretchr/testify/require" . "perun.network/go-perun/wire" diff --git a/wire/localbus.go b/wire/localbus.go index 2339de497..80294a48f 100644 --- a/wire/localbus.go +++ b/wire/localbus.go @@ -16,9 +16,10 @@ package wire import ( "context" - "perun.network/go-perun/wallet" "sync" + "perun.network/go-perun/wallet" + "github.com/pkg/errors" "perun.network/go-perun/log" diff --git a/wire/localbus_test.go b/wire/localbus_test.go index 83ba3a694..2d5141822 100644 --- a/wire/localbus_test.go +++ b/wire/localbus_test.go @@ -15,9 +15,10 @@ package wire_test import ( - "perun.network/go-perun/wallet" "testing" + "perun.network/go-perun/wallet" + . "perun.network/go-perun/wire" "perun.network/go-perun/wire/test" ) diff --git a/wire/net/bus.go b/wire/net/bus.go index f50c7ba73..adfa33e59 100644 --- a/wire/net/bus.go +++ b/wire/net/bus.go @@ -16,10 +16,11 @@ package net import ( "context" - "perun.network/go-perun/wallet" "sync" "time" + "perun.network/go-perun/wallet" + "github.com/pkg/errors" "perun.network/go-perun/log" diff --git a/wire/net/bus_test.go b/wire/net/bus_test.go index d4458c476..80e5e80f6 100644 --- a/wire/net/bus_test.go +++ b/wire/net/bus_test.go @@ -15,9 +15,10 @@ package net_test import ( - "perun.network/go-perun/wallet" "testing" + "perun.network/go-perun/wallet" + "github.com/stretchr/testify/assert" "perun.network/go-perun/wire" diff --git a/wire/net/dialer.go b/wire/net/dialer.go index b18aa335e..5e0e55d17 100644 --- a/wire/net/dialer.go +++ b/wire/net/dialer.go @@ -16,6 +16,7 @@ package net import ( "context" + "perun.network/go-perun/wallet" "perun.network/go-perun/wire" diff --git a/wire/net/endpoint.go b/wire/net/endpoint.go index 71017448a..898416ce8 100644 --- a/wire/net/endpoint.go +++ b/wire/net/endpoint.go @@ -18,6 +18,7 @@ import ( "context" "fmt" "io" + "perun.network/go-perun/wallet" "github.com/pkg/errors" diff --git a/wire/net/endpoint_internal_test.go b/wire/net/endpoint_internal_test.go index 92d0bf734..063128599 100644 --- a/wire/net/endpoint_internal_test.go +++ b/wire/net/endpoint_internal_test.go @@ -17,12 +17,13 @@ package net import ( "context" "math/rand" - "perun.network/go-perun/channel" - "perun.network/go-perun/wallet" "sync" "testing" "time" + "perun.network/go-perun/channel" + "perun.network/go-perun/wallet" + "github.com/pkg/errors" "github.com/stretchr/testify/assert" diff --git a/wire/net/endpoint_registry.go b/wire/net/endpoint_registry.go index ac5a85ac4..ca09d83ec 100644 --- a/wire/net/endpoint_registry.go +++ b/wire/net/endpoint_registry.go @@ -16,13 +16,14 @@ package net import ( "context" - "perun.network/go-perun/channel/persistence/test" - "perun.network/go-perun/wallet" "sync" "sync/atomic" "time" "unsafe" + "perun.network/go-perun/channel/persistence/test" + "perun.network/go-perun/wallet" + "github.com/pkg/errors" "perun.network/go-perun/log" diff --git a/wire/net/endpoint_registry_external_test.go b/wire/net/endpoint_registry_external_test.go index 2e78cfb25..2ee3c32af 100644 --- a/wire/net/endpoint_registry_external_test.go +++ b/wire/net/endpoint_registry_external_test.go @@ -16,11 +16,12 @@ package net_test import ( "context" - "perun.network/go-perun/channel" - "perun.network/go-perun/wallet" "testing" "time" + "perun.network/go-perun/channel" + "perun.network/go-perun/wallet" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/wire/net/endpoint_registry_internal_test.go b/wire/net/endpoint_registry_internal_test.go index cb4edde1e..b10e6267b 100644 --- a/wire/net/endpoint_registry_internal_test.go +++ b/wire/net/endpoint_registry_internal_test.go @@ -17,11 +17,12 @@ package net import ( "context" "net" - "perun.network/go-perun/wallet" "sync" "testing" "time" + "perun.network/go-perun/wallet" + "github.com/pkg/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/wire/net/exchange_addr.go b/wire/net/exchange_addr.go index 262d5cdd3..066ae4ed4 100644 --- a/wire/net/exchange_addr.go +++ b/wire/net/exchange_addr.go @@ -17,6 +17,7 @@ package net import ( "context" "fmt" + "perun.network/go-perun/channel/persistence/test" "perun.network/go-perun/wallet" diff --git a/wire/net/exchange_addr_internal_test.go b/wire/net/exchange_addr_internal_test.go index 72fa82813..5ff019f45 100644 --- a/wire/net/exchange_addr_internal_test.go +++ b/wire/net/exchange_addr_internal_test.go @@ -16,10 +16,11 @@ package net import ( "context" - "perun.network/go-perun/channel" "sync" "testing" + "perun.network/go-perun/channel" + "github.com/stretchr/testify/assert" "perun.network/go-perun/wire" diff --git a/wire/net/simple/account.go b/wire/net/simple/account.go index 4e207851c..799a59ab6 100644 --- a/wire/net/simple/account.go +++ b/wire/net/simple/account.go @@ -19,8 +19,9 @@ import ( crypto_rand "crypto/rand" "crypto/rsa" "crypto/sha256" - "github.com/pkg/errors" "math/rand" + + "github.com/pkg/errors" "perun.network/go-perun/wire" ) diff --git a/wire/net/simple/address.go b/wire/net/simple/address.go index 2edd81af7..4ed79569f 100644 --- a/wire/net/simple/address.go +++ b/wire/net/simple/address.go @@ -22,6 +22,7 @@ import ( "encoding/binary" "math/big" "math/rand" + "perun.network/go-perun/wallet" "perun.network/go-perun/wire" diff --git a/wire/net/simple/dialer.go b/wire/net/simple/dialer.go index 485342d0b..a1447c21c 100644 --- a/wire/net/simple/dialer.go +++ b/wire/net/simple/dialer.go @@ -18,10 +18,11 @@ import ( "context" "crypto/tls" "net" - "perun.network/go-perun/wallet" "sync" "time" + "perun.network/go-perun/wallet" + "github.com/pkg/errors" "perun.network/go-perun/wire" wirenet "perun.network/go-perun/wire/net" diff --git a/wire/net/simple/dialer_internal_test.go b/wire/net/simple/dialer_internal_test.go index fe17b4d6f..8758db39b 100644 --- a/wire/net/simple/dialer_internal_test.go +++ b/wire/net/simple/dialer_internal_test.go @@ -25,10 +25,11 @@ import ( "fmt" "math/big" "net" - "perun.network/go-perun/wallet" "testing" "time" + "perun.network/go-perun/wallet" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/wire/net/simple/simple_exchange_addr_test.go b/wire/net/simple/simple_exchange_addr_test.go index 78ad37c9f..e1d7d5eef 100644 --- a/wire/net/simple/simple_exchange_addr_test.go +++ b/wire/net/simple/simple_exchange_addr_test.go @@ -22,11 +22,12 @@ import ( "context" "math/rand" "net" - "perun.network/go-perun/channel" "sync" "testing" "time" + "perun.network/go-perun/channel" + "github.com/stretchr/testify/assert" "perun.network/go-perun/wire" diff --git a/wire/net/test/connhub.go b/wire/net/test/connhub.go index 54c53f961..8a7c3b5ce 100644 --- a/wire/net/test/connhub.go +++ b/wire/net/test/connhub.go @@ -15,9 +15,10 @@ package test import ( - "perun.network/go-perun/wallet" gosync "sync" + "perun.network/go-perun/wallet" + "github.com/pkg/errors" "perun.network/go-perun/wire" diff --git a/wire/net/test/connhub_internal_test.go b/wire/net/test/connhub_internal_test.go index 35f47f8be..d77549529 100644 --- a/wire/net/test/connhub_internal_test.go +++ b/wire/net/test/connhub_internal_test.go @@ -16,9 +16,10 @@ package test import ( "context" - "perun.network/go-perun/wallet" "testing" + "perun.network/go-perun/wallet" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/wire/net/test/dialer.go b/wire/net/test/dialer.go index 86f4c5879..5fe5137e6 100644 --- a/wire/net/test/dialer.go +++ b/wire/net/test/dialer.go @@ -17,9 +17,10 @@ package test import ( "context" "net" - "perun.network/go-perun/wallet" "sync/atomic" + "perun.network/go-perun/wallet" + "github.com/pkg/errors" "perun.network/go-perun/wire" diff --git a/wire/net/test/dialerlist_internal_test.go b/wire/net/test/dialerlist_internal_test.go index 41093a8c1..04ca42a8b 100644 --- a/wire/net/test/dialerlist_internal_test.go +++ b/wire/net/test/dialerlist_internal_test.go @@ -44,7 +44,7 @@ func TestDialerList_erase(t *testing.T) { d := &Dialer{} l.insert(d) assert.NoError(l.erase(d)) - assert.Len(l.entries, 0) + assert.Empty(l.entries) assert.Error(l.erase(d)) } diff --git a/wire/net/test/listenermap.go b/wire/net/test/listenermap.go index a685d37b1..12dde418b 100644 --- a/wire/net/test/listenermap.go +++ b/wire/net/test/listenermap.go @@ -15,9 +15,10 @@ package test import ( + "sync" + "perun.network/go-perun/channel/persistence/test" "perun.network/go-perun/wallet" - "sync" "github.com/pkg/errors" "perun.network/go-perun/wire" diff --git a/wire/protobuf/proposalmsgs.go b/wire/protobuf/proposalmsgs.go index e226bd34f..09d6b2971 100644 --- a/wire/protobuf/proposalmsgs.go +++ b/wire/protobuf/proposalmsgs.go @@ -18,9 +18,10 @@ import ( "bytes" "encoding/binary" "fmt" - "github.com/pkg/errors" "math" "math/big" + + "github.com/pkg/errors" "perun.network/go-perun/channel" "perun.network/go-perun/client" "perun.network/go-perun/wallet" @@ -197,7 +198,7 @@ func ToIDs(protoID *ID) (map[wallet.BackendID]channel.ID, error) { return nil, fmt.Errorf("failed to read key: %w", err) } if len(protoID.IdMapping[i].Id) != 32 { - return nil, fmt.Errorf("id has incorrect length") + return nil, errors.New("id has incorrect length") } id := channel.ID{} copy(id[:], protoID.IdMapping[i].Id) diff --git a/wire/protobuf/serializer.go b/wire/protobuf/serializer.go index da8571297..1b4fe8140 100644 --- a/wire/protobuf/serializer.go +++ b/wire/protobuf/serializer.go @@ -18,6 +18,7 @@ import ( "encoding/binary" "fmt" "io" + "perun.network/go-perun/wallet" "github.com/pkg/errors" diff --git a/wire/protobuf/wire.pb.go b/wire/protobuf/wire.pb.go index 96e208bee..31ea66cb3 100644 --- a/wire/protobuf/wire.pb.go +++ b/wire/protobuf/wire.pb.go @@ -23,10 +23,11 @@ package protobuf import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/wire/relay_internal_test.go b/wire/relay_internal_test.go index 3e6fcd6ae..db5fb2102 100644 --- a/wire/relay_internal_test.go +++ b/wire/relay_internal_test.go @@ -120,7 +120,7 @@ func TestProducer_caching(t *testing.T) { prod.Put(ping0) assert.Equal(1, prod.cache.Size()) - assert.Len(unhandlesMsg, 0) + assert.Empty(unhandlesMsg) prod.Put(pong1) assert.Equal(1, prod.cache.Size()) diff --git a/wire/test/bustest.go b/wire/test/bustest.go index 4409d2550..6f07b9d14 100644 --- a/wire/test/bustest.go +++ b/wire/test/bustest.go @@ -45,7 +45,7 @@ func GenericBusTest(t *testing.T, ) { t.Helper() require.Greater(t, numClients, 1) - require.Greater(t, numMsgs, 0) + require.Positive(t, numMsgs) rng := test.Prng(t) type Client struct { diff --git a/wire/test/randomizer.go b/wire/test/randomizer.go index 04478b50c..c88f8f1a9 100644 --- a/wire/test/randomizer.go +++ b/wire/test/randomizer.go @@ -16,6 +16,7 @@ package test import ( "math/rand" + "perun.network/go-perun/wallet" "perun.network/go-perun/wire"