From 0e033023bf585394209234b5af6dbce3efc586cf Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Sun, 12 May 2013 12:43:01 -0500 Subject: [PATCH] Improve MsgBlock negative tests. Rather than decoding from a zero-filled buffer, use valid block encoded test data. --- msgblock_test.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/msgblock_test.go b/msgblock_test.go index 2cfffe74..0ad8ceb7 100644 --- a/msgblock_test.go +++ b/msgblock_test.go @@ -241,21 +241,20 @@ func TestBlockWireErrors(t *testing.T) { writeErr error // Expected write error readErr error // Expected read error }{ - // Latest protocol version with intentional read/write errors. // Force error in version. - {&blockOne, []byte{}, pver, 0, io.ErrShortWrite, io.EOF}, + {&blockOne, blockOneBytes, pver, 0, io.ErrShortWrite, io.EOF}, // Force error in prev block hash. - {&blockOne, []byte{}, pver, 4, io.ErrShortWrite, io.EOF}, + {&blockOne, blockOneBytes, pver, 4, io.ErrShortWrite, io.EOF}, // Force error in merkle root. - {&blockOne, []byte{}, pver, 36, io.ErrShortWrite, io.EOF}, + {&blockOne, blockOneBytes, pver, 36, io.ErrShortWrite, io.EOF}, // Force error in timestamp. - {&blockOne, []byte{}, pver, 68, io.ErrShortWrite, io.EOF}, + {&blockOne, blockOneBytes, pver, 68, io.ErrShortWrite, io.EOF}, // Force error in difficulty bits. - {&blockOne, []byte{}, pver, 72, io.ErrShortWrite, io.EOF}, + {&blockOne, blockOneBytes, pver, 72, io.ErrShortWrite, io.EOF}, // Force error in header nonce. - {&blockOne, []byte{}, pver, 76, io.ErrShortWrite, io.EOF}, + {&blockOne, blockOneBytes, pver, 76, io.ErrShortWrite, io.EOF}, // Force error in transaction count. - {&blockOne, []byte{}, pver, 80, io.ErrShortWrite, io.EOF}, + {&blockOne, blockOneBytes, pver, 80, io.ErrShortWrite, io.EOF}, // Force error in transactions. {&blockOne, blockOneBytes, pver, 81, io.ErrShortWrite, io.EOF}, }