diff --git a/.github/workflows/fuzz-nightly.yml b/.github/workflows/fuzz-nightly.yml index 83f3abe27..75f734c3a 100644 --- a/.github/workflows/fuzz-nightly.yml +++ b/.github/workflows/fuzz-nightly.yml @@ -49,14 +49,14 @@ jobs: with: name: crashers path: test/fuzz/**/crashers - retention-days: 1 + retention-days: 3 - name: Archive suppressions uses: actions/upload-artifact@v2 with: name: suppressions path: test/fuzz/**/suppressions - retention-days: 1 + retention-days: 3 - name: Set crashers count working-directory: test/fuzz diff --git a/p2p/pex/pex_reactor_test.go b/p2p/pex/pex_reactor_test.go index 2e9523e80..02a3fcdee 100644 --- a/p2p/pex/pex_reactor_test.go +++ b/p2p/pex/pex_reactor_test.go @@ -91,7 +91,7 @@ func TestPEXReactorRunning(t *testing.T) { sw.AddReactor("pex", r) return sw - }) + }, logger) } for _, sw := range switches { @@ -406,7 +406,7 @@ func TestPEXReactorSeedModeFlushStop(t *testing.T) { sw.AddReactor("pex", r) return sw - }) + }, logger) } for _, sw := range switches { @@ -567,6 +567,7 @@ func testCreatePeerWithConfig(dir string, id int, config *ReactorConfig) *p2p.Sw sw.AddReactor("pex", r) return sw }, + log.TestingLogger(), ) return peer } @@ -600,6 +601,7 @@ func testCreateSeed(dir string, id int, knownAddrs, srcAddrs []*p2p.NetAddress) sw.AddReactor("pex", r) return sw }, + log.TestingLogger(), ) return seed } @@ -629,8 +631,7 @@ func createSwitchAndAddReactors(reactors ...p2p.Reactor) *p2p.Switch { sw.AddReactor(r.String(), r) } return sw - }) - sw.SetLogger(log.TestingLogger()) + }, log.TestingLogger()) return sw } diff --git a/p2p/shim_test.go b/p2p/shim_test.go index b91af366d..83fb7e382 100644 --- a/p2p/shim_test.go +++ b/p2p/shim_test.go @@ -61,7 +61,7 @@ func setup(t *testing.T, peers []p2p.Peer) *reactorShimTestSuite { sw.AddReactor(rts.shim.Name, rts.shim) return sw - }) + }, log.TestingLogger()) // start the reactor shim require.NoError(t, rts.shim.Start()) diff --git a/p2p/switch_test.go b/p2p/switch_test.go index db83bfd07..303d9d6f3 100644 --- a/p2p/switch_test.go +++ b/p2p/switch_test.go @@ -186,7 +186,7 @@ func assertMsgReceivedWithTimeout( } func TestSwitchFiltersOutItself(t *testing.T) { - s1 := MakeSwitch(cfg, 1, "127.0.0.1", "123.123.123", initSwitchFunc) + s1 := MakeSwitch(cfg, 1, "127.0.0.1", "123.123.123", initSwitchFunc, log.TestingLogger()) // simulate s1 having a public IP by creating a remote peer with the same ID rp := &remotePeer{PrivKey: s1.nodeKey.PrivKey, Config: cfg} @@ -225,6 +225,7 @@ func TestSwitchPeerFilter(t *testing.T) { "testing", "123.123.123", initSwitchFunc, + log.TestingLogger(), SwitchPeerFilters(filters...), ) ) @@ -280,6 +281,7 @@ func TestSwitchPeerFilterTimeout(t *testing.T) { "testing", "123.123.123", initSwitchFunc, + log.TestingLogger(), SwitchFilterTimeout(5*time.Millisecond), SwitchPeerFilters(filters...), ) @@ -319,7 +321,7 @@ func TestSwitchPeerFilterTimeout(t *testing.T) { } func TestSwitchPeerFilterDuplicate(t *testing.T) { - sw := MakeSwitch(cfg, 1, "testing", "123.123.123", initSwitchFunc) + sw := MakeSwitch(cfg, 1, "testing", "123.123.123", initSwitchFunc, log.TestingLogger()) err := sw.Start() require.NoError(t, err) t.Cleanup(func() { @@ -372,7 +374,7 @@ func assertNoPeersAfterTimeout(t *testing.T, sw *Switch, timeout time.Duration) func TestSwitchStopsNonPersistentPeerOnError(t *testing.T) { assert, require := assert.New(t), require.New(t) - sw := MakeSwitch(cfg, 1, "testing", "123.123.123", initSwitchFunc) + sw := MakeSwitch(cfg, 1, "testing", "123.123.123", initSwitchFunc, log.TestingLogger()) err := sw.Start() if err != nil { t.Error(err) @@ -471,7 +473,7 @@ func TestSwitchStopPeerForError(t *testing.T) { } func TestSwitchReconnectsToOutboundPersistentPeer(t *testing.T) { - sw := MakeSwitch(cfg, 1, "testing", "123.123.123", initSwitchFunc) + sw := MakeSwitch(cfg, 1, "testing", "123.123.123", initSwitchFunc, log.TestingLogger()) err := sw.Start() require.NoError(t, err) t.Cleanup(func() { @@ -521,7 +523,7 @@ func TestSwitchReconnectsToOutboundPersistentPeer(t *testing.T) { } func TestSwitchReconnectsToInboundPersistentPeer(t *testing.T) { - sw := MakeSwitch(cfg, 1, "testing", "123.123.123", initSwitchFunc) + sw := MakeSwitch(cfg, 1, "testing", "123.123.123", initSwitchFunc, log.TestingLogger()) err := sw.Start() require.NoError(t, err) t.Cleanup(func() { @@ -554,7 +556,7 @@ func TestSwitchDialPeersAsync(t *testing.T) { return } - sw := MakeSwitch(cfg, 1, "testing", "123.123.123", initSwitchFunc) + sw := MakeSwitch(cfg, 1, "testing", "123.123.123", initSwitchFunc, log.TestingLogger()) err := sw.Start() require.NoError(t, err) t.Cleanup(func() { @@ -620,7 +622,7 @@ func TestSwitchAcceptRoutine(t *testing.T) { } // make switch - sw := MakeSwitch(cfg, 1, "testing", "123.123.123", initSwitchFunc) + sw := MakeSwitch(cfg, 1, "testing", "123.123.123", initSwitchFunc, log.TestingLogger()) err := sw.AddUnconditionalPeerIDs(unconditionalPeerIDs) require.NoError(t, err) err = sw.Start() @@ -785,7 +787,7 @@ func TestSwitchInitPeerIsNotCalledBeforeRemovePeer(t *testing.T) { sw := MakeSwitch(cfg, 1, "testing", "123.123.123", func(i int, sw *Switch) *Switch { sw.AddReactor("mock", reactor) return sw - }) + }, log.TestingLogger()) err := sw.Start() require.NoError(t, err) t.Cleanup(func() { diff --git a/p2p/test_util.go b/p2p/test_util.go index 8b80034c3..83e1d9a42 100644 --- a/p2p/test_util.go +++ b/p2p/test_util.go @@ -71,7 +71,7 @@ func MakeConnectedSwitches(cfg *config.P2PConfig, ) []*Switch { switches := make([]*Switch, n) for i := 0; i < n; i++ { - switches[i] = MakeSwitch(cfg, i, TestHost, "123.123.123", initSwitch) + switches[i] = MakeSwitch(cfg, i, TestHost, "123.123.123", initSwitch, log.TestingLogger()) } if err := StartSwitches(switches); err != nil { @@ -163,6 +163,7 @@ func MakeSwitch( i int, network, version string, initSwitch func(int, *Switch) *Switch, + logger log.Logger, opts ...SwitchOption, ) *Switch { @@ -175,13 +176,13 @@ func MakeSwitch( panic(err) } - logger := log.TestingLogger().With("switch", i) - t := NewMConnTransport(logger, MConnConfig(cfg), + swLogger := logger.With("switch", i) + t := NewMConnTransport(swLogger, MConnConfig(cfg), []*ChannelDescriptor{}, MConnTransportOptions{}) // TODO: let the config be passed in? sw := initSwitch(i, NewSwitch(cfg, t, opts...)) - sw.SetLogger(log.TestingLogger().With("switch", i)) + sw.SetLogger(swLogger) sw.SetNodeKey(nodeKey) if err := t.Listen(addr.Endpoint()); err != nil { diff --git a/rpc/core/net_test.go b/rpc/core/net_test.go index c971776f3..ec91fb7e6 100644 --- a/rpc/core/net_test.go +++ b/rpc/core/net_test.go @@ -14,7 +14,7 @@ import ( func TestUnsafeDialSeeds(t *testing.T) { sw := p2p.MakeSwitch(cfg.DefaultP2PConfig(), 1, "testing", "123.123.123", - func(n int, sw *p2p.Switch) *p2p.Switch { return sw }) + func(n int, sw *p2p.Switch) *p2p.Switch { return sw }, log.TestingLogger()) err := sw.Start() require.NoError(t, err) t.Cleanup(func() { @@ -48,7 +48,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) *p2p.Switch { return sw }) + func(n int, sw *p2p.Switch) *p2p.Switch { return sw }, log.TestingLogger()) sw.SetAddrBook(&p2p.AddrBookMock{ Addrs: make(map[string]struct{}), OurAddrs: make(map[string]struct{}), diff --git a/test/fuzz/p2p/pex/reactor_receive.go b/test/fuzz/p2p/pex/reactor_receive.go index 37853810f..30b076eb4 100644 --- a/test/fuzz/p2p/pex/reactor_receive.go +++ b/test/fuzz/p2p/pex/reactor_receive.go @@ -2,6 +2,7 @@ package pex import ( "net" + "os" "github.com/tendermint/tendermint/config" "github.com/tendermint/tendermint/crypto/ed25519" @@ -13,8 +14,9 @@ import ( ) var ( - pexR *pex.Reactor - peer p2p.Peer + pexR *pex.Reactor + peer p2p.Peer + logger = log.NewTMLogger(log.NewSyncWriter(os.Stdout)) ) func init() { @@ -23,19 +25,22 @@ func init() { if pexR == nil { panic("NewReactor returned nil") } - pexR.SetLogger(log.NewNopLogger()) + pexR.SetLogger(logger) peer := newFuzzPeer() pexR.AddPeer(peer) - } func Fuzz(data []byte) int { + if len(data) == 0 { + return -1 + } + // MakeSwitch uses log.TestingLogger which can't be executed in init() cfg := config.DefaultP2PConfig() cfg.PexReactor = true sw := p2p.MakeSwitch(cfg, 0, "127.0.0.1", "123.123.123", func(i int, sw *p2p.Switch) *p2p.Switch { return sw - }) + }, logger) pexR.SetSwitch(sw) pexR.Receive(pex.PexChannel, peer, data) @@ -64,7 +69,7 @@ var defaultNodeInfo = p2p.NodeInfo{ 0, ), NodeID: nodeID, - ListenAddr: "0.0.0.0:98992", + ListenAddr: "0.0.0.0:8992", Moniker: "foo1", }