github.com/dashpay/godash@v0.0.0-20160726055534-e038a21e0e3d/wire/internal_test.go (about) 1 // Copyright (c) 2013-2015 The btcsuite developers 2 // Copyright (c) 2016 The Dash developers 3 // Use of this source code is governed by an ISC 4 // license that can be found in the LICENSE file. 5 6 /* 7 This test file is part of the wire package rather than than the wire_test 8 package so it can bridge access to the internals to properly test cases which 9 are either not possible or can't reliably be tested via the public interface. 10 The functions are only exported while the tests are being run. 11 */ 12 13 package wire 14 15 import ( 16 "io" 17 ) 18 19 const ( 20 // MaxTxPerBlock makes the internal maxTxPerBlock constant available to 21 // the test package. 22 MaxTxPerBlock = maxTxPerBlock 23 24 // MaxFlagsPerMerkleBlock makes the internal maxFlagsPerMerkleBlock 25 // constant available to the test package. 26 MaxFlagsPerMerkleBlock = maxFlagsPerMerkleBlock 27 28 // MaxCountSetCancel makes the internal maxCountSetCancel constant 29 // available to the test package. 30 MaxCountSetCancel = maxCountSetCancel 31 32 // MaxCountSetSubVer makes the internal maxCountSetSubVer constant 33 // available to the test package. 34 MaxCountSetSubVer = maxCountSetSubVer 35 ) 36 37 // TstRandomUint64 makes the internal randomUint64 function available to the 38 // test package. 39 func TstRandomUint64(r io.Reader) (uint64, error) { 40 return randomUint64(r) 41 } 42 43 // TstReadElement makes the internal readElement function available to the 44 // test package. 45 func TstReadElement(r io.Reader, element interface{}) error { 46 return readElement(r, element) 47 } 48 49 // TstWriteElement makes the internal writeElement function available to the 50 // test package. 51 func TstWriteElement(w io.Writer, element interface{}) error { 52 return writeElement(w, element) 53 } 54 55 // TstReadVarInt makes the internal ReadVarInt function available to the 56 // test package. 57 func TstReadVarInt(r io.Reader, pver uint32) (uint64, error) { 58 return ReadVarInt(r, pver) 59 } 60 61 // TstWriteVarInt makes the internal WriteVarInt function available to the 62 // test package. 63 func TstWriteVarInt(w io.Writer, pver uint32, val uint64) error { 64 return WriteVarInt(w, pver, val) 65 } 66 67 // TstReadVarBytes makes the internal ReadVarBytes function available to the 68 // test package. 69 func TstReadVarBytes(r io.Reader, pver uint32, maxAllowed uint32, fieldName string) ([]byte, error) { 70 return ReadVarBytes(r, pver, maxAllowed, fieldName) 71 } 72 73 // TstWriteVarBytes makes the internal WriteVarBytes function available to the 74 // test package. 75 func TstWriteVarBytes(w io.Writer, pver uint32, bytes []byte) error { 76 return WriteVarBytes(w, pver, bytes) 77 } 78 79 // TstReadNetAddress makes the internal readNetAddress function available to 80 // the test package. 81 func TstReadNetAddress(r io.Reader, pver uint32, na *NetAddress, ts bool) error { 82 return readNetAddress(r, pver, na, ts) 83 } 84 85 // TstWriteNetAddress makes the internal writeNetAddress function available to 86 // the test package. 87 func TstWriteNetAddress(w io.Writer, pver uint32, na *NetAddress, ts bool) error { 88 return writeNetAddress(w, pver, na, ts) 89 } 90 91 // TstMaxNetAddressPayload makes the internal maxNetAddressPayload function 92 // available to the test package. 93 func TstMaxNetAddressPayload(pver uint32) uint32 { 94 return maxNetAddressPayload(pver) 95 } 96 97 // TstReadInvVect makes the internal readInvVect function available to the test 98 // package. 99 func TstReadInvVect(r io.Reader, pver uint32, iv *InvVect) error { 100 return readInvVect(r, pver, iv) 101 } 102 103 // TstWriteInvVect makes the internal writeInvVect function available to the 104 // test package. 105 func TstWriteInvVect(w io.Writer, pver uint32, iv *InvVect) error { 106 return writeInvVect(w, pver, iv) 107 } 108 109 // TstReadBlockHeader makes the internal readBlockHeader function available to 110 // the test package. 111 func TstReadBlockHeader(r io.Reader, pver uint32, bh *BlockHeader) error { 112 return readBlockHeader(r, pver, bh) 113 } 114 115 // TstWriteBlockHeader makes the internal writeBlockHeader function available to 116 // the test package. 117 func TstWriteBlockHeader(w io.Writer, pver uint32, bh *BlockHeader) error { 118 return writeBlockHeader(w, pver, bh) 119 }