"github.com/tendermint/tmlibs/log"
)
+var (
+ sw *Switch
+)
+
func TestPEXReactorBasic(t *testing.T) {
assert, require := assert.New(t), require.New(t)
book := NewAddrBook(dir+"addrbook.json", true)
book.SetLogger(log.TestingLogger())
- r := NewPEXReactor(book)
+ r := NewPEXReactor(book, sw)
r.SetLogger(log.TestingLogger())
assert.NotNil(r)
book := NewAddrBook(dir+"addrbook.json", true)
book.SetLogger(log.TestingLogger())
- r := NewPEXReactor(book)
+ r := NewPEXReactor(book, sw)
r.SetLogger(log.TestingLogger())
size := book.Size()
switches[i] = makeSwitch(config, i, "127.0.0.1", "123.123.123", func(i int, sw *Switch) *Switch {
sw.SetLogger(log.TestingLogger().With("switch", i))
- r := NewPEXReactor(book)
+ r := NewPEXReactor(book, sw)
r.SetLogger(log.TestingLogger())
r.SetEnsurePeersPeriod(250 * time.Millisecond)
sw.AddReactor("pex", r)
for _, s := range switches {
addr, _ := NewNetAddressString(s.NodeInfo().ListenAddr)
book.AddAddress(addr, addr)
- s.AddListener(NewDefaultListener("tcp", s.NodeInfo().ListenAddr, true, log.TestingLogger()))
+ l, _ := NewDefaultListener("tcp", s.NodeInfo().ListenAddr, true, log.TestingLogger())
+ s.AddListener(l)
}
// start switches
book := NewAddrBook(dir+"addrbook.json", true)
book.SetLogger(log.TestingLogger())
- r := NewPEXReactor(book)
+ r := NewPEXReactor(book, sw)
r.SetLogger(log.TestingLogger())
peer := createRandomPeer(false)
book := NewAddrBook(dir+"addrbook.json", true)
book.SetLogger(log.TestingLogger())
- r := NewPEXReactor(book)
+ r := NewPEXReactor(book, sw)
r.SetLogger(log.TestingLogger())
r.SetMaxMsgCountByPeer(5)