diff --git a/bench_test.go b/bench_test.go index 82f895b7..377ab0aa 100644 --- a/bench_test.go +++ b/bench_test.go @@ -192,3 +192,12 @@ func BenchmarkReadTxIn(b *testing.B) { btcwire.TstReadTxIn(bytes.NewBuffer(buf), 0, 0, &txIn) } } + +// BenchmarkWriteTxIn performs a benchmark on how long it takes to write +// a transaction input. +func BenchmarkWriteTxIn(b *testing.B) { + txIn := blockOne.Transactions[0].TxIn[0] + for i := 0; i < b.N; i++ { + btcwire.TstWriteTxIn(ioutil.Discard, 0, 0, txIn) + } +} diff --git a/internal_test.go b/internal_test.go index 0696c200..e8ec3535 100644 --- a/internal_test.go +++ b/internal_test.go @@ -132,3 +132,9 @@ func TstWriteTxOut(w io.Writer, pver uint32, version uint32, to *TxOut) error { func TstReadTxIn(r io.Reader, pver uint32, version uint32, ti *TxIn) error { return readTxIn(r, pver, version, ti) } + +// TstWriteTxIn makes the internal writeTxIn function available to the test +// package. +func TstWriteTxIn(w io.Writer, pver uint32, version uint32, ti *TxIn) error { + return writeTxIn(w, pver, version, ti) +}