From b6b76be226e9a2981c1fe9303b1ab6aee5667a64 Mon Sep 17 00:00:00 2001 From: Yute Lin Date: Tue, 22 Aug 2017 11:26:04 +0800 Subject: [PATCH] container: add force stop blockchain --- container/blockchain.go | 6 +++--- container/blockchain_test.go | 2 +- tests/integration_test.go | 2 +- tests/non_byzantine_faulty_test.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/container/blockchain.go b/container/blockchain.go index 18512d71..7814287d 100644 --- a/container/blockchain.go +++ b/container/blockchain.go @@ -32,7 +32,7 @@ import ( type Blockchain interface { Start() error - Stop() error + Stop(bool) error Validators() []Ethereum Finalize() } @@ -71,9 +71,9 @@ func (bc *blockchain) Start() error { return bc.connectAll() } -func (bc *blockchain) Stop() error { +func (bc *blockchain) Stop(force bool) error { for _, v := range bc.validators { - if err := v.Stop(); err != nil { + if err := v.Stop(); err != nil && !force { return err } } diff --git a/container/blockchain_test.go b/container/blockchain_test.go index 39540985..4412b011 100644 --- a/container/blockchain_test.go +++ b/container/blockchain_test.go @@ -43,7 +43,7 @@ func TestEthereumBlockchain(t *testing.T) { time.Sleep(5 * time.Second) - err = chain.Stop() + err = chain.Stop(false) if err != nil { t.Error(err) } diff --git a/tests/integration_test.go b/tests/integration_test.go index cd531850..03f0bf9c 100644 --- a/tests/integration_test.go +++ b/tests/integration_test.go @@ -56,7 +56,7 @@ var _ = Describe("4 validators Istanbul", func() { }) AfterEach(func() { - Expect(blockchain.Stop()).To(BeNil()) + Expect(blockchain.Stop(false)).To(BeNil()) blockchain.Finalize() }) diff --git a/tests/non_byzantine_faulty_test.go b/tests/non_byzantine_faulty_test.go index 9c5e1ff6..f410f978 100644 --- a/tests/non_byzantine_faulty_test.go +++ b/tests/non_byzantine_faulty_test.go @@ -55,7 +55,7 @@ var _ = Describe("TSU-04: Non-Byzantine Faulty", func() { }) AfterEach(func() { - blockchain.Stop() // This will return container not found error since we stop one + blockchain.Stop(true) // This will return container not found error since we stop one blockchain.Finalize() })