kaspad/domain/consensus/factory_test.go
Svarog 24c94b38be
Move OnBlockAdded event to the channel that was only used by virtualChanged events (#2059)
* Move OnBlockAdded event to the channel that was only used by virtualChanged events

* Don't send notifications for header-only and invalid blocks

* Return block status from block processor and use it for event raising decision

* Use MaybeEnqueue for consensus events

* go lint

* Fix RPC call to actually include tx ids

Co-authored-by: msutton <mikisiton2@gmail.com>
2022-05-24 01:11:01 +03:00

37 lines
759 B
Go

package consensus
import (
"io/ioutil"
"testing"
"github.com/kaspanet/kaspad/domain/prefixmanager/prefix"
"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{}, nil)
if err != nil {
t.Fatalf("error in NewConsensus: %+v", err)
}
if shouldMigrate {
t.Fatalf("A fresh consensus should never return shouldMigrate=true")
}
}