Add interface test for ExistsTxSha.
This commit adds an interface test for ExistsTxSha to ensure all transactions inserted as a part of a block are available.
This commit is contained in:
parent
f37fabb855
commit
6a3824b8aa
1 changed files with 18 additions and 1 deletions
|
@ -129,6 +129,23 @@ func testInterface(t *testing.T, dbType string) {
|
|||
"want: %v", dbType, hashFromDb, expectedHash)
|
||||
return
|
||||
}
|
||||
|
||||
// The following set of tests examine all of the transactions in
|
||||
// the block.
|
||||
txHashes, err := block.TxShas()
|
||||
if err != nil {
|
||||
t.Errorf("block.TxShas: %v", err)
|
||||
return
|
||||
}
|
||||
for i, tx := range block.MsgBlock().Transactions {
|
||||
// Ensure the transaction exists.
|
||||
txHash := txHashes[i]
|
||||
if exists := db.ExistsTxSha(txHash); !exists {
|
||||
t.Errorf("ExistsTxSha (%s): tx %v does not exist",
|
||||
dbType, txHash)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure FetchBlockShaByHeight handles invalid heights properly.
|
||||
|
@ -148,7 +165,7 @@ func testInterface(t *testing.T, dbType string) {
|
|||
- FetchBlockBySha(sha *btcwire.ShaHash) (blk *btcutil.Block, err error)
|
||||
- FetchBlockShaByHeight(height int64) (sha *btcwire.ShaHash, err error)
|
||||
FetchHeightRange(startHeight, endHeight int64) (rshalist []btcwire.ShaHash, err error)
|
||||
ExistsTxSha(sha *btcwire.ShaHash) (exists bool)
|
||||
- ExistsTxSha(sha *btcwire.ShaHash) (exists bool)
|
||||
FetchTxBySha(txsha *btcwire.ShaHash) ([]*TxListReply, error)
|
||||
FetchTxByShaList(txShaList []*btcwire.ShaHash) []*TxListReply
|
||||
FetchUnSpentTxByShaList(txShaList []*btcwire.ShaHash) []*TxListReply
|
||||
|
|
Loading…
Reference in a new issue