mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 11:26:44 +01:00
Test synchronizer reorg
This commit is contained in:
@@ -729,8 +729,8 @@ func (hdb *HistoryDB) addAccounts(d meddler.DB, accounts []common.Account) error
|
||||
)
|
||||
}
|
||||
|
||||
// GetAccounts returns a list of accounts from the DB
|
||||
func (hdb *HistoryDB) GetAccounts() ([]common.Account, error) {
|
||||
// GetAllAccounts returns a list of accounts from the DB
|
||||
func (hdb *HistoryDB) GetAllAccounts() ([]common.Account, error) {
|
||||
var accs []*common.Account
|
||||
err := meddler.QueryAll(
|
||||
hdb.db, &accs,
|
||||
|
||||
@@ -293,7 +293,7 @@ func TestAccounts(t *testing.T) {
|
||||
err = historyDB.AddAccounts(accs)
|
||||
assert.NoError(t, err)
|
||||
// Fetch accounts
|
||||
fetchedAccs, err := historyDB.GetAccounts()
|
||||
fetchedAccs, err := historyDB.GetAllAccounts()
|
||||
assert.NoError(t, err)
|
||||
// Compare fetched accounts vs generated accounts
|
||||
for i, acc := range fetchedAccs {
|
||||
|
||||
@@ -249,7 +249,6 @@ func (s *StateDB) Reset(batchNum common.BatchNum) error {
|
||||
// deleted when MakeCheckpoint overwrites them. `closeCurrent` will close the
|
||||
// currently opened db before doing the reset.
|
||||
func (s *StateDB) reset(batchNum common.BatchNum, closeCurrent bool) error {
|
||||
checkpointPath := s.path + PathBatchNum + strconv.Itoa(int(batchNum))
|
||||
currentPath := s.path + PathCurrent
|
||||
|
||||
if closeCurrent {
|
||||
@@ -271,9 +270,19 @@ func (s *StateDB) reset(batchNum common.BatchNum, closeCurrent bool) error {
|
||||
s.db = sto
|
||||
s.idx = 255
|
||||
s.currentBatch = batchNum
|
||||
|
||||
if s.mt != nil {
|
||||
// open the MT for the current s.db
|
||||
mt, err := merkletree.NewMerkleTree(s.db.WithPrefix(PrefixKeyMT), s.mt.MaxLevels())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.mt = mt
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
checkpointPath := s.path + PathBatchNum + strconv.Itoa(int(batchNum))
|
||||
// copy 'BatchNumX' to 'current'
|
||||
err = pebbleMakeCheckpoint(checkpointPath, currentPath)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user