diff --git a/mir_test.go b/mir_test.go index 900e268ee..61229f28f 100644 --- a/mir_test.go +++ b/mir_test.go @@ -14,9 +14,6 @@ import ( "path/filepath" "time" - "github.com/filecoin-project/mir/pkg/iss" - t "github.com/filecoin-project/mir/pkg/types" - . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -147,15 +144,6 @@ var _ = Describe("Basic test", func() { } }) - // Create an alternative ISS configuration for a 4-node deployment with a long batch timeout. - // It will be used to simulate one node being slow. - membership := make([]t.NodeID, 4) - for i := 0; i < len(membership); i++ { - membership[i] = t.NewNodeIDFromInt(i) - } - slowProposeConfig := iss.DefaultConfig(membership) - slowProposeConfig.MaxProposeDelay = 2 * time.Second - DescribeTable("Simple tests", testFunc, Entry("Does nothing with 1 node", &deploytest.TestConfig{ NumReplicas: 1, @@ -164,11 +152,11 @@ var _ = Describe("Basic test", func() { Duration: 4 * time.Second, }), Entry("Does nothing with 4 nodes", &deploytest.TestConfig{ - NumReplicas: 4, - Transport: "fake", - Directory: "", - Duration: 20 * time.Second, - FirstReplicaISSConfig: slowProposeConfig, + NumReplicas: 4, + Transport: "fake", + Directory: "", + Duration: 20 * time.Second, + SlowProposeReplicas: map[int]bool{0: true}, }), Entry("Submits 10 fake requests with 1 node", &deploytest.TestConfig{ NumReplicas: 1, @@ -186,13 +174,13 @@ var _ = Describe("Basic test", func() { Duration: 4 * time.Second, }), Entry("Submits 100 fake requests with 4 nodes", &deploytest.TestConfig{ - NumReplicas: 4, - NumClients: 0, - Transport: "fake", - NumFakeRequests: 100, - Directory: "", - Duration: 10 * time.Second, - FirstReplicaISSConfig: slowProposeConfig, + NumReplicas: 4, + NumClients: 0, + Transport: "fake", + NumFakeRequests: 100, + Directory: "", + Duration: 10 * time.Second, + SlowProposeReplicas: map[int]bool{0: true}, }), Entry("Submits 10 fake requests with 4 nodes and actual networking", &deploytest.TestConfig{ NumReplicas: 4, diff --git a/pkg/deploytest/deployment.go b/pkg/deploytest/deployment.go index 8ed1c29a3..70411e3e4 100644 --- a/pkg/deploytest/deployment.go +++ b/pkg/deploytest/deployment.go @@ -63,8 +63,8 @@ type TestConfig struct { // Duration after which the test deployment will be asked to shut down. Duration time.Duration - // If not nil, the TestReplica with ID 0 will use this ISS configuration instead of the default one. - FirstReplicaISSConfig *iss.Config + // A set of replicas that are slow in proposing batches that is likely to trigger view change. + SlowProposeReplicas map[int]bool // Logger to use for producing diagnostic messages. Logger logging.Logger @@ -128,13 +128,16 @@ func NewDeployment(testConfig *TestConfig) (*Deployment, error) { ) } - // Create instance of TestReplica. - // The first TestReplica might get a special ISS configuration. - // This is useful if one replica should do something else than the others during the test (e.g., fail). - var issConfig *iss.Config - if i == 0 { - issConfig = testConfig.FirstReplicaISSConfig + // ISS configuration + issConfig := iss.DefaultConfig(membership) + if testConfig.SlowProposeReplicas[i] { + // Increase MaxProposeDelay such that it is likely to trigger view change by the batch timeout. + // Since a sensible value for the segment timeout needs to be stricter than the batch timeout, + // in the worst case, it will trigger view change by the segment timeout. + issConfig.MaxProposeDelay = issConfig.PBFTViewChangeBatchTimeout } + + // Create instance of TestReplica. replicas[i] = &TestReplica{ ID: t.NewNodeIDFromInt(i), Config: config,