github.com/annchain/OG@v0.0.9/og/handler_test.go (about)

     1  package og
     2  
     3  import (
     4  	"fmt"
     5  	"github.com/annchain/OG/og/types"
     6  	"github.com/annchain/OG/og/types/archive"
     7  	"testing"
     8  )
     9  
    10  func TestIncomingMessageHandler_HandleBodiesRequest(t *testing.T) {
    11  	var msgRes archive.MessageBodiesResponse
    12  	var bytes int
    13  	for i := 0; i < 2; i++ {
    14  		seq := types.RandomSequencer()
    15  
    16  		if bytes >= softResponseLimit {
    17  			message_archive.msgLog.Debug("reached softResponseLimit")
    18  			break
    19  		}
    20  		if len(msgRes.Bodies) >= 400000 {
    21  			message_archive.msgLog.Debug("reached MaxBlockFetch 128")
    22  			break
    23  		}
    24  		var body types.MessageBodyData
    25  		body.RawSequencer = seq.RawSequencer()
    26  		var txs types.Txis
    27  		for j := 0; j < 3; j++ {
    28  			txs = append(txs, archive.RandomTx())
    29  		}
    30  		rtxs := types.NewTxisMarshaler(txs)
    31  		if rtxs != nil && len(rtxs) != 0 {
    32  			body.RawTxs = &rtxs
    33  		}
    34  		bodyData, _ := body.MarshalMsg(nil)
    35  		bytes += len(bodyData)
    36  		msgRes.Bodies = append(msgRes.Bodies, archive.RawData(bodyData))
    37  		fmt.Println(body)
    38  	}
    39  	fmt.Println(&msgRes)
    40  }