2014-01-09 06:44:08 +01:00
|
|
|
// Copyright (c) 2013-2014 Conformal Systems LLC.
|
2013-05-08 21:31:00 +02:00
|
|
|
// Use of this source code is governed by an ISC
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
/*
|
|
|
|
This test file is part of the btcwire package rather than than the
|
|
|
|
btcwire_test package so it can bridge access to the internals to properly test
|
|
|
|
cases which are either not possible or can't reliably be tested via the public
|
|
|
|
interface. The functions are only exported while the tests are being run.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package btcwire
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
)
|
|
|
|
|
2014-05-05 09:15:18 +02:00
|
|
|
const (
|
|
|
|
// MaxTxPerBlock makes the internal maxTxPerBlock constant available to
|
|
|
|
// the test package.
|
|
|
|
MaxTxPerBlock = maxTxPerBlock
|
2014-04-24 21:48:22 +02:00
|
|
|
|
2014-05-05 09:15:18 +02:00
|
|
|
// MaxFlagsPerMerkleBlock makes the internal maxFlagsPerMerkleBlock
|
|
|
|
// constant available to the test package.
|
|
|
|
MaxFlagsPerMerkleBlock = maxFlagsPerMerkleBlock
|
2014-04-24 21:48:22 +02:00
|
|
|
|
2014-05-05 09:15:18 +02:00
|
|
|
// MaxCountSetCancel makes the internal maxCountSetCancel constant
|
|
|
|
// available to the test package.
|
|
|
|
MaxCountSetCancel = maxCountSetCancel
|
|
|
|
|
|
|
|
// MaxCountSetSubVer makes the internal maxCountSetSubVer constant
|
|
|
|
// available to the test package.
|
|
|
|
MaxCountSetSubVer = maxCountSetSubVer
|
|
|
|
|
|
|
|
// CommandSize makes the internal commandSize constant available to the
|
|
|
|
// test package.
|
|
|
|
CommandSize = commandSize
|
|
|
|
)
|
2013-11-07 12:17:17 +01:00
|
|
|
|
2013-05-08 21:31:00 +02:00
|
|
|
// TstRandomUint64 makes the internal randomUint64 function available to the
|
|
|
|
// test package.
|
|
|
|
func TstRandomUint64(r io.Reader) (uint64, error) {
|
|
|
|
return randomUint64(r)
|
|
|
|
}
|
|
|
|
|
2013-11-07 12:17:17 +01:00
|
|
|
// TstReadElement makes the internal readElement function available to the
|
|
|
|
// test package.
|
|
|
|
func TstReadElement(r io.Reader, element interface{}) error {
|
|
|
|
return readElement(r, element)
|
|
|
|
}
|
|
|
|
|
|
|
|
// TstWriteElement makes the internal writeElement function available to the
|
|
|
|
// test package.
|
|
|
|
func TstWriteElement(w io.Writer, element interface{}) error {
|
|
|
|
return writeElement(w, element)
|
|
|
|
}
|
|
|
|
|
2013-05-08 21:31:00 +02:00
|
|
|
// TstReadVarInt makes the internal readVarInt function available to the
|
|
|
|
// test package.
|
|
|
|
func TstReadVarInt(r io.Reader, pver uint32) (uint64, error) {
|
|
|
|
return readVarInt(r, pver)
|
|
|
|
}
|
|
|
|
|
|
|
|
// TstWriteVarInt makes the internal writeVarInt function available to the
|
|
|
|
// test package.
|
|
|
|
func TstWriteVarInt(w io.Writer, pver uint32, val uint64) error {
|
|
|
|
return writeVarInt(w, pver, val)
|
|
|
|
}
|
|
|
|
|
|
|
|
// TstReadVarString makes the internal readVarString function available to the
|
|
|
|
// test package.
|
|
|
|
func TstReadVarString(r io.Reader, pver uint32) (string, error) {
|
|
|
|
return readVarString(r, pver)
|
|
|
|
}
|
|
|
|
|
|
|
|
// TstWriteVarString makes the internal writeVarString function available to the
|
|
|
|
// test package.
|
|
|
|
func TstWriteVarString(w io.Writer, pver uint32, str string) error {
|
|
|
|
return writeVarString(w, pver, str)
|
|
|
|
}
|
|
|
|
|
2014-04-24 21:48:22 +02:00
|
|
|
// TstReadVarBytes makes the internal readVarBytes function available to the
|
|
|
|
// test package.
|
|
|
|
func TstReadVarBytes(r io.Reader, pver uint32, maxAllowed uint32, fieldName string) ([]byte, error) {
|
|
|
|
return readVarBytes(r, pver, maxAllowed, fieldName)
|
|
|
|
}
|
|
|
|
|
|
|
|
// TstWriteVarBytes makes the internal writeVarBytes function available to the
|
|
|
|
// test package.
|
|
|
|
func TstWriteVarBytes(w io.Writer, pver uint32, bytes []byte) error {
|
|
|
|
return writeVarBytes(w, pver, bytes)
|
|
|
|
}
|
|
|
|
|
2013-05-08 21:31:00 +02:00
|
|
|
// TstReadNetAddress makes the internal readNetAddress function available to
|
|
|
|
// the test package.
|
|
|
|
func TstReadNetAddress(r io.Reader, pver uint32, na *NetAddress, ts bool) error {
|
|
|
|
return readNetAddress(r, pver, na, ts)
|
|
|
|
}
|
|
|
|
|
|
|
|
// TstWriteNetAddress makes the internal writeNetAddress function available to
|
|
|
|
// the test package.
|
|
|
|
func TstWriteNetAddress(w io.Writer, pver uint32, na *NetAddress, ts bool) error {
|
|
|
|
return writeNetAddress(w, pver, na, ts)
|
|
|
|
}
|
|
|
|
|
|
|
|
// TstMaxNetAddressPayload makes the internal maxNetAddressPayload function
|
|
|
|
// available to the test package.
|
|
|
|
func TstMaxNetAddressPayload(pver uint32) uint32 {
|
|
|
|
return maxNetAddressPayload(pver)
|
|
|
|
}
|
|
|
|
|
|
|
|
// TstReadInvVect makes the internal readInvVect function available to the test
|
|
|
|
// package.
|
|
|
|
func TstReadInvVect(r io.Reader, pver uint32, iv *InvVect) error {
|
|
|
|
return readInvVect(r, pver, iv)
|
|
|
|
}
|
|
|
|
|
|
|
|
// TstWriteInvVect makes the internal writeInvVect function available to the
|
|
|
|
// test package.
|
|
|
|
func TstWriteInvVect(w io.Writer, pver uint32, iv *InvVect) error {
|
|
|
|
return writeInvVect(w, pver, iv)
|
|
|
|
}
|
|
|
|
|
|
|
|
// TstReadBlockHeader makes the internal readBlockHeader function available to
|
|
|
|
// the test package.
|
|
|
|
func TstReadBlockHeader(r io.Reader, pver uint32, bh *BlockHeader) error {
|
|
|
|
return readBlockHeader(r, pver, bh)
|
|
|
|
}
|
|
|
|
|
|
|
|
// TstWriteBlockHeader makes the internal writeBlockHeader function available to
|
|
|
|
// the test package.
|
|
|
|
func TstWriteBlockHeader(w io.Writer, pver uint32, bh *BlockHeader) error {
|
|
|
|
return writeBlockHeader(w, pver, bh)
|
|
|
|
}
|
|
|
|
|
|
|
|
// TstReadMessageHeader makes the internal readMessageHeader function available
|
|
|
|
// to the test package.
|
2014-01-19 05:29:44 +01:00
|
|
|
func TstReadMessageHeader(r io.Reader) (int, *messageHeader, error) {
|
2013-05-08 21:31:00 +02:00
|
|
|
return readMessageHeader(r)
|
|
|
|
}
|
2013-11-06 07:43:52 +01:00
|
|
|
|
2013-11-06 14:33:37 +01:00
|
|
|
// TstReadOutPoint makes the internal readOutPoint function available to the
|
|
|
|
// test package.
|
2014-06-29 21:40:20 +02:00
|
|
|
func TstReadOutPoint(r io.Reader, pver uint32, version int32, op *OutPoint) error {
|
2013-11-06 14:33:37 +01:00
|
|
|
return readOutPoint(r, pver, version, op)
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:43:52 +01:00
|
|
|
// TstWriteOutPoint makes the internal writeOutPoint function available to the
|
|
|
|
// test package.
|
2014-06-29 21:40:20 +02:00
|
|
|
func TstWriteOutPoint(w io.Writer, pver uint32, version int32, op *OutPoint) error {
|
2013-11-06 07:43:52 +01:00
|
|
|
return writeOutPoint(w, pver, version, op)
|
|
|
|
}
|
2013-11-06 22:21:37 +01:00
|
|
|
|
2013-11-06 22:40:46 +01:00
|
|
|
// TstReadTxOut makes the internal readTxOut function available to the test
|
|
|
|
// package.
|
2014-06-29 21:40:20 +02:00
|
|
|
func TstReadTxOut(r io.Reader, pver uint32, version int32, to *TxOut) error {
|
2013-11-06 22:40:46 +01:00
|
|
|
return readTxOut(r, pver, version, to)
|
|
|
|
}
|
|
|
|
|
2013-11-06 22:21:37 +01:00
|
|
|
// TstWriteTxOut makes the internal writeTxOut function available to the test
|
|
|
|
// package.
|
2014-06-29 21:40:20 +02:00
|
|
|
func TstWriteTxOut(w io.Writer, pver uint32, version int32, to *TxOut) error {
|
2013-11-06 22:21:37 +01:00
|
|
|
return writeTxOut(w, pver, version, to)
|
|
|
|
}
|
2013-11-06 23:06:53 +01:00
|
|
|
|
|
|
|
// TstReadTxIn makes the internal readTxIn function available to the test
|
|
|
|
// package.
|
2014-06-29 21:40:20 +02:00
|
|
|
func TstReadTxIn(r io.Reader, pver uint32, version int32, ti *TxIn) error {
|
2013-11-06 23:06:53 +01:00
|
|
|
return readTxIn(r, pver, version, ti)
|
|
|
|
}
|
2013-11-06 23:21:49 +01:00
|
|
|
|
|
|
|
// TstWriteTxIn makes the internal writeTxIn function available to the test
|
|
|
|
// package.
|
2014-06-29 21:40:20 +02:00
|
|
|
func TstWriteTxIn(w io.Writer, pver uint32, version int32, ti *TxIn) error {
|
2013-11-06 23:21:49 +01:00
|
|
|
return writeTxIn(w, pver, version, ti)
|
|
|
|
}
|