Skip to content

Commit

Permalink
fix(CI): change code to fix CI
Browse files Browse the repository at this point in the history
Signed-off-by: Minh Huy Tran <[email protected]>
  • Loading branch information
NhoxxKienn committed Feb 16, 2024
1 parent 71e1868 commit b3a1fb1
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 23 deletions.
4 changes: 2 additions & 2 deletions channel/test/app_randomizer_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ func TestAppRandomizerSet(t *testing.T) {
assert.NotNil(t, appRandomizer, "appRandomizer should be default initialized")
assert.False(t, isAppRandomizerSet, "isAppRandomizerSet should be defaulted to false")

old := appRandomizer
// old := appRandomizer
assert.NotPanics(t, func() { SetAppRandomizer(&MockAppRandomizer{}) }, "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")

old = appRandomizer
old := appRandomizer
assert.Panics(t, func() { SetAppRandomizer(&MockAppRandomizer{}) }, "second SetAppRandomizer() should panic")
assert.True(t, isAppRandomizerSet, "isAppRandomizerSet should be true")
assert.NotNil(t, appRandomizer, "appRandomizer should not be nil")
Expand Down
2 changes: 1 addition & 1 deletion client/adjudicate.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func (c *Channel) Settle(ctx context.Context) (err error) {
// Withdraw.
err = c.withdraw(ctx)
if err != nil {
return
return err
}

// Set phase `Withdrawn`.
Expand Down
2 changes: 1 addition & 1 deletion client/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ func (c *Client) validTwoPartyProposal(
multiLedger := multi.IsMultiLedgerAssets(proposal.Base().InitBals.Assets)
appChannel := !channel.IsNoApp(proposal.Base().App)
if multiLedger && appChannel {
return fmt.Errorf("multi-ledger app channel not supported")
return errors.New("multi-ledger app channel not supported")
}

peers := c.proposalPeers(proposal)
Expand Down
3 changes: 2 additions & 1 deletion client/virtual_channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ func (c *Client) matchFundingProposal(ctx context.Context, a, b interface{}) boo
}

go func() {
err := virtual.watchVirtual() //nolint:contextcheck // The context will be derived from the channel context.
// The context will be derived from the channel context.
err := virtual.watchVirtual() //nolint:contextcheck
c.log.Debugf("channel %v: watcher stopped: %v", virtual.ID(), err)
}()
return true
Expand Down
4 changes: 2 additions & 2 deletions wallet/test/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ func TestAddress(t *testing.T, s *Setup) { //nolint:revive // `test.Test...` stu
// Test Address.String.
nullString := null.String()
addrString := addr.String()
assert.Greater(t, len(nullString), 0)
assert.Greater(t, len(addrString), 0)
assert.NotEmpty(t, len(nullString), 0)
assert.NotEmpty(t, len(addrString), 0)
assert.NotEqual(t, addrString, nullString)

// Test Address.Equals.
Expand Down
2 changes: 1 addition & 1 deletion wallet/test/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestAccountWithWalletAndBackend(t *testing.T, s *Setup) { //nolint:revive /
t.Error("Verification of invalid signature should produce error or return false")
}
// Expand the signature and check for error
// nolint:gocritic
//nolint:gocritic
tampered = append(sig, 0)
valid, err = s.Backend.VerifySignature(s.DataToSign, tampered, acc.Address())
if valid && err != nil {
Expand Down
6 changes: 3 additions & 3 deletions wallet/test/walletbench.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func GenericAccountBenchmark(b *testing.B, s *Setup) {
func benchAccountSign(b *testing.B, s *Setup) {
b.Helper()
perunAcc, err := s.Wallet.Unlock(s.AddressInWallet)
require.Nil(b, err)
require.NoError(b, err)

for n := 0; n < b.N; n++ {
_, err := perunAcc.SignData(s.DataToSign)
Expand All @@ -56,9 +56,9 @@ func benchBackendVerifySig(b *testing.B, s *Setup) {
// We dont want to measure the SignDataWithPW here, just need it for the verification
b.StopTimer()
perunAcc, err := s.Wallet.Unlock(s.AddressInWallet)
require.Nil(b, err)
require.NoError(b, err)
signature, err := perunAcc.SignData(s.DataToSign)
require.Nil(b, err)
require.NoError(b, err)
b.StartTimer()

for n := 0; n < b.N; n++ {
Expand Down
2 changes: 1 addition & 1 deletion wire/cache_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestCache(t *testing.T) {
assert.Equal(2, c.Size())

empty := c.Messages(func(*Envelope) bool { return false })
assert.Len(empty, 0)
assert.Empty(empty, 0)

c.Release(&isPing)
assert.False(c.Put(ping2), "Put into cache with canceled predicate")
Expand Down
2 changes: 1 addition & 1 deletion wire/net/simple/address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ func TestAddress(t *testing.T) {
test.TestAddressImplementation(t, func() wire.Address {
return simple.NewAddress("")
}, func(rng *rand.Rand) wire.Address {

Check failure on line 29 in wire/net/simple/address_test.go

View workflow job for this annotation

GitHub Actions / Vetting

unlambda: replace `func(rng *rand.Rand) wire.Address {
return simple.NewRandomAddress(rng)
return test.NewRandomAddress(rng)
})
}
5 changes: 3 additions & 2 deletions wire/net/simple/dialer_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (

"perun.network/go-perun/wire"
perunio "perun.network/go-perun/wire/perunio/serializer"
wiretest "perun.network/go-perun/wire/test"
ctxtest "polycry.pt/poly-go/context/test"
"polycry.pt/poly-go/test"
)
Expand Down Expand Up @@ -76,7 +77,7 @@ func TestDialer_Dial(t *testing.T) {
timeout := 100 * time.Millisecond
rng := test.Prng(t)
lhost := "127.0.0.1:7357"
laddr := NewRandomAccount(rng).Address()
laddr := wiretest.NewRandomAccount(rng).Address()

commonName := "127.0.0.1"
sans := []string{"127.0.0.1", "localhost"}
Expand All @@ -90,7 +91,7 @@ func TestDialer_Dial(t *testing.T) {
ser := perunio.Serializer()
d := NewTCPDialer(timeout, dConfig)
d.Register(laddr, lhost)
daddr := NewRandomAccount(rng).Address()
daddr := wiretest.NewRandomAccount(rng).Address()
defer d.Close()

t.Run("happy", func(t *testing.T) {
Expand Down
11 changes: 6 additions & 5 deletions wire/net/simple/simple_exchange_addr_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"perun.network/go-perun/wire"
wirenet "perun.network/go-perun/wire/net"
perunio "perun.network/go-perun/wire/perunio/serializer"
wiretest "perun.network/go-perun/wire/test"
ctxtest "polycry.pt/poly-go/context/test"
"polycry.pt/poly-go/test"
)
Expand All @@ -37,7 +38,7 @@ func TestExchangeAddrs_ConnFail(t *testing.T) {
rng := test.Prng(t)
a, _ := newPipeConnPair()
a.Close()
addr, err := wirenet.ExchangeAddrsPassive(context.Background(), NewRandomAccount(rng), a)
addr, err := wirenet.ExchangeAddrsPassive(context.Background(), wiretest.NewRandomAccount(rng), a)
assert.Nil(t, addr)
assert.Error(t, err)
}
Expand All @@ -46,7 +47,7 @@ func TestExchangeAddrs_Success(t *testing.T) {
rng := test.Prng(t)
conn0, conn1 := newPipeConnPair()
defer conn0.Close()
account0, account1 := NewRandomAccount(rng), NewRandomAccount(rng)
account0, account1 := wiretest.NewRandomAccount(rng), wiretest.NewRandomAccount(rng)
var wg sync.WaitGroup
wg.Add(1)

Expand All @@ -71,16 +72,16 @@ func TestExchangeAddrs_Timeout(t *testing.T) {

ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
ctxtest.AssertTerminates(t, 2*timeout, func() {
addr, err := wirenet.ExchangeAddrsPassive(ctx, NewRandomAccount(rng), a)
ctxtest.AssertTerminates(t, 20*timeout, func() {
addr, err := wirenet.ExchangeAddrsPassive(ctx, wiretest.NewRandomAccount(rng), a)
assert.Nil(t, addr)
assert.Error(t, err)
})
}

func TestExchangeAddrs_BogusMsg(t *testing.T) {
rng := test.Prng(t)
acc := NewRandomAccount(rng)
acc := wiretest.NewRandomAccount(rng)
conn := newMockConn()
conn.recvQueue <- newRandomEnvelope(rng, wire.NewPingMsg())
addr, err := wirenet.ExchangeAddrsPassive(context.Background(), acc, conn)
Expand Down
2 changes: 1 addition & 1 deletion wire/perunio/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func encodeString(w io.Writer, s string) error {
return errors.Wrap(err, "failed to write string")
}

// decodeString reads the length as uint16 and the the string itself from the io.Reader.
// decodeString reads the length as uint16 and the string itself from the io.Reader.
func decodeString(r io.Reader, s *string) error {
var l uint16
if err := binary.Read(r, byteOrder, &l); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion wire/perunio/string_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestEncodeDecodeString(t *testing.T) {
})

t.Run("too long string", func(t *testing.T) {
tooLong := string(append(uint16buf, 42)) // nolint: makezero
tooLong := string(append(uint16buf, 42)) //nolint: makezero
var buf bytes.Buffer
assert.Error(encodeString(&buf, tooLong))
assert.Zero(buf.Len(), "nothing should have been written to the stream")
Expand Down
2 changes: 1 addition & 1 deletion wire/perunio/wire_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func TestEncodeDecode(t *testing.T) {
}

go func() {
a.Nil(Encode(w, values...), "failed to encode values")
a.NoError(Encode(w, values...), "failed to encode values")
}()

d := make([]interface{}, len(values))
Expand Down

0 comments on commit b3a1fb1

Please sign in to comment.