mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
eth: Lower bound on broadcast - fix gofmt
This commit is contained in:
parent
c91bd9891e
commit
2d9af032b3
1 changed files with 24 additions and 23 deletions
|
|
@ -17,7 +17,7 @@
|
||||||
package eth
|
package eth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"math/big"
|
"math/big"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
|
@ -243,10 +243,10 @@ func testGetBlockBodies(t *testing.T, protocol int) {
|
||||||
available []bool // Availability of explicitly requested blocks
|
available []bool // Availability of explicitly requested blocks
|
||||||
expected int // Total number of existing blocks to expect
|
expected int // Total number of existing blocks to expect
|
||||||
}{
|
}{
|
||||||
{1, nil, nil, 1}, // A single random block should be retrievable
|
{1, nil, nil, 1}, // A single random block should be retrievable
|
||||||
{10, nil, nil, 10}, // Multiple random blocks should be retrievable
|
{10, nil, nil, 10}, // Multiple random blocks should be retrievable
|
||||||
{limit, nil, nil, limit}, // The maximum possible blocks should be retrievable
|
{limit, nil, nil, limit}, // The maximum possible blocks should be retrievable
|
||||||
{limit + 1, nil, nil, limit}, // No more than the possible block count should be returned
|
{limit + 1, nil, nil, limit}, // No more than the possible block count should be returned
|
||||||
{0, []common.Hash{pm.blockchain.Genesis().Hash()}, []bool{true}, 1}, // The genesis block should be retrievable
|
{0, []common.Hash{pm.blockchain.Genesis().Hash()}, []bool{true}, 1}, // The genesis block should be retrievable
|
||||||
{0, []common.Hash{pm.blockchain.CurrentBlock().Hash()}, []bool{true}, 1}, // The chains head block should be retrievable
|
{0, []common.Hash{pm.blockchain.CurrentBlock().Hash()}, []bool{true}, 1}, // The chains head block should be retrievable
|
||||||
{0, []common.Hash{{}}, []bool{false}, 0}, // A non existent block should not be returned
|
{0, []common.Hash{{}}, []bool{false}, 0}, // A non existent block should not be returned
|
||||||
|
|
@ -467,12 +467,12 @@ func testDAOChallenge(t *testing.T, localForked, remoteForked bool, timeout bool
|
||||||
}
|
}
|
||||||
// Create a DAO aware protocol manager
|
// Create a DAO aware protocol manager
|
||||||
var (
|
var (
|
||||||
evmux = new(event.TypeMux)
|
evmux = new(event.TypeMux)
|
||||||
pow = ethash.NewFaker()
|
pow = ethash.NewFaker()
|
||||||
db = ethdb.NewMemDatabase()
|
db = ethdb.NewMemDatabase()
|
||||||
config = ¶ms.ChainConfig{DAOForkBlock: big.NewInt(1), DAOForkSupport: localForked}
|
config = ¶ms.ChainConfig{DAOForkBlock: big.NewInt(1), DAOForkSupport: localForked}
|
||||||
gspec = &core.Genesis{Config: config}
|
gspec = &core.Genesis{Config: config}
|
||||||
genesis = gspec.MustCommit(db)
|
genesis = gspec.MustCommit(db)
|
||||||
)
|
)
|
||||||
blockchain, err := core.NewBlockChain(db, nil, config, pow, vm.Config{}, nil)
|
blockchain, err := core.NewBlockChain(db, nil, config, pow, vm.Config{}, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -527,7 +527,7 @@ func testDAOChallenge(t *testing.T, localForked, remoteForked bool, timeout bool
|
||||||
|
|
||||||
func TestBroadcastBlock(t *testing.T) {
|
func TestBroadcastBlock(t *testing.T) {
|
||||||
var tests = []struct {
|
var tests = []struct {
|
||||||
totalPeers int
|
totalPeers int
|
||||||
broadcastExpected int
|
broadcastExpected int
|
||||||
}{
|
}{
|
||||||
{1, 1},
|
{1, 1},
|
||||||
|
|
@ -548,12 +548,12 @@ func TestBroadcastBlock(t *testing.T) {
|
||||||
|
|
||||||
func testBroadcastBlock(t *testing.T, totalPeers, broadcastExpected int) {
|
func testBroadcastBlock(t *testing.T, totalPeers, broadcastExpected int) {
|
||||||
var (
|
var (
|
||||||
evmux = new(event.TypeMux)
|
evmux = new(event.TypeMux)
|
||||||
pow = ethash.NewFaker()
|
pow = ethash.NewFaker()
|
||||||
db = ethdb.NewMemDatabase()
|
db = ethdb.NewMemDatabase()
|
||||||
config = ¶ms.ChainConfig{}
|
config = ¶ms.ChainConfig{}
|
||||||
gspec = &core.Genesis{Config: config}
|
gspec = &core.Genesis{Config: config}
|
||||||
genesis = gspec.MustCommit(db)
|
genesis = gspec.MustCommit(db)
|
||||||
)
|
)
|
||||||
blockchain, err := core.NewBlockChain(db, nil, config, pow, vm.Config{}, nil)
|
blockchain, err := core.NewBlockChain(db, nil, config, pow, vm.Config{}, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -585,18 +585,19 @@ func testBroadcastBlock(t *testing.T, totalPeers, broadcastExpected int) {
|
||||||
}
|
}
|
||||||
}(peer)
|
}(peer)
|
||||||
}
|
}
|
||||||
timeoutCh := time.NewTimer(time.Millisecond*100).C
|
timeoutCh := time.NewTimer(time.Millisecond * 100).C
|
||||||
var receivedCount int
|
var receivedCount int
|
||||||
outer: for {
|
outer:
|
||||||
|
for {
|
||||||
select {
|
select {
|
||||||
case err =<- errCh:
|
case err = <-errCh:
|
||||||
break outer
|
break outer
|
||||||
case <- doneCh:
|
case <-doneCh:
|
||||||
receivedCount++
|
receivedCount++
|
||||||
if receivedCount == totalPeers {
|
if receivedCount == totalPeers {
|
||||||
break outer
|
break outer
|
||||||
}
|
}
|
||||||
case <- timeoutCh:
|
case <-timeoutCh:
|
||||||
break outer
|
break outer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue