diff --git a/tests/dynamic_test.go b/tests/dynamic_test.go index 81d8dd75..2daf789d 100644 --- a/tests/dynamic_test.go +++ b/tests/dynamic_test.go @@ -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() + }) + }) + }) })