mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-13 12:33:42 +02:00
MERGE-FIX: General fixes for functional tests
This commit is contained in:
parent
3a8398024f
commit
1a2a93a5ff
5 changed files with 53 additions and 26 deletions
|
|
@ -23,7 +23,7 @@ def main():
|
|||
parser = argparse.ArgumentParser(usage='%(prog)s [options] <test temporary directory>', description=__doc__)
|
||||
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)')
|
||||
parser.add_argument('--html', dest='html', action='store_true', help='outputs the combined log as html. Requires jinja2. pip install jinja2')
|
||||
parser.add_argument('--chain', dest='chain', help='selected chain in the tests (default: regtest2)', default='regtest2')
|
||||
parser.add_argument('--chain', dest='chain', help='selected chain in the tests (default: elementsregtest)', default='elementsregtest')
|
||||
args, unknown_args = parser.parse_known_args()
|
||||
|
||||
if args.html and args.color:
|
||||
|
|
|
|||
|
|
@ -300,6 +300,8 @@ OUTPOINT_PEGIN_FLAG = (1 << 30)
|
|||
OUTPOINT_INDEX_MASK = 0x3fffffff
|
||||
|
||||
class CAssetIssuance():
|
||||
__slots__ = ("assetBlindingNonce", "assetEntropy", "nAmount", "nInflationKeys")
|
||||
|
||||
def __init__(self):
|
||||
self.assetBlindingNonce = 0
|
||||
self.assetEntropy = 0
|
||||
|
|
@ -329,7 +331,7 @@ class CAssetIssuance():
|
|||
return "CAssetIssuance(assetBlindingNonce=%064x assetEntropy=%064x nAmount=%s nInflationKeys=%s)" % (self.assetBlindingNonce, self.assetEntropy, self.nAmount.vchCommitment, self.nInflationKeys.vchCommitment)
|
||||
|
||||
class CTxIn:
|
||||
__slots__ = ("nSequence", "prevout", "scriptSig")
|
||||
__slots__ = ("nSequence", "prevout", "scriptSig", "m_is_pegin", "assetIssuance")
|
||||
|
||||
def __init__(self, outpoint=None, scriptSig=b"", nSequence=0):
|
||||
if outpoint is None:
|
||||
|
|
@ -385,7 +387,9 @@ class CTxIn:
|
|||
% (repr(self.prevout), bytes_to_hex_str(self.scriptSig),
|
||||
self.nSequence, self.m_is_pegin, self.assetIssuance)
|
||||
|
||||
class CTxOutAsset(object):
|
||||
class CTxOutAsset:
|
||||
__slots__ = ("vchCommitment")
|
||||
|
||||
def __init__(self, vchCommitment=b"\x00"):
|
||||
self.vchCommitment = vchCommitment
|
||||
|
||||
|
|
@ -418,7 +422,8 @@ class CTxOutAsset(object):
|
|||
def __repr__(self):
|
||||
return "CTxOutAsset(vchCommitment=%s)" % self.vchCommitment
|
||||
|
||||
class CTxOutValue(object):
|
||||
class CTxOutValue:
|
||||
__slots__ = ("vchCommitment")
|
||||
|
||||
def __init__(self, value=None):
|
||||
self.setNull()
|
||||
|
|
@ -469,7 +474,9 @@ class CTxOutValue(object):
|
|||
def __repr__(self):
|
||||
return "CTxOutValue(vchCommitment=%s)" % self.vchCommitment
|
||||
|
||||
class CTxOutNonce(object):
|
||||
class CTxOutNonce:
|
||||
__slots__ = ("vchCommitment")
|
||||
|
||||
def __init__(self, vchCommitment=b"\x00"):
|
||||
self.vchCommitment = vchCommitment
|
||||
|
||||
|
|
@ -499,7 +506,7 @@ class CTxOutNonce(object):
|
|||
|
||||
|
||||
class CTxOut():
|
||||
__slots__ = ("nValue", "scriptPubKey")
|
||||
__slots__ = ("nValue", "scriptPubKey", "nAsset", "nNonce")
|
||||
|
||||
def __init__(self, nValue=CTxOutValue(), scriptPubKey=b'', nAsset=CTxOutAsset(BITCOIN_ASSET_OUT), nNonce=CTxOutNonce()):
|
||||
self.nAsset = nAsset
|
||||
|
|
@ -559,7 +566,8 @@ class CScriptWitness:
|
|||
|
||||
|
||||
class CTxInWitness:
|
||||
__slots__ = ("scriptWitness",)
|
||||
__slots__ = ("scriptWitness", "vchIssuanceAmountRangeproof",
|
||||
"vchInflationKeysRangeproof", "peginWitness")
|
||||
|
||||
def __init__(self):
|
||||
self.vchIssuanceAmountRangeproof = b''
|
||||
|
|
@ -601,7 +609,9 @@ class CTxInWitness:
|
|||
and self.scriptWitness.is_null()
|
||||
|
||||
|
||||
class CTxOutWitness(object):
|
||||
class CTxOutWitness:
|
||||
__slots__ = ("vchSurjectionproof", "vchRangeproof")
|
||||
|
||||
def __init__(self):
|
||||
self.vchSurjectionproof = b''
|
||||
self.vchRangeproof = b''
|
||||
|
|
@ -632,7 +642,7 @@ class CTxOutWitness(object):
|
|||
|
||||
|
||||
class CTxWitness:
|
||||
__slots__ = ("vtxinwit",)
|
||||
__slots__ = ("vtxinwit", "vtxoutwit")
|
||||
|
||||
def __init__(self):
|
||||
self.vtxinwit = []
|
||||
|
|
@ -793,7 +803,9 @@ class CTransaction:
|
|||
% (self.nVersion, repr(self.vin), repr(self.vout), repr(self.wit), self.nLockTime)
|
||||
|
||||
|
||||
class CProof(object):
|
||||
class CProof:
|
||||
__slots__ = ("challenge", "solution")
|
||||
|
||||
# Default allows OP_TRUE blocks
|
||||
def __init__(self, challenge=bytearray.fromhex('51'), solution=b""):
|
||||
self.challenge = challenge
|
||||
|
|
@ -824,7 +836,7 @@ class CProof(object):
|
|||
|
||||
class CBlockHeader:
|
||||
__slots__ = ("hash", "hashMerkleRoot", "hashPrevBlock", "nBits", "nNonce",
|
||||
"nTime", "nVersion", "sha256")
|
||||
"nTime", "nVersion", "sha256", "block_height", "proof")
|
||||
|
||||
def __init__(self, header=None):
|
||||
if header is None:
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
|||
|
||||
def __init__(self):
|
||||
"""Sets test framework defaults. Do not override this method. Instead, override the set_test_params() method"""
|
||||
self.chain = 'regtest2'
|
||||
self.chain = 'elementsregtest'
|
||||
self.setup_clean_chain = False
|
||||
self.nodes = []
|
||||
self.network_thread = None
|
||||
|
|
|
|||
|
|
@ -101,21 +101,36 @@ class TestNode():
|
|||
|
||||
self.p2ps = []
|
||||
|
||||
# ELEMENTS:
|
||||
self.deterministic_priv_key = None
|
||||
|
||||
def set_deterministic_priv_key(self, address, privkey):
|
||||
AddressKeyPair = collections.namedtuple('AddressKeyPair', ['address', 'key'])
|
||||
self.deterministic_priv_key = AddressKeyPair(address, privkey)
|
||||
|
||||
def get_deterministic_priv_key(self):
|
||||
"""Return a deterministic priv key in base58, that only depends on the node's index"""
|
||||
|
||||
AddressKeyPair = collections.namedtuple('AddressKeyPair', ['address', 'key'])
|
||||
PRIV_KEYS = [
|
||||
# address , privkey
|
||||
AddressKeyPair('mjTkW3DjgyZck4KbiRusZsqTgaYTxdSz6z', 'cVpF924EspNh8KjYsfhgY96mmxvT6DgdWiTYMtMjuM74hJaU5psW'),
|
||||
AddressKeyPair('msX6jQXvxiNhx3Q62PKeLPrhrqZQdSimTg', 'cUxsWyKyZ9MAQTaAhUQWJmBbSvHMwSmuv59KgxQV7oZQU3PXN3KE'),
|
||||
AddressKeyPair('mnonCMyH9TmAsSj3M59DsbH8H63U3RKoFP', 'cTrh7dkEAeJd6b3MRX9bZK8eRmNqVCMH3LSUkE3dSFDyzjU38QxK'),
|
||||
AddressKeyPair('mqJupas8Dt2uestQDvV2NH3RU8uZh2dqQR', 'cVuKKa7gbehEQvVq717hYcbE9Dqmq7KEBKqWgWrYBa2CKKrhtRim'),
|
||||
AddressKeyPair('msYac7Rvd5ywm6pEmkjyxhbCDKqWsVeYws', 'cQDCBuKcjanpXDpCqacNSjYfxeQj8G6CAtH1Dsk3cXyqLNC4RPuh'),
|
||||
AddressKeyPair('n2rnuUnwLgXqf9kk2kjvVm8R5BZK1yxQBi', 'cQakmfPSLSqKHyMFGwAqKHgWUiofJCagVGhiB4KCainaeCSxeyYq'),
|
||||
AddressKeyPair('myzuPxRwsf3vvGzEuzPfK9Nf2RfwauwYe6', 'cQMpDLJwA8DBe9NcQbdoSb1BhmFxVjWD5gRyrLZCtpuF9Zi3a9RK'),
|
||||
AddressKeyPair('mumwTaMtbxEPUswmLBBN3vM9oGRtGBrys8', 'cSXmRKXVcoouhNNVpcNKFfxsTsToY5pvB9DVsFksF1ENunTzRKsy'),
|
||||
AddressKeyPair('mpV7aGShMkJCZgbW7F6iZgrvuPHjZjH9qg', 'cSoXt6tm3pqy43UMabY6eUTmR3eSUYFtB2iNQDGgb3VUnRsQys2k'),
|
||||
AddressKeyPair('XLk5KrNPcrDQgX2VLZoWcarPhAdWiaT2kj', 'cUefCfa8BubvB647rZkJZx693KxHV6SYCnixB63GnDbAfeayrTZn'),
|
||||
AddressKeyPair('XNE8xf6DVprZ7uKeTF5D6fU2UV3JXgidky', 'cSV5h5frESA7GP1E7qUFFLr5GuJTqWH6sfvWhqhUk6viimDjGfhA'),
|
||||
AddressKeyPair('XX8fKzSef3pfhYn57UMUHVqF3i2ADEduKP', 'cPWfJTmzWJUD9evKEzTF8x7rjXRxnZcaPAjBYBck8yxiLgthUEFm'),
|
||||
AddressKeyPair('XM98ggwbX6JZv4baocdAg17Srvep8aUw5J', 'cUPkzzKWSTqTAtYanCJXC8e6LkLaxaqagcxAvbdJj7bN6rhfyJCS'),
|
||||
AddressKeyPair('XKbMRzP9735q3aQBne8KUSoXeopjVDsA4Q', 'cQVhmMSGoMSYTLPkQkqSpskosHwx8N7EZeFKJcJgfruPjiw8Q7tV'),
|
||||
AddressKeyPair('XD8eGQh8ihNzpTLrqErCJMFdm5W3yjrqyw', 'cQn4GB4xHcAwzAEsFfDUqvGGa6t4hpqxtrjAzj3T7UfYWdhzyEjg'),
|
||||
AddressKeyPair('XZzJC9V6tgP4G4dciz4McK9CHFYGA98hJ3', 'cUyxqmWmFGTFkd1H9AR4CJ9QpRKDC7nVEirSe79xMJ8MTv8rJAiT'),
|
||||
AddressKeyPair('XFPZFwRmVVW8LmmQoqUu81ynS3WHEbN11t', 'cMjyVk6QF2ffE7FrWM19jSNCs7VLdmdYQEDZ2BVfwXs8QCHmJ44c'),
|
||||
AddressKeyPair('XZY7RA4gkBErWUey3egGois93D11mA6zWj', 'cVXrhqnTc519sK8A1jsR1Zm7oBqDRbwkx7GMT3KZ78Dbv6e9vZef'),
|
||||
]
|
||||
|
||||
# ELEMENTS: this allows overriding the default for parent nodes in fedpeg test
|
||||
if self.deterministic_priv_key is not None:
|
||||
self.log.debug("Custom deterministic_priv_key: {}".format(self.deterministic_priv_key))
|
||||
return self.deterministic_priv_key
|
||||
assert(self.chain == "elementsregtest")
|
||||
|
||||
return PRIV_KEYS[self.index]
|
||||
|
||||
def get_mem_rss(self):
|
||||
|
|
@ -278,7 +293,7 @@ class TestNode():
|
|||
|
||||
@contextlib.contextmanager
|
||||
def assert_debug_log(self, expected_msgs):
|
||||
debug_log = os.path.join(self.datadir, 'regtest2', 'debug.log')
|
||||
debug_log = os.path.join(self.datadir, self.chain, 'debug.log')
|
||||
with open(debug_log, encoding='utf-8') as dl:
|
||||
dl.seek(0, 2)
|
||||
prev_size = dl.tell()
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ from io import BytesIO
|
|||
|
||||
logger = logging.getLogger("TestFramework.utils")
|
||||
|
||||
BITCOIN_ASSET = "e08fa5a62d79b9e3f5f476743a5535512f0f44444533275a2adc5fe8476a2eac"
|
||||
BITCOIN_ASSET = "b2e15d0d7a0c94e4e2ce0fe6e8691b9e451377f6e46e8045a86f7c4b5d4f0f23"
|
||||
BITCOIN_ASSET_BYTES = bytearray.fromhex(BITCOIN_ASSET)
|
||||
BITCOIN_ASSET_BYTES.reverse()
|
||||
BITCOIN_ASSET_OUT = b"\x01"+BITCOIN_ASSET_BYTES
|
||||
|
|
@ -330,9 +330,9 @@ def initialize_datadir(dirname, n, chain):
|
|||
f.write("con_bip66height=1251\n")
|
||||
f.write("con_csv_deploy_start=0\n") # Enhance tests if removing this line
|
||||
f.write("blindedaddresses=0\n") # Set to minimize broken tests in favor of custom
|
||||
f.write("pubkeyprefix=111\n")
|
||||
f.write("scriptprefix=196\n")
|
||||
f.write("bech32_hrp=bcrt\n")
|
||||
#f.write("pubkeyprefix=111\n")
|
||||
#f.write("scriptprefix=196\n")
|
||||
#f.write("bech32_hrp=bcrt\n")
|
||||
os.makedirs(os.path.join(datadir, 'stderr'), exist_ok=True)
|
||||
os.makedirs(os.path.join(datadir, 'stdout'), exist_ok=True)
|
||||
return datadir
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue