From b90727cc8ac43a648b22be89ebacb4901b201f81 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Thu, 30 May 2013 10:30:04 -0500 Subject: [PATCH] Add tests for TxLoc. --- block_test.go | 20 ++++++++++++++++++++ test_coverage.txt | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/block_test.go b/block_test.go index 52daa21..d954aa2 100644 --- a/block_test.go +++ b/block_test.go @@ -153,6 +153,26 @@ func TestBlock(t *testing.T) { } } + + // Transaction offsets and length for the transaction in Block100000. + wantTxLocs := []btcwire.TxLoc{ + btcwire.TxLoc{TxStart: 81, TxLen: 135}, + btcwire.TxLoc{TxStart: 216, TxLen: 259}, + btcwire.TxLoc{TxStart: 475, TxLen: 257}, + btcwire.TxLoc{TxStart: 732, TxLen: 225}, + } + + // Ensure the transaction location information is accurate. + txLocs, err := b.TxLoc() + if err != nil { + t.Errorf("TxLoc: %v", err) + return + } + if !reflect.DeepEqual(txLocs, wantTxLocs) { + t.Errorf("TxLoc: mismatched transaction location information "+ + "- got %v, want %v", spew.Sdump(txLocs), + spew.Sdump(wantTxLocs)) + } } // TestNewBlockFromBytes tests creation of a Block from raw bytes. diff --git a/test_coverage.txt b/test_coverage.txt index dad4595..f6a65d9 100644 --- a/test_coverage.txt +++ b/test_coverage.txt @@ -10,7 +10,7 @@ github.com/conformal/btcutil/block.go NewBlock 100.00% (1/1) github.com/conformal/btcutil/block.go Block.Bytes 88.89% (8/9) github.com/conformal/btcutil/block.go NewBlockFromBytes 85.71% (6/7) github.com/conformal/btcutil/block.go Block.TxSha 81.82% (9/11) -github.com/conformal/btcutil/block.go Block.TxLoc 0.00% (0/9) +github.com/conformal/btcutil/block.go Block.TxLoc 77.78% (7/9) github.com/conformal/btcutil/block.go OutOfRangeError.Error 0.00% (0/1) -github.com/conformal/btcutil ------------------------- 75.86% (44/58) +github.com/conformal/btcutil ------------------------- 87.93% (51/58)