mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 22:18:54 +01:00
test: Rename early key response test and move random_bitflip to util
Early key response test is a special kind of test which requires modified v2 handshake functions. More such tests can be added where v2 handshake functions send incorrect garbage terminator, excess garbage bytes etc.. Hence, rename p2p_v2_earlykey.py to a general test file name - p2p_v2_misbehaving.py. random_bitflip function (used in signature tests prior to this commit) can be used in p2p_v2_misbehaving test to generate wrong garbage terminator, wrong garbage bytes etc.. So, move the function to util.
This commit is contained in:
@@ -14,6 +14,7 @@ import random
|
||||
import unittest
|
||||
|
||||
from test_framework.crypto import secp256k1
|
||||
from test_framework.util import random_bitflip
|
||||
|
||||
# Point with no known discrete log.
|
||||
H_POINT = "50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0"
|
||||
@@ -292,11 +293,6 @@ def sign_schnorr(key, msg, aux=None, flip_p=False, flip_r=False):
|
||||
class TestFrameworkKey(unittest.TestCase):
|
||||
def test_ecdsa_and_schnorr(self):
|
||||
"""Test the Python ECDSA and Schnorr implementations."""
|
||||
def random_bitflip(sig):
|
||||
sig = list(sig)
|
||||
sig[random.randrange(len(sig))] ^= (1 << (random.randrange(8)))
|
||||
return bytes(sig)
|
||||
|
||||
byte_arrays = [generate_privkey() for _ in range(3)] + [v.to_bytes(32, 'big') for v in [0, ORDER - 1, ORDER, 2**256 - 1]]
|
||||
keys = {}
|
||||
for privkey_bytes in byte_arrays: # build array of key/pubkey pairs
|
||||
|
||||
Reference in New Issue
Block a user