You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.1 KiB
38 lines
1.1 KiB
package consensus
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/harmony-one/harmony/consensus/quorum"
|
|
"github.com/harmony-one/harmony/crypto/bls"
|
|
"github.com/harmony-one/harmony/internal/utils"
|
|
"github.com/harmony-one/harmony/multibls"
|
|
"github.com/harmony-one/harmony/p2p"
|
|
"github.com/harmony-one/harmony/p2p/p2pimpl"
|
|
"github.com/harmony-one/harmony/shard"
|
|
)
|
|
|
|
func TestNew(test *testing.T) {
|
|
leader := p2p.Peer{IP: "127.0.0.1", Port: "9902"}
|
|
priKey, _, _ := utils.GenKeyP2P("127.0.0.1", "9902")
|
|
host, err := p2pimpl.NewHost(&leader, priKey)
|
|
if err != nil {
|
|
test.Fatalf("newhost failure: %v", err)
|
|
}
|
|
decider := quorum.NewDecider(
|
|
quorum.SuperMajorityVote, shard.BeaconChainShardID,
|
|
)
|
|
consensus, err := New(
|
|
host, shard.BeaconChainShardID, leader, multibls.GetPrivateKey(bls.RandPrivateKey()), decider,
|
|
)
|
|
if err != nil {
|
|
test.Fatalf("Cannot craeate consensus: %v", err)
|
|
}
|
|
if consensus.viewID != 0 {
|
|
test.Errorf("Consensus Id is initialized to the wrong value: %d", consensus.viewID)
|
|
}
|
|
|
|
if consensus.ReadySignal == nil {
|
|
test.Error("Consensus ReadySignal should be initialized")
|
|
}
|
|
}
|
|
|