aboutsummaryrefslogtreecommitdiffstats
path: root/integration_test/byzantine_test.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2019-03-25 10:14:42 +0800
committerJimmy Hu <jimmy.hu@dexon.org>2019-03-27 15:25:10 +0800
commitb8ced165b1fb03394f8758e08148b0e5d06aa07b (patch)
treefa327764a4cf564bb4aa39c1570ffd7f292c7ba1 /integration_test/byzantine_test.go
parent6efe199cb38eb4cb9a9a64d98ff5f8c4fb997da7 (diff)
downloaddexon-consensus-b8ced165b1fb03394f8758e08148b0e5d06aa07b.tar.gz
dexon-consensus-b8ced165b1fb03394f8758e08148b0e5d06aa07b.tar.zst
dexon-consensus-b8ced165b1fb03394f8758e08148b0e5d06aa07b.zip
core: Remove agreement result (#514)
* core: remove agreement result for round with randomness * remove agr test in syncer * fixup * remove randomness field from agreement result * modify test
Diffstat (limited to 'integration_test/byzantine_test.go')
-rw-r--r--integration_test/byzantine_test.go66
1 files changed, 66 insertions, 0 deletions
diff --git a/integration_test/byzantine_test.go b/integration_test/byzantine_test.go
index 3aea057..62dfe7a 100644
--- a/integration_test/byzantine_test.go
+++ b/integration_test/byzantine_test.go
@@ -191,6 +191,72 @@ Loop:
s.verifyNodes(nodes)
}
+type voteCensor struct{}
+
+func (vc *voteCensor) Censor(msg interface{}) bool {
+ _, ok := msg.(*types.Vote)
+ return ok
+}
+
+func (s *ByzantineTestSuite) TestOneNodeWithoutVote() {
+ // 4 nodes setup with one node's votes been censored.
+ // so it will always do syncing BA.
+ var (
+ req = s.Require()
+ peerCount = 4
+ dMoment = time.Now().UTC()
+ untilRound = uint64(3)
+ tolerence = uint64(2)
+ )
+ if testing.Short() {
+ untilRound = 2
+ }
+ prvKeys, pubKeys, err := test.NewKeys(peerCount)
+ req.NoError(err)
+ // Setup seed governance instance. Give a short latency to make this test
+ // run faster.
+ lambda := 100 * time.Millisecond
+ seedGov, err := test.NewGovernance(
+ test.NewState(core.DKGDelayRound,
+ pubKeys, lambda, &common.NullLogger{}, true),
+ core.ConfigRoundShift)
+ req.NoError(err)
+ req.NoError(seedGov.State().RequestChange(
+ test.StateChangeRoundLength, uint64(100)))
+ votelessNodeID := types.NewNodeID(pubKeys[0])
+ nodes := s.setupNodes(dMoment, prvKeys, seedGov)
+ votelessNode := nodes[votelessNodeID]
+ votelessNode.network.SetCensor(&voteCensor{}, &voteCensor{})
+ for _, n := range nodes {
+ go n.con.Run()
+ defer n.con.Stop()
+ }
+Loop:
+ for {
+ <-time.After(5 * time.Second)
+ fmt.Println("check latest position delivered by voteless node")
+ latestPos := votelessNode.app.GetLatestDeliveredPosition()
+ fmt.Println("latestPos", votelessNode.ID, &latestPos)
+ for _, n := range nodes {
+ if n.ID == votelessNodeID {
+ continue
+ }
+ otherPos := n.app.GetLatestDeliveredPosition()
+ if otherPos.Newer(latestPos) {
+ fmt.Println("otherPos", n.ID, &otherPos)
+ s.Require().True(
+ otherPos.Height-latestPos.Height <= tolerence)
+ }
+ }
+ if latestPos.Round < untilRound {
+ continue Loop
+ }
+ // Oh ya.
+ break
+ }
+ s.verifyNodes(nodes)
+}
+
func TestByzantine(t *testing.T) {
suite.Run(t, new(ByzantineTestSuite))
}