From 8362a1dec4699d34a6aea56bf657295c3b3a5585 Mon Sep 17 00:00:00 2001 From: jholdstock Date: Sun, 23 Aug 2026 12:07:48 +0800 Subject: [PATCH] mixclient: Override timeout and jitter for testing This reduces the total runtime for the mixclient package tests from ~975s to ~39s. --- mixing/mixclient/client.go | 4 +++- mixing/mixclient/client_test.go | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/mixing/mixclient/client.go b/mixing/mixclient/client.go index aa2fa1b782..e74191beeb 100644 --- a/mixing/mixclient/client.go +++ b/mixing/mixclient/client.go @@ -40,7 +40,9 @@ const MinPeers = mixing.MinPeers const pairingVersion byte = 3 -const ( +// durations below should be treated as constants, they are only variables so +// they can be overridden in tests. +var ( timeoutDuration = 30 * time.Second maxJitter = timeoutDuration / 10 msgJitter = 300 * time.Millisecond diff --git a/mixing/mixclient/client_test.go b/mixing/mixclient/client_test.go index dd1442daa5..b68a49a84b 100644 --- a/mixing/mixclient/client_test.go +++ b/mixing/mixclient/client_test.go @@ -174,6 +174,13 @@ func (w *testWallet) privForPkScript(p2pkhScript []byte) *secp256k1.PrivateKey { return w.privForHash160(hash160) } +func TestMain(t *testing.T) { + timeoutDuration = 1 * time.Second + maxJitter = timeoutDuration / 10 + msgJitter = 10 * time.Millisecond + peerJitter = maxJitter - msgJitter +} + func TestHonest(t *testing.T) { requireCsppsolver(t)