Merge pull request #39 from getamis/feature/TFS-02-04-Reduce-validator-network-size-below-3f-1

Implement TFU-02-04 Reduce validator network size but keep it more than 2F+1
This commit is contained in:
bailantaotao 2017-08-24 15:00:58 +08:00 committed by GitHub
commit 2a39a56650
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()
})
})
})
})