Skip to content

Commit

Permalink
fix: fmt error
Browse files Browse the repository at this point in the history
  • Loading branch information
Woosang Son committed Oct 30, 2020
1 parent 1403890 commit 3fd9d02
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 19 deletions.
4 changes: 2 additions & 2 deletions blockchain/v0/reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ func TestBadBlockStopsPeer(t *testing.T) {
config.P2P.RecvAsync, config.P2P.BlockchainRecvBufSize)
reactorPairs = append(reactorPairs, lastReactorPair)

switches = append(switches, p2p.MakeConnectedSwitches(config.P2P, 1,
func(i int, s *p2p.Switch, config *cfg.P2PConfig) *p2p.Switch {
switches = append(switches, p2p.MakeConnectedSwitches(config.P2P, 1, func(i int, s *p2p.Switch,
config *cfg.P2PConfig) *p2p.Switch {
s.AddReactor("BLOCKCHAIN", reactorPairs[len(reactorPairs)-1].reactor)
return s

Expand Down
8 changes: 4 additions & 4 deletions blockchain/v1/reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ func TestFastSyncBadBlockStopsPeer(t *testing.T) {
reactorPairs[i] = newBlockchainReactorPair(t, logger[i], genDoc, privVals, height)
}

switches := p2p.MakeConnectedSwitches(config.P2P, numNodes,
func(i int, s *p2p.Switch, config *cfg.P2PConfig) *p2p.Switch {
switches := p2p.MakeConnectedSwitches(config.P2P, numNodes, func(i int, s *p2p.Switch,
config *cfg.P2PConfig) *p2p.Switch {
reactorPairs[i].conR.mtx.Lock()
s.AddReactor("BLOCKCHAIN", reactorPairs[i].bcR)
s.AddReactor("CONSENSUS", reactorPairs[i].conR)
Expand Down Expand Up @@ -310,8 +310,8 @@ outerFor:
lastReactorPair := newBlockchainReactorPair(t, lastLogger, genDoc, privVals, 0)
reactorPairs = append(reactorPairs, lastReactorPair)

switches = append(switches, p2p.MakeConnectedSwitches(config.P2P, 1,
func(i int, s *p2p.Switch, config *cfg.P2PConfig) *p2p.Switch {
switches = append(switches, p2p.MakeConnectedSwitches(config.P2P, 1, func(i int, s *p2p.Switch,
config *cfg.P2PConfig) *p2p.Switch {
s.AddReactor("BLOCKCHAIN", reactorPairs[len(reactorPairs)-1].bcR)
s.AddReactor("CONSENSUS", reactorPairs[len(reactorPairs)-1].conR)
moduleName := fmt.Sprintf("blockchain-%v", len(reactorPairs)-1)
Expand Down
3 changes: 1 addition & 2 deletions consensus/byzantine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ func TestByzantine(t *testing.T) {
}
}()

p2p.MakeConnectedSwitches(config.P2P, N,
func(i int, s *p2p.Switch, config *config2.P2PConfig) *p2p.Switch {
p2p.MakeConnectedSwitches(config.P2P, N, func(i int, s *p2p.Switch, config *config2.P2PConfig) *p2p.Switch {
// ignore new switch s, we already made ours
switches[i].AddReactor("CONSENSUS", reactors[i])
return switches[i]
Expand Down
6 changes: 3 additions & 3 deletions p2p/base_reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ type Reactor interface {

type BaseReactor struct {
service.BaseService // Provides Start, Stop, .Quit
Switch *Switch
recvMsgBuf chan *BufferedMsg
impl Reactor
Switch *Switch
recvMsgBuf chan *BufferedMsg
impl Reactor
}

func NewBaseReactor(name string, impl Reactor, async bool, recvBufSize int) *BaseReactor {
Expand Down
8 changes: 4 additions & 4 deletions p2p/pex/pex_reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ func TestPEXReactorRunning(t *testing.T) {

// create switches
for i := 0; i < N; i++ {
switches[i] = p2p.MakeSwitch(cfg, i, "testing", "123.123.123",
func(i int, sw *p2p.Switch, config *config.P2PConfig) *p2p.Switch {
switches[i] = p2p.MakeSwitch(cfg, i, "testing", "123.123.123", func(i int, sw *p2p.Switch,
config *config.P2PConfig) *p2p.Switch {
books[i] = NewAddrBook(filepath.Join(dir, fmt.Sprintf("addrbook%d.json", i)), false)
books[i].SetLogger(logger.With("pex", i))
sw.SetAddrBook(books[i])
Expand Down Expand Up @@ -415,8 +415,8 @@ func TestPEXReactorSeedModeFlushStop(t *testing.T) {

// create switches
for i := 0; i < N; i++ {
switches[i] = p2p.MakeSwitch(cfg, i, "testing", "123.123.123",
func(i int, sw *p2p.Switch, config *config.P2PConfig) *p2p.Switch {
switches[i] = p2p.MakeSwitch(cfg, i, "testing", "123.123.123", func(i int, sw *p2p.Switch,
config *config.P2PConfig) *p2p.Switch {
books[i] = NewAddrBook(filepath.Join(dir, fmt.Sprintf("addrbook%d.json", i)), false)
books[i].SetLogger(logger.With("pex", i))
sw.SetAddrBook(books[i])
Expand Down
5 changes: 2 additions & 3 deletions p2p/switch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -689,11 +689,10 @@ func (r *mockReactor) InitCalledBeforeRemoveFinished() bool {
func TestSwitchInitPeerIsNotCalledBeforeRemovePeer(t *testing.T) {
// make reactor
reactor := &mockReactor{}
reactor.BaseReactor = NewBaseReactor("mockReactor", reactor, true,1000)
reactor.BaseReactor = NewBaseReactor("mockReactor", reactor, true, 1000)

// make switch
sw := MakeSwitch(cfg, 1, "testing", "123.123.123",
func(i int, sw *Switch, config *config.P2PConfig) *Switch {
sw := MakeSwitch(cfg, 1, "testing", "123.123.123", func(i int, sw *Switch, config *config.P2PConfig) *Switch {
sw.AddReactor("mock", reactor)
return sw
}) // mock reactor uses 1000 chan buffer
Expand Down
2 changes: 1 addition & 1 deletion rpc/core/net_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestUnsafeDialSeeds(t *testing.T) {

func TestUnsafeDialPeers(t *testing.T) {
sw := p2p.MakeSwitch(cfg.DefaultP2PConfig(), 1, "testing", "123.123.123",
func(n int, sw *p2p.Switch, config *cfg.P2PConfig) *p2p.Switch { return sw })
func(n int, sw *p2p.Switch, config *cfg.P2PConfig) *p2p.Switch { return sw })
err := sw.Start()
require.NoError(t, err)
defer sw.Stop()
Expand Down

0 comments on commit 3fd9d02

Please sign in to comment.