fmt
This commit is contained in:
parent
840708a3e7
commit
b4c6a5b8ab
3 changed files with 11 additions and 15 deletions
|
@ -50,7 +50,7 @@ func failtestOperationalMode(t *testing.T, mode int) {
|
|||
t.Errorf("not right type")
|
||||
}
|
||||
case dbTmNoVerify: // validated block
|
||||
// no point in testing this
|
||||
// no point in testing this
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ out:
|
|||
block := blocks[height]
|
||||
|
||||
mblock := block.MsgBlock()
|
||||
blockname, _ := block.Sha()
|
||||
blockname, _ := block.Sha()
|
||||
|
||||
if height == 248 {
|
||||
// time to corrupt the datbase, to see if it leaves the block or tx in the db
|
||||
|
@ -90,7 +90,6 @@ out:
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if height == 248 {
|
||||
}
|
||||
newheight, err := db.InsertBlock(block)
|
||||
|
@ -120,7 +119,7 @@ out:
|
|||
t.Errorf("block still present after failed insert")
|
||||
}
|
||||
// if we got here with no error, testing was successful
|
||||
break out
|
||||
break out
|
||||
}
|
||||
if newheight != height {
|
||||
t.Errorf("height mismatch expect %v returned %v", height, newheight)
|
||||
|
|
|
@ -152,11 +152,10 @@ out:
|
|||
|
||||
blkSha, _ := block.Sha()
|
||||
if *newSha != *blkSha {
|
||||
t.Errorf("Newest block sha does not match freshly inserted one %v %v ", newSha, blkSha)
|
||||
t.Errorf("Newest block sha does not match freshly inserted one %v %v ", newSha, blkSha)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// now that db is populated, do some additional test
|
||||
testFetchRangeHeight(t, db, blocks)
|
||||
|
||||
|
@ -365,11 +364,10 @@ func loadBlocks(t *testing.T, file string) (blocks []*btcutil.Block, err error)
|
|||
return
|
||||
}
|
||||
|
||||
|
||||
func testFetchRangeHeight(t *testing.T, db btcdb.Db, blocks []*btcutil.Block) () {
|
||||
func testFetchRangeHeight(t *testing.T, db btcdb.Db, blocks []*btcutil.Block) {
|
||||
|
||||
var testincrement int64 = 50
|
||||
var testcnt int64 = 100
|
||||
var testcnt int64 = 100
|
||||
|
||||
shanames := make([]*btcwire.ShaHash, len(blocks))
|
||||
|
||||
|
@ -396,8 +394,8 @@ func testFetchRangeHeight(t *testing.T, db btcdb.Db, blocks []*btcutil.Block) ()
|
|||
}
|
||||
|
||||
if endheight == btcdb.AllShas {
|
||||
if int64(len(shalist)) != nBlocks - startheight {
|
||||
t.Errorf("FetchRangeHeight: expected A %v shas, got %v", nBlocks - startheight, len(shalist))
|
||||
if int64(len(shalist)) != nBlocks-startheight {
|
||||
t.Errorf("FetchRangeHeight: expected A %v shas, got %v", nBlocks-startheight, len(shalist))
|
||||
}
|
||||
} else {
|
||||
if int64(len(shalist)) != testcnt {
|
||||
|
@ -412,5 +410,4 @@ func testFetchRangeHeight(t *testing.T, db btcdb.Db, blocks []*btcutil.Block) ()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -576,7 +576,7 @@ func (db *SqliteDb) DropAfterBlockBySha(sha *btcwire.ShaHash) (err error) {
|
|||
return db.delFromDB(keepidx)
|
||||
}
|
||||
|
||||
func (db *SqliteDb) delFromDB(keepidx int64) (error) {
|
||||
func (db *SqliteDb) delFromDB(keepidx int64) error {
|
||||
tx := &db.txState
|
||||
_, err := tx.tx.Exec("DELETE FROM txtmp WHERE blockid > ?", keepidx)
|
||||
if err != nil {
|
||||
|
@ -649,7 +649,7 @@ func (db *SqliteDb) InsertBlock(block *btcutil.Block) (int64, error) {
|
|||
if success {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
for txidx := 0; txidx <= txinsertidx; txidx++ {
|
||||
tx := mblock.Transactions[txidx]
|
||||
|
||||
|
@ -659,7 +659,7 @@ func (db *SqliteDb) InsertBlock(block *btcutil.Block) (int64, error) {
|
|||
}
|
||||
}
|
||||
|
||||
err = db.delFromDB(newheight -1)
|
||||
err = db.delFromDB(newheight - 1)
|
||||
if err != nil {
|
||||
log.Warnf("Error during block insert unwind %v %v", blocksha, err)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue