// TestGetBlockTxns tests the MsgGetBlockTxns API against the latest protocol
// version.
TestGetBlockTxns tests the MsgGetBlockTxns API against the latest protocol
version.
// TestGetBlockTxns tests the MsgGetBlockTxns API against the latest protocol // version .
func TestGetBlockTxns(t *testing.T) {
	pver := ProtocolVersion
	enc := BaseEncoding
	wantCmd := "getblocktxn"
	msg := NewMsgGetBlockTxns(chainhash.Hash{}, nil)
	if cmd := msg.Command(); cmd != wantCmd {
		t.Errorf("NewMsgGetBlockTxns: wrong command - got %v want %v",
			cmd, wantCmd)
	}
	wantPayload := maxMessagePayload()
	maxPayload := msg.MaxPayloadLength(pver)
	if maxPayload != wantPayload {
		t.Errorf("MaxPayloadLength: wrong max payload length for "+
			"protocol version %d - got %v, want %v", pver,
			maxPayload, wantPayload)
	}
	var buf bytes.Buffer
	err := msg.BchEncode(&buf, pver, enc)
	if err != nil {
		t.Errorf("encode of MsgGetBlockTxns failed %v err <%v>", msg,
			err)
	}
	oldPver := BIP0152Version - 1
	err = msg.BchEncode(&buf, oldPver, enc)
	if err == nil {
		s := "encode of MsgGetBlockTxns passed for old protocol " +
			"version %v err <%v>"
		t.Errorf(s, msg, err)
	}
	readmsg := MsgGetBlockTxns{}
	err = readmsg.BchDecode(&buf, pver, enc)
	if err != nil {
		t.Errorf("decode of MsgGetBlockTxns failed [%v] err <%v>", buf,
			err)
	}
	err = readmsg.BchDecode(&buf, oldPver, enc)
	if err == nil {
		s := "decode of MsgGetBlockTxns passed for old protocol " +
			"version %v err <%v>"
		t.Errorf(s, msg, err)
	}
}
func TestGetBlockTxns ( t * testing . T ) { pver := ProtocolVersion enc := BaseEncoding wantCmd := " " msg := NewMsgGetBlockTxns ( chainhash . Hash { } , nil ) if cmd := msg . Command ( ) ; cmd != wantCmd { t . Errorf ( " " , cmd , wantCmd ) } wantPayload := maxMessagePayload ( ) maxPayload := msg . MaxPayloadLength ( pver ) if maxPayload != wantPayload { t . Errorf ( " " + " " , pver , maxPayload , wantPayload ) } var buf bytes . Buffer err := msg . BchEncode ( & buf , pver , enc ) if err != nil { t . Errorf ( " " , msg , err ) } oldPver := BIP0152Version - 1 err = msg . BchEncode ( & buf , oldPver , enc ) if err == nil { s := " " + " " t . Errorf ( s , msg , err ) } readmsg := MsgGetBlockTxns { } err = readmsg . BchDecode ( & buf , pver , enc ) if err != nil { t . Errorf ( " " , buf , err ) } err = readmsg . BchDecode ( & buf , oldPver , enc ) if err == nil { s := " " + " " t . Errorf ( s , msg , err ) } }
TestGetBlockTxns tests the MsgGetBlockTxns API against the latest protocol
version.
TestGetBlockTxns tests the MsgGetBlockTxns API against the latest protocol version .
// Ensure the command is expected value. // Ensure max payload is expected value. // Test encode with latest protocol version. // Older protocol versions should fail encode since message didn't // exist yet. // Test decode with latest protocol version. // Older protocol versions should fail decode since message didn't // exist yet.