Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: respect P2PConfig fuzzing configuration in MultiplexTransport #1414

Merged
merged 2 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down
5 changes: 5 additions & 0 deletions p2p/conn/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions p2p/switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
5 changes: 5 additions & 0 deletions p2p/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading