Skip to content

Commit

Permalink
fix: skip when encounter EOF for events query and fix static mockapp …
Browse files Browse the repository at this point in the history
…address for app channel test

Signed-off-by: Minh Huy Tran <[email protected]>
  • Loading branch information
NhoxxKienn committed Apr 22, 2024
1 parent 0141940 commit 4d61c08
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion channel/pallet/adjudicator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestAdjudicator_Walkthrough(t *testing.T) {
dSetup := chtest.NewDepositSetup(params, state)
adjAlice := pallet.NewAdjudicator(s.Alice.Acc, s.Pallet, s.API, test.PastBlocks)
adjBob := pallet.NewAdjudicator(s.Bob.Acc, s.Pallet, s.API, test.PastBlocks)
ctx, cancel := context.WithTimeout(context.Background(), 100*s.BlockTime)
ctx, cancel := context.WithTimeout(context.Background(), 1000*s.BlockTime)
defer cancel()

// Fund
Expand Down
5 changes: 5 additions & 0 deletions channel/pallet/event_sub.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package pallet

import (
"io"

"github.com/centrifuge/go-substrate-rpc-client/v4/types"
"perun.network/go-perun/log"
pkgsync "polycry.pt/poly-go/sync"
Expand Down Expand Up @@ -60,6 +62,9 @@ func NewEventSub(source *substrate.EventSource, meta *types.Metadata, p EventPre
select {
case set := <-source.Events():
if err = sub.decodeEventRecords(set, meta); err != nil {
if err == io.EOF {
continue
}
sub.Log().Errorf("decoding event records: %v", err)
break loop
}
Expand Down
16 changes: 14 additions & 2 deletions client/appchannel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ import (
"perun.network/go-perun/channel"
"perun.network/go-perun/client"
clienttest "perun.network/go-perun/client/test"
test "perun.network/go-perun/wallet/test"
"perun.network/go-perun/wire"
pkgtest "polycry.pt/poly-go/test"

"github.com/ChainSafe/go-schnorrkel"
pchannel "github.com/perun-network/perun-polkadot-backend/channel"
ptest "github.com/perun-network/perun-polkadot-backend/channel/pallet/test"
dotwallet "github.com/perun-network/perun-polkadot-backend/wallet/sr25519"
"github.com/stretchr/testify/require"
)

func TestAppChannel(t *testing.T) {
Expand All @@ -42,7 +44,17 @@ func TestAppChannel(t *testing.T) {
clienttest.NewPaula(t, setups[B]),
}

appAddress := test.NewRandomAddress(rng)
byteArray := [32]byte{
176, 115, 108, 113, 171, 155, 245, 248,
27, 234, 80, 36, 30, 145, 56, 217,
213, 25, 176, 99, 145, 198, 217, 248,
220, 159, 39, 241, 120, 209, 175, 8,
}
pk, err := schnorrkel.NewPublicKey(byteArray)
require.NoError(t, err)

appAddress := dotwallet.NewAddressFromPK(pk)
require.NoError(t, err)
app := channel.NewMockApp(appAddress)
channel.RegisterApp(app)

Expand Down

0 comments on commit 4d61c08

Please sign in to comment.