Skip to content

Commit af3f150

Browse files
committed
Add WithRaceDetection flag to integration tests
- Use EnableRaceDetector() after integration.New() to enable race detection - This approach allows platform factories to be registered before Generate() is called
1 parent a3e86c3 commit af3f150

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

integration/token/fungible/dlogx/dlog_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,14 @@ func newTestSuite(commType fsc.P2PCommunicationType, mask int, factor int, token
8989
FSCLogSpec: "grpc=error:info",
9090
TokenSelector: tokenSelector,
9191
})...)
92+
if err != nil {
93+
return nil, err
94+
}
95+
i.EnableRaceDetector()
9296
i.RegisterPlatformFactory(fabricx.NewPlatformFactory())
9397
i.RegisterPlatformFactory(token.NewPlatformFactory(i))
9498
i.Generate()
95-
return i, err
99+
return i, nil
96100
})
97101
return ts, selector
98102
}

integration/token/test_utils.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,12 @@ func replicaName(name string, idx int) string {
110110
func NewTestSuite(startPort func() int, topologies []api.Topology) *TestSuite {
111111
return &TestSuite{
112112
generator: func() (*integration.Infrastructure, error) {
113-
return integration.New(startPort(), "", topologies...)
113+
i, err := integration.New(startPort(), "", topologies...)
114+
if err != nil {
115+
return nil, err
116+
}
117+
i.EnableRaceDetector()
118+
return i, nil
114119
},
115120
}
116121
}
@@ -121,8 +126,12 @@ func NewLocalTestSuite(startPort func() int, topologies []api.Topology) *TestSui
121126
return &TestSuite{
122127
generator: func() (*integration.Infrastructure, error) {
123128
i, err := integration.New(startPort(), "./testdata", topologies...)
129+
if err != nil {
130+
return nil, err
131+
}
132+
i.EnableRaceDetector()
124133
i.DeleteOnStop = false
125-
return i, err
134+
return i, nil
126135
},
127136
}
128137
}

0 commit comments

Comments
 (0)