From 50f2c277d763bf85ba6315b454f79839582dc207 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Tue, 5 Sep 2023 07:43:33 +0800 Subject: [PATCH] aezeed: fix flake in `TestDecipherIncorrectMnemonic` --- aezeed/cipherseed_test.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/aezeed/cipherseed_test.go b/aezeed/cipherseed_test.go index 7547f25e9..158b69bcf 100644 --- a/aezeed/cipherseed_test.go +++ b/aezeed/cipherseed_test.go @@ -533,7 +533,17 @@ func TestDecipherIncorrectMnemonic(t *testing.T) { // a checksum failure. swapIndex1 := 9 swapIndex2 := 13 - mnemonic[swapIndex1], mnemonic[swapIndex2] = mnemonic[swapIndex2], mnemonic[swapIndex1] + + mnemonic[swapIndex1], mnemonic[swapIndex2] = + mnemonic[swapIndex2], mnemonic[swapIndex1] + + // If the words happen to be the same by pure chance, we'll try again + // with different indexes. + if mnemonic[swapIndex1] == mnemonic[swapIndex2] { + swapIndex1 = 3 + mnemonic[swapIndex1], mnemonic[swapIndex2] = + mnemonic[swapIndex2], mnemonic[swapIndex1] + } // If we attempt to decrypt now, we should get a checksum failure. // If we attempt to map back to the original cipher seed now, then we