1 // Copyright (c) 2013-2016 The btcsuite developers
2 // Use of this source code is governed by an ISC
3 // license that can be found in the LICENSE file.
12 func TestMemPool(t *testing.T) {
13 pver := ProtocolVersion
16 // Ensure the command is expected value.
18 msg := NewMsgMemPool()
19 if cmd := msg.Command(); cmd != wantCmd {
20 t.Errorf("NewMsgMemPool: wrong command - got %v want %v",
24 // Ensure max payload is expected value.
25 wantPayload := uint32(0)
26 maxPayload := msg.MaxPayloadLength(pver)
27 if maxPayload != wantPayload {
28 t.Errorf("MaxPayloadLength: wrong max payload length for "+
29 "protocol version %d - got %v, want %v", pver,
30 maxPayload, wantPayload)
33 // Test encode with latest protocol version.
35 err := msg.BtcEncode(&buf, pver, enc)
37 t.Errorf("encode of MsgMemPool failed %v err <%v>", msg, err)
40 // Older protocol versions should fail encode since message didn't
42 oldPver := BIP0035Version - 1
43 err = msg.BtcEncode(&buf, oldPver, enc)
45 s := "encode of MsgMemPool passed for old protocol version %v err <%v>"
49 // Test decode with latest protocol version.
50 readmsg := NewMsgMemPool()
51 err = readmsg.BtcDecode(&buf, pver, enc)
53 t.Errorf("decode of MsgMemPool failed [%v] err <%v>", buf, err)
56 // Older protocol versions should fail decode since message didn't
58 err = readmsg.BtcDecode(&buf, oldPver, enc)
60 s := "decode of MsgMemPool passed for old protocol version %v err <%v>"