github.com/koko1123/flow-go-1@v0.29.6/model/messages/convert_test.go (about) 1 package messages_test 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 8 "github.com/koko1123/flow-go-1/model/cluster" 9 "github.com/koko1123/flow-go-1/model/messages" 10 "github.com/koko1123/flow-go-1/utils/unittest" 11 ) 12 13 func TestBlockProposal(t *testing.T) { 14 block := unittest.FullBlockFixture() 15 proposal := messages.NewBlockProposal(&block) 16 converted := proposal.Block.ToInternal() 17 assert.Equal(t, &block, converted) 18 } 19 20 func TestClusterBlockProposal(t *testing.T) { 21 block := unittest.ClusterBlockFixture() 22 proposal := messages.NewClusterBlockProposal(&block) 23 converted := proposal.Block.ToInternal() 24 assert.Equal(t, &block, converted) 25 } 26 27 func TestBlockResponse(t *testing.T) { 28 expected := unittest.BlockFixtures(2) 29 res := messages.BlockResponse{ 30 Blocks: []messages.UntrustedBlock{ 31 messages.UntrustedBlockFromInternal(expected[0]), 32 messages.UntrustedBlockFromInternal(expected[1]), 33 }, 34 } 35 converted := res.BlocksInternal() 36 assert.Equal(t, expected, converted) 37 } 38 39 func TestClusterBlockResponse(t *testing.T) { 40 b1 := unittest.ClusterBlockFixture() 41 b2 := unittest.ClusterBlockFixture() 42 expected := []*cluster.Block{&b1, &b2} 43 res := messages.ClusterBlockResponse{ 44 Blocks: []messages.UntrustedClusterBlock{ 45 messages.UntrustedClusterBlockFromInternal(expected[0]), 46 messages.UntrustedClusterBlockFromInternal(expected[1]), 47 }, 48 } 49 converted := res.BlocksInternal() 50 assert.Equal(t, expected, converted) 51 }