kaspad/domain/consensus/factory_test.go
Ori Newman 58d627e05a
Unite reachability stores (#1963)
* Unite all reachability stores

* Upgrade script

* Fix tests

* Add UpdateReindexRoot to RebuildReachability

* Use dbTx when deleting reachability stores

* Use ghostdagDataWithoutPrunedBlocks when rebuilding reachability

* Use next tree ancestor wherever possible and avoid finality point search if the block is too close to pruning point

* Address the boundary case where the pruning point becomes the finality point

* some minor fixes

* Remove RebuildReachability and use manual syncing between old and new consensus for migration

* Remove sanity test (it failed when tips where not in the same order)

Co-authored-by: msutton <mikisiton2@gmail.com>
2022-03-27 21:23:03 +03:00

36 lines
753 B
Go

package consensus
import (
"github.com/kaspanet/kaspad/domain/prefixmanager/prefix"
"io/ioutil"
"testing"
"github.com/kaspanet/kaspad/domain/dagconfig"
"github.com/kaspanet/kaspad/infrastructure/db/database/ldb"
)
func TestNewConsensus(t *testing.T) {
f := NewFactory()
config := &Config{Params: dagconfig.DevnetParams}
tmpDir, err := ioutil.TempDir("", "TestNewConsensus")
if err != nil {
return
}
db, err := ldb.NewLevelDB(tmpDir, 8)
if err != nil {
t.Fatalf("error in NewLevelDB: %s", err)
}
_, shouldMigrate, err := f.NewConsensus(config, db, &prefix.Prefix{})
if err != nil {
t.Fatalf("error in NewConsensus: %+v", err)
}
if shouldMigrate {
t.Fatalf("A fresh consensus should never return shouldMigrate=true")
}
}