github.com/MetalBlockchain/metalgo@v1.11.9/message/outbound_msg_builder_test.go (about) 1 // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 package message 5 6 import ( 7 "testing" 8 "time" 9 10 "github.com/prometheus/client_golang/prometheus" 11 "github.com/stretchr/testify/require" 12 13 "github.com/MetalBlockchain/metalgo/ids" 14 "github.com/MetalBlockchain/metalgo/utils/compression" 15 "github.com/MetalBlockchain/metalgo/utils/logging" 16 ) 17 18 func Test_newOutboundBuilder(t *testing.T) { 19 t.Parallel() 20 21 mb, err := newMsgBuilder( 22 logging.NoLog{}, 23 prometheus.NewRegistry(), 24 10*time.Second, 25 ) 26 require.NoError(t, err) 27 28 for _, compressionType := range []compression.Type{ 29 compression.TypeNone, 30 compression.TypeZstd, 31 } { 32 t.Run(compressionType.String(), func(t *testing.T) { 33 builder := newOutboundBuilder(compressionType, mb) 34 35 outMsg, err := builder.GetAcceptedStateSummary( 36 ids.GenerateTestID(), 37 12345, 38 time.Hour, 39 []uint64{1000, 2000}, 40 ) 41 require.NoError(t, err) 42 t.Logf("outbound message with compression type %s built message with size %d", compressionType, len(outMsg.Bytes())) 43 }) 44 } 45 }