From 99bf75a98e6c2bb79d6fa42c0e71ec83328347ea Mon Sep 17 00:00:00 2001 From: Diego Date: Wed, 18 Sep 2024 14:31:56 -0300 Subject: [PATCH] Add message decoding test --- dot/network/warp_sync_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 dot/network/warp_sync_test.go diff --git a/dot/network/warp_sync_test.go b/dot/network/warp_sync_test.go new file mode 100644 index 0000000000..b599563018 --- /dev/null +++ b/dot/network/warp_sync_test.go @@ -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) +}