Skip to content

Commit 1a2a93a

Browse files
committed
MERGE-FIX: General fixes for functional tests
1 parent 3a83980 commit 1a2a93a

File tree

5 files changed

+53
-26
lines changed

5 files changed

+53
-26
lines changed

test/functional/combine_logs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def main():
2323
parser = argparse.ArgumentParser(usage='%(prog)s [options] <test temporary directory>', description=__doc__)
2424
parser.add_argument('-c', '--color', dest='color', action='store_true', help='outputs the combined log with events colored by source (requires posix terminal colors. Use less -r for viewing)')
2525
parser.add_argument('--html', dest='html', action='store_true', help='outputs the combined log as html. Requires jinja2. pip install jinja2')
26-
parser.add_argument('--chain', dest='chain', help='selected chain in the tests (default: regtest2)', default='regtest2')
26+
parser.add_argument('--chain', dest='chain', help='selected chain in the tests (default: elementsregtest)', default='elementsregtest')
2727
args, unknown_args = parser.parse_known_args()
2828

2929
if args.html and args.color:

test/functional/test_framework/messages.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,8 @@ def __repr__(self):
300300
OUTPOINT_INDEX_MASK = 0x3fffffff
301301

302302
class CAssetIssuance():
303+
__slots__ = ("assetBlindingNonce", "assetEntropy", "nAmount", "nInflationKeys")
304+
303305
def __init__(self):
304306
self.assetBlindingNonce = 0
305307
self.assetEntropy = 0
@@ -329,7 +331,7 @@ def __repr__(self):
329331
return "CAssetIssuance(assetBlindingNonce=%064x assetEntropy=%064x nAmount=%s nInflationKeys=%s)" % (self.assetBlindingNonce, self.assetEntropy, self.nAmount.vchCommitment, self.nInflationKeys.vchCommitment)
330332

331333
class CTxIn:
332-
__slots__ = ("nSequence", "prevout", "scriptSig")
334+
__slots__ = ("nSequence", "prevout", "scriptSig", "m_is_pegin", "assetIssuance")
333335

334336
def __init__(self, outpoint=None, scriptSig=b"", nSequence=0):
335337
if outpoint is None:
@@ -385,7 +387,9 @@ def __repr__(self):
385387
% (repr(self.prevout), bytes_to_hex_str(self.scriptSig),
386388
self.nSequence, self.m_is_pegin, self.assetIssuance)
387389

388-
class CTxOutAsset(object):
390+
class CTxOutAsset:
391+
__slots__ = ("vchCommitment")
392+
389393
def __init__(self, vchCommitment=b"\x00"):
390394
self.vchCommitment = vchCommitment
391395

@@ -418,7 +422,8 @@ def setToAsset(self, val):
418422
def __repr__(self):
419423
return "CTxOutAsset(vchCommitment=%s)" % self.vchCommitment
420424

421-
class CTxOutValue(object):
425+
class CTxOutValue:
426+
__slots__ = ("vchCommitment")
422427

423428
def __init__(self, value=None):
424429
self.setNull()
@@ -469,7 +474,9 @@ def getAmount(self):
469474
def __repr__(self):
470475
return "CTxOutValue(vchCommitment=%s)" % self.vchCommitment
471476

472-
class CTxOutNonce(object):
477+
class CTxOutNonce:
478+
__slots__ = ("vchCommitment")
479+
473480
def __init__(self, vchCommitment=b"\x00"):
474481
self.vchCommitment = vchCommitment
475482

@@ -499,7 +506,7 @@ def __repr__(self):
499506

500507

501508
class CTxOut():
502-
__slots__ = ("nValue", "scriptPubKey")
509+
__slots__ = ("nValue", "scriptPubKey", "nAsset", "nNonce")
503510

504511
def __init__(self, nValue=CTxOutValue(), scriptPubKey=b'', nAsset=CTxOutAsset(BITCOIN_ASSET_OUT), nNonce=CTxOutNonce()):
505512
self.nAsset = nAsset
@@ -559,7 +566,8 @@ def is_null(self):
559566

560567

561568
class CTxInWitness:
562-
__slots__ = ("scriptWitness",)
569+
__slots__ = ("scriptWitness", "vchIssuanceAmountRangeproof",
570+
"vchInflationKeysRangeproof", "peginWitness")
563571

564572
def __init__(self):
565573
self.vchIssuanceAmountRangeproof = b''
@@ -601,7 +609,9 @@ def is_null(self):
601609
and self.scriptWitness.is_null()
602610

603611

604-
class CTxOutWitness(object):
612+
class CTxOutWitness:
613+
__slots__ = ("vchSurjectionproof", "vchRangeproof")
614+
605615
def __init__(self):
606616
self.vchSurjectionproof = b''
607617
self.vchRangeproof = b''
@@ -632,7 +642,7 @@ def is_null(self):
632642

633643

634644
class CTxWitness:
635-
__slots__ = ("vtxinwit",)
645+
__slots__ = ("vtxinwit", "vtxoutwit")
636646

637647
def __init__(self):
638648
self.vtxinwit = []
@@ -793,7 +803,9 @@ def __repr__(self):
793803
% (self.nVersion, repr(self.vin), repr(self.vout), repr(self.wit), self.nLockTime)
794804

795805

796-
class CProof(object):
806+
class CProof:
807+
__slots__ = ("challenge", "solution")
808+
797809
# Default allows OP_TRUE blocks
798810
def __init__(self, challenge=bytearray.fromhex('51'), solution=b""):
799811
self.challenge = challenge
@@ -824,7 +836,7 @@ def __repr__(self):
824836

825837
class CBlockHeader:
826838
__slots__ = ("hash", "hashMerkleRoot", "hashPrevBlock", "nBits", "nNonce",
827-
"nTime", "nVersion", "sha256")
839+
"nTime", "nVersion", "sha256", "block_height", "proof")
828840

829841
def __init__(self, header=None):
830842
if header is None:

test/functional/test_framework/test_framework.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
8989

9090
def __init__(self):
9191
"""Sets test framework defaults. Do not override this method. Instead, override the set_test_params() method"""
92-
self.chain = 'regtest2'
92+
self.chain = 'elementsregtest'
9393
self.setup_clean_chain = False
9494
self.nodes = []
9595
self.network_thread = None

test/functional/test_framework/test_node.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,36 @@ def __init__(self, i, datadir, chain, *, rpchost, timewait, bitcoind, bitcoin_cl
101101

102102
self.p2ps = []
103103

104+
# ELEMENTS:
105+
self.deterministic_priv_key = None
106+
107+
def set_deterministic_priv_key(self, address, privkey):
108+
AddressKeyPair = collections.namedtuple('AddressKeyPair', ['address', 'key'])
109+
self.deterministic_priv_key = AddressKeyPair(address, privkey)
110+
104111
def get_deterministic_priv_key(self):
105112
"""Return a deterministic priv key in base58, that only depends on the node's index"""
113+
106114
AddressKeyPair = collections.namedtuple('AddressKeyPair', ['address', 'key'])
107115
PRIV_KEYS = [
108116
# address , privkey
109-
AddressKeyPair('mjTkW3DjgyZck4KbiRusZsqTgaYTxdSz6z', 'cVpF924EspNh8KjYsfhgY96mmxvT6DgdWiTYMtMjuM74hJaU5psW'),
110-
AddressKeyPair('msX6jQXvxiNhx3Q62PKeLPrhrqZQdSimTg', 'cUxsWyKyZ9MAQTaAhUQWJmBbSvHMwSmuv59KgxQV7oZQU3PXN3KE'),
111-
AddressKeyPair('mnonCMyH9TmAsSj3M59DsbH8H63U3RKoFP', 'cTrh7dkEAeJd6b3MRX9bZK8eRmNqVCMH3LSUkE3dSFDyzjU38QxK'),
112-
AddressKeyPair('mqJupas8Dt2uestQDvV2NH3RU8uZh2dqQR', 'cVuKKa7gbehEQvVq717hYcbE9Dqmq7KEBKqWgWrYBa2CKKrhtRim'),
113-
AddressKeyPair('msYac7Rvd5ywm6pEmkjyxhbCDKqWsVeYws', 'cQDCBuKcjanpXDpCqacNSjYfxeQj8G6CAtH1Dsk3cXyqLNC4RPuh'),
114-
AddressKeyPair('n2rnuUnwLgXqf9kk2kjvVm8R5BZK1yxQBi', 'cQakmfPSLSqKHyMFGwAqKHgWUiofJCagVGhiB4KCainaeCSxeyYq'),
115-
AddressKeyPair('myzuPxRwsf3vvGzEuzPfK9Nf2RfwauwYe6', 'cQMpDLJwA8DBe9NcQbdoSb1BhmFxVjWD5gRyrLZCtpuF9Zi3a9RK'),
116-
AddressKeyPair('mumwTaMtbxEPUswmLBBN3vM9oGRtGBrys8', 'cSXmRKXVcoouhNNVpcNKFfxsTsToY5pvB9DVsFksF1ENunTzRKsy'),
117-
AddressKeyPair('mpV7aGShMkJCZgbW7F6iZgrvuPHjZjH9qg', 'cSoXt6tm3pqy43UMabY6eUTmR3eSUYFtB2iNQDGgb3VUnRsQys2k'),
117+
AddressKeyPair('XLk5KrNPcrDQgX2VLZoWcarPhAdWiaT2kj', 'cUefCfa8BubvB647rZkJZx693KxHV6SYCnixB63GnDbAfeayrTZn'),
118+
AddressKeyPair('XNE8xf6DVprZ7uKeTF5D6fU2UV3JXgidky', 'cSV5h5frESA7GP1E7qUFFLr5GuJTqWH6sfvWhqhUk6viimDjGfhA'),
119+
AddressKeyPair('XX8fKzSef3pfhYn57UMUHVqF3i2ADEduKP', 'cPWfJTmzWJUD9evKEzTF8x7rjXRxnZcaPAjBYBck8yxiLgthUEFm'),
120+
AddressKeyPair('XM98ggwbX6JZv4baocdAg17Srvep8aUw5J', 'cUPkzzKWSTqTAtYanCJXC8e6LkLaxaqagcxAvbdJj7bN6rhfyJCS'),
121+
AddressKeyPair('XKbMRzP9735q3aQBne8KUSoXeopjVDsA4Q', 'cQVhmMSGoMSYTLPkQkqSpskosHwx8N7EZeFKJcJgfruPjiw8Q7tV'),
122+
AddressKeyPair('XD8eGQh8ihNzpTLrqErCJMFdm5W3yjrqyw', 'cQn4GB4xHcAwzAEsFfDUqvGGa6t4hpqxtrjAzj3T7UfYWdhzyEjg'),
123+
AddressKeyPair('XZzJC9V6tgP4G4dciz4McK9CHFYGA98hJ3', 'cUyxqmWmFGTFkd1H9AR4CJ9QpRKDC7nVEirSe79xMJ8MTv8rJAiT'),
124+
AddressKeyPair('XFPZFwRmVVW8LmmQoqUu81ynS3WHEbN11t', 'cMjyVk6QF2ffE7FrWM19jSNCs7VLdmdYQEDZ2BVfwXs8QCHmJ44c'),
125+
AddressKeyPair('XZY7RA4gkBErWUey3egGois93D11mA6zWj', 'cVXrhqnTc519sK8A1jsR1Zm7oBqDRbwkx7GMT3KZ78Dbv6e9vZef'),
118126
]
127+
128+
# ELEMENTS: this allows overriding the default for parent nodes in fedpeg test
129+
if self.deterministic_priv_key is not None:
130+
self.log.debug("Custom deterministic_priv_key: {}".format(self.deterministic_priv_key))
131+
return self.deterministic_priv_key
132+
assert(self.chain == "elementsregtest")
133+
119134
return PRIV_KEYS[self.index]
120135

121136
def get_mem_rss(self):
@@ -278,7 +293,7 @@ def wait_until_stopped(self, timeout=BITCOIND_PROC_WAIT_TIMEOUT):
278293

279294
@contextlib.contextmanager
280295
def assert_debug_log(self, expected_msgs):
281-
debug_log = os.path.join(self.datadir, 'regtest2', 'debug.log')
296+
debug_log = os.path.join(self.datadir, self.chain, 'debug.log')
282297
with open(debug_log, encoding='utf-8') as dl:
283298
dl.seek(0, 2)
284299
prev_size = dl.tell()

test/functional/test_framework/util.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
logger = logging.getLogger("TestFramework.utils")
2525

26-
BITCOIN_ASSET = "e08fa5a62d79b9e3f5f476743a5535512f0f44444533275a2adc5fe8476a2eac"
26+
BITCOIN_ASSET = "b2e15d0d7a0c94e4e2ce0fe6e8691b9e451377f6e46e8045a86f7c4b5d4f0f23"
2727
BITCOIN_ASSET_BYTES = bytearray.fromhex(BITCOIN_ASSET)
2828
BITCOIN_ASSET_BYTES.reverse()
2929
BITCOIN_ASSET_OUT = b"\x01"+BITCOIN_ASSET_BYTES
@@ -330,9 +330,9 @@ def initialize_datadir(dirname, n, chain):
330330
f.write("con_bip66height=1251\n")
331331
f.write("con_csv_deploy_start=0\n") # Enhance tests if removing this line
332332
f.write("blindedaddresses=0\n") # Set to minimize broken tests in favor of custom
333-
f.write("pubkeyprefix=111\n")
334-
f.write("scriptprefix=196\n")
335-
f.write("bech32_hrp=bcrt\n")
333+
#f.write("pubkeyprefix=111\n")
334+
#f.write("scriptprefix=196\n")
335+
#f.write("bech32_hrp=bcrt\n")
336336
os.makedirs(os.path.join(datadir, 'stderr'), exist_ok=True)
337337
os.makedirs(os.path.join(datadir, 'stdout'), exist_ok=True)
338338
return datadir

0 commit comments

Comments
 (0)