diff --git a/database/interface_test.go b/database/interface_test.go index c07f73805..ef89dfacd 100644 --- a/database/interface_test.go +++ b/database/interface_test.go @@ -549,13 +549,8 @@ func testInterface(t *testing.T, dbType string) { // Get the appropriate block and hash and update the test // context accordingly. block := blocks[height] - blockHash, err := block.Sha() - if err != nil { - t.Errorf("block.Sha: %v", err) - return - } context.blockHeight = height - context.blockHash = blockHash + context.blockHash = block.Sha() context.block = block // The block must insert without any errors and return the @@ -590,13 +585,8 @@ func testInterface(t *testing.T, dbType string) { // Get the appropriate block and hash and update the // test context accordingly. block := blocks[height] - blockHash, err := block.Sha() - if err != nil { - t.Errorf("block.Sha: %v", err) - return - } context.blockHeight = height - context.blockHash = blockHash + context.blockHash = block.Sha() context.block = block testIntegrity(&context) diff --git a/database/ldb/dup_test.go b/database/ldb/dup_test.go index caf0ddad1..39b2cd87c 100644 --- a/database/ldb/dup_test.go +++ b/database/ldb/dup_test.go @@ -103,7 +103,7 @@ out: t.Errorf("height doe not match latest block height %v %v %v", blkid, height, err) } - blkSha, _ := block.Sha() + blkSha := block.Sha() if *newSha != *blkSha { t.Errorf("Newest block sha does not match freshly inserted one %v %v %v ", newSha, blkSha, err) } diff --git a/database/ldb/insertremove_test.go b/database/ldb/insertremove_test.go index 1c53cc2f9..9640d45ae 100644 --- a/database/ldb/insertremove_test.go +++ b/database/ldb/insertremove_test.go @@ -150,9 +150,8 @@ endtest: continue } dropblock := blocks[height-1] - dropsha, _ := dropblock.Sha() - err = db.DropAfterBlockBySha(dropsha) + err = db.DropAfterBlockBySha(dropblock.Sha()) if err != nil { t.Errorf("failed to drop block %v err %v", height, err) break endtest diff --git a/database/ldb/operational_test.go b/database/ldb/operational_test.go index d86b7c5d0..1219b32e5 100644 --- a/database/ldb/operational_test.go +++ b/database/ldb/operational_test.go @@ -268,7 +268,7 @@ out: t.Errorf("height does not match latest block height %v %v %v", blkid, height, err) } - blkSha, _ := block.Sha() + blkSha := block.Sha() if *newSha != *blkSha { t.Errorf("Newest block sha does not match freshly inserted one %v %v %v ", newSha, blkSha, err) } @@ -345,11 +345,7 @@ func testBackout(t *testing.T) { } }() - sha, err := testDb.blocks[99].Sha() - if err != nil { - t.Errorf("failed to get block 99 sha err %v", err) - return - } + sha := testDb.blocks[99].Sha() if _, err := testDb.db.ExistsSha(sha); err != nil { t.Errorf("ExistsSha: unexpected error: %v", err) } @@ -359,11 +355,7 @@ func testBackout(t *testing.T) { return } - sha, err = testDb.blocks[119].Sha() - if err != nil { - t.Errorf("failed to get block 110 sha err %v", err) - return - } + sha = testDb.blocks[119].Sha() if _, err := testDb.db.ExistsSha(sha); err != nil { t.Errorf("ExistsSha: unexpected error: %v", err) } @@ -472,11 +464,7 @@ func testFetchHeightRange(t *testing.T, db database.Db, blocks []*btcutil.Block) nBlocks := int64(len(blocks)) for i := range blocks { - blockSha, err := blocks[i].Sha() - if err != nil { - t.Errorf("FetchHeightRange: unexpected failure computing block sah %v", err) - } - shanames[i] = blockSha + shanames[i] = blocks[i].Sha() } for startheight := int64(0); startheight < nBlocks; startheight += testincrement { @@ -557,7 +545,7 @@ func TestLimitAndSkipFetchTxsForAddr(t *testing.T) { copy(hash160[:], scriptAddr[:]) index[hash160] = append(index[hash160], &txLoc[i]) } - blkSha, _ := testBlock.Sha() + blkSha := testBlock.Sha() err = testDb.db.UpdateAddrIndexForBlock(blkSha, newheight, index) if err != nil { t.Fatalf("UpdateAddrIndexForBlock: failed to index"+ diff --git a/database/reorg_test.go b/database/reorg_test.go index 344a358c0..5ba8fbb58 100644 --- a/database/reorg_test.go +++ b/database/reorg_test.go @@ -34,13 +34,10 @@ func testReorganization(t *testing.T, dbType string) { } for i := int64(0); i <= 2; i++ { - blkHash, err := blocks[i].Sha() - if err != nil { - t.Fatalf("Error getting SHA for block %d: %v", i, err) - } _, err = db.InsertBlock(blocks[i]) if err != nil { - t.Fatalf("Error inserting block %d (%v): %v", i, blkHash, err) + t.Fatalf("Error inserting block %d (%v): %v", i, + blocks[i].Sha(), err) } var txIDs []string for _, tx := range blocks[i].Transactions() { @@ -49,10 +46,7 @@ func testReorganization(t *testing.T, dbType string) { } for i := int64(1); i >= 0; i-- { - blkHash, err := blocks[i].Sha() - if err != nil { - t.Fatalf("Error getting SHA for block %d: %v", i, err) - } + blkHash := blocks[i].Sha() err = db.DropAfterBlockBySha(blkHash) if err != nil { t.Fatalf("Error removing block %d for reorganization: %v", i, err) @@ -70,7 +64,7 @@ func testReorganization(t *testing.T, dbType string) { } for i := int64(3); i < int64(len(blocks)); i++ { - blkHash, err := blocks[i].Sha() + blkHash := blocks[i].Sha() if err != nil { t.Fatalf("Error getting SHA for block %dA: %v", i-2, err) }