tests: reduce validator network size but keep it more than 2F+1

This commit is contained in:
Edwin 2017-08-24 14:52:31 +08:00
parent 6c7c38b7ed
commit 48dc093aa8
1 changed files with 36 additions and 1 deletions

View File

@ -18,8 +18,9 @@ package tests
import (
"context"
"time"
"math"
"sync"
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
@ -114,4 +115,38 @@ var _ = Describe("Dynamic validators addition/removal testing", func() {
Expect(blockchain.EnsureConsensusWorking(blockchain.Validators(), 30*time.Second)).Should(BeNil())
})
})
It("TFS-02-04 Reduce validator network size below 2F+1", func() {
By("Ensure that blocks are generated by validators", func() {
waitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) {
Expect(geth.WaitForBlocks(5)).To(BeNil())
wg.Done()
})
})
By("Reduce validator network size but keep it more than 2F+1", func() {
// stop validators [3]
stopCandidates := blockchain.Validators()[numberOfValidators-1:]
for _, candidates := range stopCandidates {
c := candidates.NewIstanbulClient()
Expect(c.StopMining(context.Background())).Should(BeNil())
}
})
By("Verify number of validators", func() {
for _, v := range blockchain.Validators() {
client := v.NewIstanbulClient()
validators, err := client.GetValidators(context.Background(), nil)
Expect(err).Should(BeNil())
Expect(len(validators)).Should(BeNumerically("==", numberOfValidators))
}
})
By("Ensure that blocks are generated by validators", func() {
waitFor(blockchain.Validators()[:numberOfValidators-1], func(geth container.Ethereum, wg *sync.WaitGroup) {
Expect(geth.WaitForBlocks(5)).To(BeNil())
wg.Done()
})
})
})
})