mirror of
https://github.com/LBRYFoundation/lbcd.git
synced 2025-08-27 15:31:28 +00:00
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")
|
t.Errorf("not right type")
|
||||||
}
|
}
|
||||||
case dbTmNoVerify: // validated block
|
case dbTmNoVerify: // validated block
|
||||||
// no point in testing this
|
// no point in testing this
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ out:
|
||||||
block := blocks[height]
|
block := blocks[height]
|
||||||
|
|
||||||
mblock := block.MsgBlock()
|
mblock := block.MsgBlock()
|
||||||
blockname, _ := block.Sha()
|
blockname, _ := block.Sha()
|
||||||
|
|
||||||
if height == 248 {
|
if height == 248 {
|
||||||
// time to corrupt the datbase, to see if it leaves the block or tx in the db
|
// 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 {
|
if height == 248 {
|
||||||
}
|
}
|
||||||
newheight, err := db.InsertBlock(block)
|
newheight, err := db.InsertBlock(block)
|
||||||
|
@ -120,7 +119,7 @@ out:
|
||||||
t.Errorf("block still present after failed insert")
|
t.Errorf("block still present after failed insert")
|
||||||
}
|
}
|
||||||
// if we got here with no error, testing was successful
|
// if we got here with no error, testing was successful
|
||||||
break out
|
break out
|
||||||
}
|
}
|
||||||
if newheight != height {
|
if newheight != height {
|
||||||
t.Errorf("height mismatch expect %v returned %v", height, newheight)
|
t.Errorf("height mismatch expect %v returned %v", height, newheight)
|
||||||
|
|
|
@ -152,11 +152,10 @@ out:
|
||||||
|
|
||||||
blkSha, _ := block.Sha()
|
blkSha, _ := block.Sha()
|
||||||
if *newSha != *blkSha {
|
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
|
// now that db is populated, do some additional test
|
||||||
testFetchRangeHeight(t, db, blocks)
|
testFetchRangeHeight(t, db, blocks)
|
||||||
|
|
||||||
|
@ -365,11 +364,10 @@ func loadBlocks(t *testing.T, file string) (blocks []*btcutil.Block, err error)
|
||||||
return
|
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 testincrement int64 = 50
|
||||||
var testcnt int64 = 100
|
var testcnt int64 = 100
|
||||||
|
|
||||||
shanames := make([]*btcwire.ShaHash, len(blocks))
|
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 endheight == btcdb.AllShas {
|
||||||
if int64(len(shalist)) != nBlocks - startheight {
|
if int64(len(shalist)) != nBlocks-startheight {
|
||||||
t.Errorf("FetchRangeHeight: expected A %v shas, got %v", nBlocks - startheight, len(shalist))
|
t.Errorf("FetchRangeHeight: expected A %v shas, got %v", nBlocks-startheight, len(shalist))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if int64(len(shalist)) != testcnt {
|
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)
|
return db.delFromDB(keepidx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *SqliteDb) delFromDB(keepidx int64) (error) {
|
func (db *SqliteDb) delFromDB(keepidx int64) error {
|
||||||
tx := &db.txState
|
tx := &db.txState
|
||||||
_, err := tx.tx.Exec("DELETE FROM txtmp WHERE blockid > ?", keepidx)
|
_, err := tx.tx.Exec("DELETE FROM txtmp WHERE blockid > ?", keepidx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -649,7 +649,7 @@ func (db *SqliteDb) InsertBlock(block *btcutil.Block) (int64, error) {
|
||||||
if success {
|
if success {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for txidx := 0; txidx <= txinsertidx; txidx++ {
|
for txidx := 0; txidx <= txinsertidx; txidx++ {
|
||||||
tx := mblock.Transactions[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 {
|
if err != nil {
|
||||||
log.Warnf("Error during block insert unwind %v %v", blocksha, err)
|
log.Warnf("Error during block insert unwind %v %v", blocksha, err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue