diff --git a/config/config.go b/config/config.go index 5c44c55eac1..d631ed388f9 100644 --- a/config/config.go +++ b/config/config.go @@ -735,7 +735,7 @@ type P2PConfig struct { //nolint: maligned // Testing params. // Force dial to fail TestDialFail bool `mapstructure:"test_dial_fail"` - // FUzz connection + // Fuzz connection TestFuzz bool `mapstructure:"test_fuzz"` TestFuzzConfig *FuzzConnConfig `mapstructure:"test_fuzz_config"` } diff --git a/p2p/conn/connection.go b/p2p/conn/connection.go index df783753d49..7bd8e34dc13 100644 --- a/p2p/conn/connection.go +++ b/p2p/conn/connection.go @@ -14,6 +14,7 @@ import ( "github.com/cosmos/gogoproto/proto" + "github.com/cometbft/cometbft/config" flow "github.com/cometbft/cometbft/libs/flowrate" "github.com/cometbft/cometbft/libs/log" cmtmath "github.com/cometbft/cometbft/libs/math" @@ -136,6 +137,10 @@ type MConnConfig struct { // Maximum wait time for pongs PongTimeout time.Duration `mapstructure:"pong_timeout"` + + // Fuzz connection + TestFuzz bool `mapstructure:"test_fuzz"` + TestFuzzConfig *config.FuzzConnConfig `mapstructure:"test_fuzz_config"` } // DefaultMConnConfig returns the default config. diff --git a/p2p/switch.go b/p2p/switch.go index 71586d27790..68ad5669b3e 100644 --- a/p2p/switch.go +++ b/p2p/switch.go @@ -39,6 +39,8 @@ func MConnConfig(cfg *config.P2PConfig) conn.MConnConfig { mConfig.SendRate = cfg.SendRate mConfig.RecvRate = cfg.RecvRate mConfig.MaxPacketMsgPayloadSize = cfg.MaxPacketMsgPayloadSize + mConfig.TestFuzz = cfg.TestFuzz + mConfig.TestFuzzConfig = cfg.TestFuzzConfig return mConfig } diff --git a/p2p/transport.go b/p2p/transport.go index 96d3738d662..d6043da3beb 100644 --- a/p2p/transport.go +++ b/p2p/transport.go @@ -218,6 +218,11 @@ func (mt *MultiplexTransport) Dial( return nil, err } + if mt.mConfig.TestFuzz { + // so we have time to do peer handshakes and get set up. + c = FuzzConnAfterFromConfig(c, 10*time.Second, mt.mConfig.TestFuzzConfig) + } + // TODO(xla): Evaluate if we should apply filters if we explicitly dial. if err := mt.filterConn(c); err != nil { return nil, err