Add tests for TxLoc.

This commit is contained in:
Dave Collins 2013-05-30 10:30:04 -05:00
parent af89ed1c2e
commit b90727cc8a
2 changed files with 22 additions and 2 deletions

View file

@ -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. // TestNewBlockFromBytes tests creation of a Block from raw bytes.

View file

@ -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 Block.Bytes 88.89% (8/9)
github.com/conformal/btcutil/block.go NewBlockFromBytes 85.71% (6/7) 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.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/block.go OutOfRangeError.Error 0.00% (0/1)
github.com/conformal/btcutil ------------------------- 75.86% (44/58) github.com/conformal/btcutil ------------------------- 87.93% (51/58)