mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-31 00:05:13 +02:00
scripted-diff: replace remaining Python test equality asserts
Some Python functional tests still use plain `assert x == y`. The earlier commits convert the ambiguous assert patterns by hand, so this commit can rewrite the remaining safe cases mechanically. The verify script excludes `wallet_bumpfee.py`, `test_framework/netutil.py`, and `test_framework/authproxy.py`, which still contain assert forms that the plain line-based substitution would misidentify. -BEGIN VERIFY SCRIPT- perl -pi -e 's/^(\s*)assert (.+?) == ([^,#]+?)$/\1assert_equal(\2, \3)/' $(git ls-files -- 'test/functional' \ ':(exclude)test/functional/wallet_bumpfee.py' ':(exclude)test/functional/test_framework/netutil.py' ':(exclude)test/functional/test_framework/authproxy.py') -END VERIFY SCRIPT-
This commit is contained in:
@@ -105,7 +105,7 @@ class TestFrameworkEllSwift(unittest.TestCase):
|
||||
(FE(42), FE(0)), # t = 0
|
||||
(FE(5), FE(-132).sqrt()), # u^3 + t^2 + 7 = 0
|
||||
]
|
||||
assert undefined_inputs[-1][0]**3 + undefined_inputs[-1][1]**2 + 7 == 0
|
||||
assert_equal(undefined_inputs[-1][0]**3 + undefined_inputs[-1][1]**2 + 7, 0)
|
||||
for u, t in undefined_inputs:
|
||||
x = xswiftec(u, t)
|
||||
self.assertTrue(GE.is_valid_x(x))
|
||||
@@ -155,7 +155,7 @@ class TestFrameworkEllSwift(unittest.TestCase):
|
||||
reader = csv.DictReader(csvfile)
|
||||
for row in reader:
|
||||
encoding = bytes.fromhex(row['ellswift'])
|
||||
assert len(encoding) == 64
|
||||
assert_equal(len(encoding), 64)
|
||||
expected_x = FE(int(row['x'], 16))
|
||||
u = FE(int.from_bytes(encoding[:32], 'big'))
|
||||
t = FE(int.from_bytes(encoding[32:], 'big'))
|
||||
|
||||
@@ -179,7 +179,7 @@ class GE:
|
||||
# Initialize as point on the curve (and check that it is).
|
||||
fx = FE(x)
|
||||
fy = FE(y)
|
||||
assert fy**2 == fx**3 + 7
|
||||
assert_equal(fy**2, fx**3 + 7)
|
||||
self.infinity = False
|
||||
self.x = fx
|
||||
self.y = fy
|
||||
@@ -194,7 +194,7 @@ class GE:
|
||||
if self.x == a.x:
|
||||
if self.y != a.y:
|
||||
# A point added to its own negation is infinity.
|
||||
assert self.y + a.y == 0
|
||||
assert_equal(self.y + a.y, 0)
|
||||
return GE()
|
||||
else:
|
||||
# For identical inputs, use the tangent (doubling formula).
|
||||
@@ -292,7 +292,7 @@ class GE:
|
||||
@staticmethod
|
||||
def from_bytes_xonly(b):
|
||||
"""Convert a point given in xonly encoding to a group element."""
|
||||
assert len(b) == 32
|
||||
assert_equal(len(b), 32)
|
||||
x = FE.from_bytes(b)
|
||||
if x is None:
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user