2017-08-22 00:44:43 -07:00
|
|
|
// Copyright 2017 AMIS Technologies
|
|
|
|
// This file is part of the go-ethereum library.
|
|
|
|
//
|
|
|
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2017-08-31 20:26:54 -07:00
|
|
|
package functional
|
2017-08-22 00:44:43 -07:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2017-08-23 02:04:33 -07:00
|
|
|
"sync"
|
2017-08-22 00:44:43 -07:00
|
|
|
|
|
|
|
. "github.com/onsi/ginkgo"
|
|
|
|
. "github.com/onsi/gomega"
|
|
|
|
|
|
|
|
"github.com/getamis/istanbul-tools/container"
|
2017-08-31 20:26:54 -07:00
|
|
|
"github.com/getamis/istanbul-tools/tests"
|
2017-08-22 00:44:43 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
var _ = Describe("TFS-07: Gossip Network", func() {
|
|
|
|
const (
|
|
|
|
numberOfValidators = 4
|
|
|
|
)
|
|
|
|
var (
|
|
|
|
blockchain container.Blockchain
|
|
|
|
)
|
|
|
|
|
|
|
|
BeforeEach(func() {
|
2017-09-01 01:52:08 -07:00
|
|
|
blockchain = container.NewDefaultBlockchain(dockerNetwork, numberOfValidators)
|
2017-08-22 00:44:43 -07:00
|
|
|
Expect(blockchain.Start(false)).To(BeNil())
|
|
|
|
})
|
|
|
|
|
|
|
|
AfterEach(func() {
|
|
|
|
Expect(blockchain.Stop(false)).To(BeNil())
|
|
|
|
blockchain.Finalize()
|
|
|
|
})
|
|
|
|
|
|
|
|
It("TFS-07-01: Gossip Network", func(done Done) {
|
|
|
|
By("Check peer count", func() {
|
|
|
|
for _, geth := range blockchain.Validators() {
|
2017-09-06 20:30:30 -07:00
|
|
|
c := geth.NewClient()
|
2017-08-22 00:44:43 -07:00
|
|
|
peers, e := c.AdminPeers(context.Background())
|
|
|
|
Expect(e).To(BeNil())
|
|
|
|
Ω(len(peers)).Should(BeNumerically("<=", 2))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
By("Checking blockchain progress", func() {
|
2017-08-31 20:26:54 -07:00
|
|
|
tests.WaitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) {
|
2017-08-23 02:04:33 -07:00
|
|
|
Expect(geth.WaitForBlocks(3)).To(BeNil())
|
|
|
|
wg.Done()
|
|
|
|
})
|
2017-08-22 00:44:43 -07:00
|
|
|
})
|
2017-08-23 02:04:33 -07:00
|
|
|
|
2017-08-22 00:44:43 -07:00
|
|
|
close(done)
|
|
|
|
}, 240)
|
|
|
|
})
|