mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00

* 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>
37 lines
759 B
Go
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")
|
|
}
|
|
}
|