Skip to content

Commit

Permalink
Add message decoding test
Browse files Browse the repository at this point in the history
  • Loading branch information
dimartiro committed Sep 18, 2024
1 parent f80ff45 commit a7e03f7
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions dot/network/warp_sync_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package network

import (
"testing"

"github.com/ChainSafe/gossamer/dot/network/messages"
"github.com/ChainSafe/gossamer/lib/common"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/stretchr/testify/require"
)

func TestDecodeWarpSyncMessage(t *testing.T) {
t.Parallel()
testWarpReqMessage := &messages.WarpProofRequest{
Begin: common.EmptyHash,
}

testPeer := peer.ID("me")
reqEnc, err := testWarpReqMessage.Encode()
require.NoError(t, err)

msg, err := decodeWarpSyncMessage(reqEnc, testPeer, true)
require.NoError(t, err)

req, ok := msg.(*messages.WarpProofRequest)
require.True(t, ok)
require.Equal(t, testWarpReqMessage, req)
}

0 comments on commit a7e03f7

Please sign in to comment.