// TestGetBlockTxnsWire tests the GetBlockTxnsWire wire encode and decode for
// various protocol versions.
TestGetBlockTxnsWire tests the GetBlockTxnsWire wire encode and decode for
various protocol versions.
// TestGetBlockTxnsWire tests the GetBlockTxnsWire wire encode and decode for // various protocol versions .
func TestGetBlockTxnsWire(t *testing.T) {
	msgGetBlockTxns := NewMsgGetBlockTxns(chainhash.Hash{}, []uint32{2})
	msgGetBlockTxnsEncoded := []byte{
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
		0x01, 
		0x02, 
	}
	tests := []struct {
		in   *MsgGetBlockTxns 
		out  *MsgGetBlockTxns 
		buf  []byte           
		pver uint32           
		enc  MessageEncoding  
	}{
		{
			msgGetBlockTxns,
			msgGetBlockTxns,
			msgGetBlockTxnsEncoded,
			ProtocolVersion,
			BaseEncoding,
		},
		{
			msgGetBlockTxns,
			msgGetBlockTxns,
			msgGetBlockTxnsEncoded,
			BIP0152Version + 1,
			BaseEncoding,
		},
		{
			msgGetBlockTxns,
			msgGetBlockTxns,
			msgGetBlockTxnsEncoded,
			BIP0152Version,
			BaseEncoding,
		},
	}
	t.Logf("Running %d tests", len(tests))
	for i, test := range tests {
		var buf bytes.Buffer
		err := test.in.BchEncode(&buf, test.pver, test.enc)
		if err != nil {
			t.Errorf("BchEncode #%d error %v", i, err)
			continue
		}
		if !bytes.Equal(buf.Bytes(), test.buf) {
			t.Errorf("BchEncode #%d\n got: %s want: %s", i,
				spew.Sdump(buf.Bytes()), spew.Sdump(test.buf))
			continue
		}
		var msg MsgGetBlockTxns
		rbuf := bytes.NewReader(test.buf)
		err = msg.BchDecode(rbuf, test.pver, test.enc)
		if err != nil {
			t.Errorf("BchDecode #%d error %v", i, err)
			continue
		}
		if !reflect.DeepEqual(&msg, test.out) {
			t.Errorf("BchDecode #%d\n got: %s want: %s", i,
				spew.Sdump(msg), spew.Sdump(test.out))
			continue
		}
	}
}
func TestGetBlockTxnsWire ( t * testing . T ) { msgGetBlockTxns := NewMsgGetBlockTxns ( chainhash . Hash { } , [ ] uint32 { 2 } ) msgGetBlockTxnsEncoded := [ ] byte { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x01 , 0x02 , } tests := [ ] struct { in * MsgGetBlockTxns out * MsgGetBlockTxns buf [ ] byte pver uint32 enc MessageEncoding } { { msgGetBlockTxns , msgGetBlockTxns , msgGetBlockTxnsEncoded , ProtocolVersion , BaseEncoding , } , { msgGetBlockTxns , msgGetBlockTxns , msgGetBlockTxnsEncoded , BIP0152Version + 1 , BaseEncoding , } , { msgGetBlockTxns , msgGetBlockTxns , msgGetBlockTxnsEncoded , BIP0152Version , BaseEncoding , } , } t . Logf ( " " , len ( tests ) ) for i , test := range tests { var buf bytes . Buffer err := test . in . BchEncode ( & buf , test . pver , test . enc ) if err != nil { t . Errorf ( " " , i , err ) continue } if ! bytes . Equal ( buf . Bytes ( ) , test . buf ) { t . Errorf ( " \n " , i , spew . Sdump ( buf . Bytes ( ) ) , spew . Sdump ( test . buf ) ) continue } var msg MsgGetBlockTxns rbuf := bytes . NewReader ( test . buf ) err = msg . BchDecode ( rbuf , test . pver , test . enc ) if err != nil { t . Errorf ( " " , i , err ) continue } if ! reflect . DeepEqual ( & msg , test . out ) { t . Errorf ( " \n " , i , spew . Sdump ( msg ) , spew . Sdump ( test . out ) ) continue } } }
TestGetBlockTxnsWire tests the GetBlockTxnsWire wire encode and decode for
various protocol versions.
TestGetBlockTxnsWire tests the GetBlockTxnsWire wire encode and decode for various protocol versions .
// Block hash // Varint for number of indexes // Index of 2 // Message to encode // Expected decoded message // Wire encoding // Protocol version for wire encoding // Message encoding format // Latest protocol version. // Protocol version BIP0152Version+1 // Protocol version BIP0152Version // Encode the message to wire format. // Decode the message from wire format.