Skip to content

Commit 5e150ac

Browse files
committed
Prevent false-positive test failures in Test_CBitcoinSecret
Previously had a one-in-256 chance of the signature passing, thus failing the test!
1 parent d4f45f9 commit 5e150ac

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

bitcoin/tests/test_wallet.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,13 @@ def test_sign(self):
222222
self.assertTrue(key.pub.verify(hash, sig))
223223
self.assertTrue(IsLowDERSignature(sig))
224224

225-
# Check invalid hash returns false
225+
# Check that invalid hash returns false
226226
self.assertFalse(key.pub.verify(b'\xFF'*32, sig))
227-
# Check invalid signature returns false
228-
self.assertFalse(key.pub.verify(hash, sig[0:-1] + b'\x00'))
227+
228+
# Check that invalid signature returns false.
229+
#
230+
# Note the one-in-four-billion chance of a false positive :)
231+
self.assertFalse(key.pub.verify(hash, sig[0:-4] + b'\x00\x00\x00\x00'))
229232

230233
def test_sign_invalid_hash(self):
231234
key = CBitcoinSecret('5KJvsngHeMpm884wtkJNzQGaCErckhHJBGFsvd3VyK5qMZXj3hS')

0 commit comments

Comments
 (0)