Skip to content

Commit 50eb0c2

Browse files
sipaMarcoFalke
authored andcommitted
Small improvements to the Taproot functional tests
The "whitelist" and "connect_nodes" is not needed in feature_taproot.py, so remove it. The changes to key.py are required when running the unit tests from the test folder. Failure on current master: [test]$ python -m unittest functional/test_framework/key.py .E ====================================================================== ERROR: test_schnorr_testvectors (functional.test_framework.key.TestFrameworkKey) Implement the BIP340 test vectors (read from bip340_test_vectors.csv). ---------------------------------------------------------------------- Traceback (most recent call last): File "test/functional/test_framework/key.py", line 526, in test_schnorr_testvectors with open(os.path.join(sys.path[0], 'test_framework', 'bip340_test_vectors.csv'), newline='', encoding='utf8') as csvfile: FileNotFoundError: [Errno 2] No such file or directory: 'test/test_framework/bip340_test_vectors.csv' ---------------------------------------------------------------------- Ran 2 tests in 0.775s FAILED (errors=1)
1 parent fac865b commit 50eb0c2

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

test/functional/feature_taproot.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@ def set_test_params(self):
12001200
self.num_nodes = 2
12011201
self.setup_clean_chain = True
12021202
# Node 0 has Taproot inactive, Node 1 active.
1203-
self.extra_args = [["-whitelist=127.0.0.1", "-par=1", "-vbparams=taproot:1:1"], ["-whitelist=127.0.0.1", "-par=1"]]
1203+
self.extra_args = [["-par=1", "-vbparams=taproot:1:1"], ["-par=1"]]
12041204

12051205
def block_submit(self, node, txs, msg, err_msg, cb_pubkey=None, fees=0, sigops_weight=0, witness=False, accept=False):
12061206

@@ -1437,8 +1437,6 @@ def test_spenders(self, node, spenders, input_counts):
14371437
self.log.info(" - Done")
14381438

14391439
def run_test(self):
1440-
self.connect_nodes(0, 1)
1441-
14421440
# Post-taproot activation tests go first (pre-taproot tests' blocks are invalid post-taproot).
14431441
self.log.info("Post-activation tests...")
14441442
self.nodes[1].generate(101)

test/functional/test_framework/key.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import hashlib
1111
import os
1212
import random
13-
import sys
1413
import unittest
1514

1615
from .util import modinv
@@ -22,6 +21,7 @@ def TaggedHash(tag, data):
2221
return hashlib.sha256(ss).digest()
2322

2423
def xor_bytes(b0, b1):
24+
assert len(b0) == len(b1)
2525
return bytes(x ^ y for (x, y) in zip(b0, b1))
2626

2727
def jacobi_symbol(n, k):
@@ -523,7 +523,8 @@ def test_schnorr(self):
523523
def test_schnorr_testvectors(self):
524524
"""Implement the BIP340 test vectors (read from bip340_test_vectors.csv)."""
525525
num_tests = 0
526-
with open(os.path.join(sys.path[0], 'test_framework', 'bip340_test_vectors.csv'), newline='', encoding='utf8') as csvfile:
526+
vectors_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'bip340_test_vectors.csv')
527+
with open(vectors_file, newline='', encoding='utf8') as csvfile:
527528
reader = csv.reader(csvfile)
528529
next(reader)
529530
for row in reader:

0 commit comments

Comments
 (0)