Skip to content

Commit 8362a1d

Browse files
committed
mixclient: Override timeout and jitter for testing
This reduces the total runtime for the mixclient package tests from ~975s to ~39s.
1 parent 036b709 commit 8362a1d

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

mixing/mixclient/client.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ const MinPeers = mixing.MinPeers
4040

4141
const pairingVersion byte = 3
4242

43-
const (
43+
// durations below should be treated as constants, they are only variables so
44+
// they can be overridden in tests.
45+
var (
4446
timeoutDuration = 30 * time.Second
4547
maxJitter = timeoutDuration / 10
4648
msgJitter = 300 * time.Millisecond

mixing/mixclient/client_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,13 @@ func (w *testWallet) privForPkScript(p2pkhScript []byte) *secp256k1.PrivateKey {
174174
return w.privForHash160(hash160)
175175
}
176176

177+
func TestMain(t *testing.T) {
178+
timeoutDuration = 1 * time.Second
179+
maxJitter = timeoutDuration / 10
180+
msgJitter = 10 * time.Millisecond
181+
peerJitter = maxJitter - msgJitter
182+
}
183+
177184
func TestHonest(t *testing.T) {
178185
requireCsppsolver(t)
179186

0 commit comments

Comments
 (0)