Add tests for new size hint functions.

This brings the test coverage back up to 100%.
This commit is contained in:
Dave Collins 2014-01-08 17:42:57 -06:00
parent 497aac6d4a
commit 2458841855
3 changed files with 46 additions and 26 deletions

View File

@ -57,6 +57,15 @@ func TestGetData(t *testing.T) {
"vectors not received")
}
// Ensure creating the message with a size hint larger than the max
// works as expected.
msg = btcwire.NewMsgGetDataSizeHint(btcwire.MaxInvPerMsg + 1)
wantCap := btcwire.MaxInvPerMsg
if cap(msg.InvList) != wantCap {
t.Errorf("NewMsgGetDataSizeHint: wrong cap for size hint - "+
"got %v, want %v", cap(msg.InvList), wantCap)
}
return
}

View File

@ -57,6 +57,15 @@ func TestInv(t *testing.T) {
"vectors not received")
}
// Ensure creating the message with a size hint larger than the max
// works as expected.
msg = btcwire.NewMsgInvSizeHint(btcwire.MaxInvPerMsg + 1)
wantCap := btcwire.MaxInvPerMsg
if cap(msg.InvList) != wantCap {
t.Errorf("NewMsgInvSizeHint: wrong cap for size hint - "+
"got %v, want %v", cap(msg.InvList), wantCap)
}
return
}

View File

@ -16,8 +16,8 @@ github.com/conformal/btcwire/msggetblocks.go MsgGetBlocks.BtcDecode 100.00%
github.com/conformal/btcwire/message.go makeEmptyMessage 100.00% (20/20)
github.com/conformal/btcwire/msggetheaders.go MsgGetHeaders.BtcDecode 100.00% (20/20)
github.com/conformal/btcwire/msgblock.go MsgBlock.DeserializeTxLoc 100.00% (19/19)
github.com/conformal/btcwire/msggetblocks.go MsgGetBlocks.BtcEncode 100.00% (18/18)
github.com/conformal/btcwire/msggetheaders.go MsgGetHeaders.BtcEncode 100.00% (18/18)
github.com/conformal/btcwire/msggetblocks.go MsgGetBlocks.BtcEncode 100.00% (18/18)
github.com/conformal/btcwire/msgheaders.go MsgHeaders.BtcDecode 100.00% (17/17)
github.com/conformal/btcwire/msgtx.go readTxOut 100.00% (17/17)
github.com/conformal/btcwire/msgtx.go writeTxIn 100.00% (16/16)
@ -31,9 +31,9 @@ github.com/conformal/btcwire/msgaddr.go MsgAddr.BtcDecode 100.00% (14/14)
github.com/conformal/btcwire/msgnotfound.go MsgNotFound.BtcDecode 100.00% (14/14)
github.com/conformal/btcwire/msggetdata.go MsgGetData.BtcDecode 100.00% (14/14)
github.com/conformal/btcwire/msgtx.go writeTxOut 100.00% (13/13)
github.com/conformal/btcwire/msginv.go MsgInv.BtcEncode 100.00% (12/12)
github.com/conformal/btcwire/protocol.go ServiceFlag.String 100.00% (12/12)
github.com/conformal/btcwire/msggetdata.go MsgGetData.BtcEncode 100.00% (12/12)
github.com/conformal/btcwire/protocol.go ServiceFlag.String 100.00% (12/12)
github.com/conformal/btcwire/msginv.go MsgInv.BtcEncode 100.00% (12/12)
github.com/conformal/btcwire/msgnotfound.go MsgNotFound.BtcEncode 100.00% (12/12)
github.com/conformal/btcwire/common.go readVarString 100.00% (11/11)
github.com/conformal/btcwire/message.go discardInput 100.00% (10/10)
@ -41,8 +41,8 @@ github.com/conformal/btcwire/blockheader.go readBlockHeader 100.00% (10/10)
github.com/conformal/btcwire/msgtx.go readOutPoint 100.00% (9/9)
github.com/conformal/btcwire/msgblock.go MsgBlock.BtcEncode 100.00% (9/9)
github.com/conformal/btcwire/msgtx.go writeOutPoint 100.00% (9/9)
github.com/conformal/btcwire/msgalert.go MsgAlert.BtcDecode 100.00% (8/8)
github.com/conformal/btcwire/msgalert.go MsgAlert.BtcEncode 100.00% (8/8)
github.com/conformal/btcwire/msgalert.go MsgAlert.BtcDecode 100.00% (8/8)
github.com/conformal/btcwire/blockheader.go writeBlockHeader 100.00% (8/8)
github.com/conformal/btcwire/msgpong.go MsgPong.BtcEncode 100.00% (7/7)
github.com/conformal/btcwire/message.go readMessageHeader 100.00% (7/7)
@ -51,26 +51,26 @@ github.com/conformal/btcwire/common.go writeVarString 100.00% (7/7)
github.com/conformal/btcwire/msgpong.go MsgPong.BtcDecode 100.00% (7/7)
github.com/conformal/btcwire/common.go varIntSerializeSize 100.00% (7/7)
github.com/conformal/btcwire/msgversion.go NewMsgVersionFromConn 100.00% (7/7)
github.com/conformal/btcwire/msgtx.go MsgTx.SerializeSize 100.00% (6/6)
github.com/conformal/btcwire/common.go DoubleSha256 100.00% (6/6)
github.com/conformal/btcwire/msgping.go MsgPing.BtcDecode 100.00% (5/5)
github.com/conformal/btcwire/msgtx.go MsgTx.SerializeSize 100.00% (6/6)
github.com/conformal/btcwire/shahash.go ShaHash.SetBytes 100.00% (5/5)
github.com/conformal/btcwire/msgheaders.go MsgHeaders.AddBlockHeader 100.00% (5/5)
github.com/conformal/btcwire/msggetblocks.go MsgGetBlocks.AddBlockLocatorHash 100.00% (5/5)
github.com/conformal/btcwire/msginv.go MsgInv.AddInvVect 100.00% (5/5)
github.com/conformal/btcwire/common.go writeElements 100.00% (5/5)
github.com/conformal/btcwire/msgnotfound.go MsgNotFound.AddInvVect 100.00% (5/5)
github.com/conformal/btcwire/msggetheaders.go MsgGetHeaders.AddBlockLocatorHash 100.00% (5/5)
github.com/conformal/btcwire/msgnotfound.go MsgNotFound.AddInvVect 100.00% (5/5)
github.com/conformal/btcwire/msggetblocks.go MsgGetBlocks.AddBlockLocatorHash 100.00% (5/5)
github.com/conformal/btcwire/msgheaders.go MsgHeaders.AddBlockHeader 100.00% (5/5)
github.com/conformal/btcwire/common.go writeElements 100.00% (5/5)
github.com/conformal/btcwire/msgping.go MsgPing.BtcEncode 100.00% (5/5)
github.com/conformal/btcwire/common.go readElements 100.00% (5/5)
github.com/conformal/btcwire/msggetdata.go MsgGetData.AddInvVect 100.00% (5/5)
github.com/conformal/btcwire/shahash.go NewShaHash 100.00% (5/5)
github.com/conformal/btcwire/msginv.go MsgInv.AddInvVect 100.00% (5/5)
github.com/conformal/btcwire/netaddress.go NewNetAddress 100.00% (5/5)
github.com/conformal/btcwire/blockheader.go BlockHeader.BlockSha 100.00% (5/5)
github.com/conformal/btcwire/msgtx.go MsgTx.TxSha 100.00% (5/5)
github.com/conformal/btcwire/msgblock.go MsgBlock.TxShas 100.00% (5/5)
github.com/conformal/btcwire/msgaddr.go MsgAddr.AddAddress 100.00% (5/5)
github.com/conformal/btcwire/msgaddr.go MsgAddr.AddAddresses 100.00% (5/5)
github.com/conformal/btcwire/msgping.go MsgPing.BtcEncode 100.00% (5/5)
github.com/conformal/btcwire/msgping.go MsgPing.BtcDecode 100.00% (5/5)
github.com/conformal/btcwire/invvect.go readInvVect 100.00% (4/4)
github.com/conformal/btcwire/invvect.go writeInvVect 100.00% (4/4)
github.com/conformal/btcwire/msgmempool.go MsgMemPool.BtcDecode 100.00% (4/4)
@ -79,25 +79,26 @@ github.com/conformal/btcwire/msgping.go MsgPing.MaxPayloadLength 100.00% (4/
github.com/conformal/btcwire/msgpong.go MsgPong.MaxPayloadLength 100.00% (4/4)
github.com/conformal/btcwire/netaddress.go maxNetAddressPayload 100.00% (4/4)
github.com/conformal/btcwire/shahash.go ShaHash.String 100.00% (4/4)
github.com/conformal/btcwire/msgversion.go MsgVersion.HasService 100.00% (3/3)
github.com/conformal/btcwire/invvect.go InvType.String 100.00% (3/3)
github.com/conformal/btcwire/shahash.go ShaHash.Bytes 100.00% (3/3)
github.com/conformal/btcwire/error.go MessageError.Error 100.00% (3/3)
github.com/conformal/btcwire/protocol.go BitcoinNet.String 100.00% (3/3)
github.com/conformal/btcwire/msgaddr.go MsgAddr.MaxPayloadLength 100.00% (3/3)
github.com/conformal/btcwire/msggetdata.go NewMsgGetDataSizeHint 100.00% (3/3)
github.com/conformal/btcwire/netaddress.go NetAddress.HasService 100.00% (3/3)
github.com/conformal/btcwire/msgblock.go MsgBlock.AddTransaction 100.00% (3/3)
github.com/conformal/btcwire/invvect.go InvType.String 100.00% (3/3)
github.com/conformal/btcwire/msginv.go NewMsgInvSizeHint 100.00% (3/3)
github.com/conformal/btcwire/error.go MessageError.Error 100.00% (3/3)
github.com/conformal/btcwire/protocol.go BitcoinNet.String 100.00% (3/3)
github.com/conformal/btcwire/msgversion.go MsgVersion.HasService 100.00% (3/3)
github.com/conformal/btcwire/shahash.go ShaHash.Bytes 100.00% (3/3)
github.com/conformal/btcwire/msgaddr.go MsgAddr.MaxPayloadLength 100.00% (3/3)
github.com/conformal/btcwire/netaddress.go NetAddress.SetAddress 100.00% (2/2)
github.com/conformal/btcwire/netaddress.go NewNetAddressIPPort 100.00% (2/2)
github.com/conformal/btcwire/msgblock.go MsgBlock.ClearTransactions 100.00% (2/2)
github.com/conformal/btcwire/netaddress.go NetAddress.SetAddress 100.00% (2/2)
github.com/conformal/btcwire/msggetblocks.go MsgGetBlocks.Command 100.00% (1/1)
github.com/conformal/btcwire/msggetaddr.go NewMsgGetAddr 100.00% (1/1)
github.com/conformal/btcwire/msggetaddr.go MsgGetAddr.MaxPayloadLength 100.00% (1/1)
github.com/conformal/btcwire/msggetaddr.go MsgGetAddr.Command 100.00% (1/1)
github.com/conformal/btcwire/msgnotfound.go MsgNotFound.Command 100.00% (1/1)
github.com/conformal/btcwire/msgnotfound.go MsgNotFound.MaxPayloadLength 100.00% (1/1)
github.com/conformal/btcwire/msgnotfound.go NewMsgNotFound 100.00% (1/1)
github.com/conformal/btcwire/msggetaddr.go MsgGetAddr.Command 100.00% (1/1)
github.com/conformal/btcwire/msggetaddr.go MsgGetAddr.BtcEncode 100.00% (1/1)
github.com/conformal/btcwire/msgheaders.go NewMsgHeaders 100.00% (1/1)
github.com/conformal/btcwire/msgping.go MsgPing.Command 100.00% (1/1)
github.com/conformal/btcwire/common.go RandomUint64 100.00% (1/1)
github.com/conformal/btcwire/msgping.go NewMsgPing 100.00% (1/1)
@ -142,8 +143,8 @@ github.com/conformal/btcwire/blockheader.go NewBlockHeader 100.00% (1/1)
github.com/conformal/btcwire/netaddress.go NetAddress.AddService 100.00% (1/1)
github.com/conformal/btcwire/invvect.go NewInvVect 100.00% (1/1)
github.com/conformal/btcwire/error.go messageError 100.00% (1/1)
github.com/conformal/btcwire/msggetheaders.go NewMsgGetHeaders 100.00% (1/1)
github.com/conformal/btcwire/msggetheaders.go MsgGetHeaders.MaxPayloadLength 100.00% (1/1)
github.com/conformal/btcwire/msggetheaders.go NewMsgGetHeaders 100.00% (1/1)
github.com/conformal/btcwire/msggetheaders.go MsgGetHeaders.Command 100.00% (1/1)
github.com/conformal/btcwire/msggetdata.go NewMsgGetData 100.00% (1/1)
github.com/conformal/btcwire/msgheaders.go MsgHeaders.Command 100.00% (1/1)
@ -151,13 +152,14 @@ github.com/conformal/btcwire/msgheaders.go MsgHeaders.MaxPayloadLength 100.00
github.com/conformal/btcwire/msggetdata.go MsgGetData.MaxPayloadLength 100.00% (1/1)
github.com/conformal/btcwire/msggetdata.go MsgGetData.Command 100.00% (1/1)
github.com/conformal/btcwire/msggetblocks.go NewMsgGetBlocks 100.00% (1/1)
github.com/conformal/btcwire/msggetblocks.go MsgGetBlocks.MaxPayloadLength 100.00% (1/1)
github.com/conformal/btcwire/msggetblocks.go MsgGetBlocks.Command 100.00% (1/1)
github.com/conformal/btcwire/msginv.go MsgInv.Command 100.00% (1/1)
github.com/conformal/btcwire/msginv.go MsgInv.MaxPayloadLength 100.00% (1/1)
github.com/conformal/btcwire/msginv.go NewMsgInv 100.00% (1/1)
github.com/conformal/btcwire/msgheaders.go NewMsgHeaders 100.00% (1/1)
github.com/conformal/btcwire/msggetblocks.go MsgGetBlocks.MaxPayloadLength 100.00% (1/1)
github.com/conformal/btcwire/msgmempool.go MsgMemPool.Command 100.00% (1/1)
github.com/conformal/btcwire/msgmempool.go MsgMemPool.MaxPayloadLength 100.00% (1/1)
github.com/conformal/btcwire/msgmempool.go NewMsgMemPool 100.00% (1/1)
github.com/conformal/btcwire --------------------------------- 100.00% (1126/1126)
github.com/conformal/btcwire/msggetaddr.go NewMsgGetAddr 100.00% (1/1)
github.com/conformal/btcwire --------------------------------- 100.00% (1132/1132)