mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
elements: Give pytest some information about the test chain
We are checking against chain-dependent constants, so let's make sure we are using the ones for the correct chain. Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
committed by
Rusty Russell
parent
b016ce94e8
commit
cd93a855ce
@@ -161,6 +161,8 @@ const struct chainparams networks[] = {
|
|||||||
.max_funding = AMOUNT_SAT_INIT((1 << 24) - 1),
|
.max_funding = AMOUNT_SAT_INIT((1 << 24) - 1),
|
||||||
.max_payment = AMOUNT_MSAT_INIT(0xFFFFFFFFULL),
|
.max_payment = AMOUNT_MSAT_INIT(0xFFFFFFFFULL),
|
||||||
.when_lightning_became_cool = 1,
|
.when_lightning_became_cool = 1,
|
||||||
|
.p2pkh_version = 91,
|
||||||
|
.p2sh_version = 75,
|
||||||
.testnet = true,
|
.testnet = true,
|
||||||
.bip32_key_version = {.bip32_pubkey_version = BIP32_VER_TEST_PUBLIC,
|
.bip32_key_version = {.bip32_pubkey_version = BIP32_VER_TEST_PUBLIC,
|
||||||
.bip32_privkey_version = BIP32_VER_TEST_PRIVATE},
|
.bip32_privkey_version = BIP32_VER_TEST_PRIVATE},
|
||||||
|
|||||||
@@ -305,3 +305,25 @@ def executor(teardown_checks):
|
|||||||
ex = futures.ThreadPoolExecutor(max_workers=20)
|
ex = futures.ThreadPoolExecutor(max_workers=20)
|
||||||
yield ex
|
yield ex
|
||||||
ex.shutdown(wait=False)
|
ex.shutdown(wait=False)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def chainparams():
|
||||||
|
chainparams = {
|
||||||
|
'regtest': {
|
||||||
|
"bip173_prefix": "bcrt",
|
||||||
|
"elements": False,
|
||||||
|
"name": "regtest",
|
||||||
|
"p2sh_prefix": '2',
|
||||||
|
"elements": False,
|
||||||
|
},
|
||||||
|
'liquid-regtest': {
|
||||||
|
"bip173_prefix": "ert",
|
||||||
|
"elements": True,
|
||||||
|
"name": "liquid-regtest",
|
||||||
|
"p2sh_prefix": 'X',
|
||||||
|
"elements": True,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return chainparams[config['TEST_NETWORK']]
|
||||||
|
|||||||
@@ -426,7 +426,7 @@ def test_htlc_in_timeout(node_factory, bitcoind, executor):
|
|||||||
|
|
||||||
|
|
||||||
@unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1")
|
@unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1")
|
||||||
def test_bech32_funding(node_factory):
|
def test_bech32_funding(node_factory, chainparams):
|
||||||
# Don't get any funds from previous runs.
|
# Don't get any funds from previous runs.
|
||||||
l1 = node_factory.get_node(random_hsm=True)
|
l1 = node_factory.get_node(random_hsm=True)
|
||||||
l2 = node_factory.get_node(random_hsm=True)
|
l2 = node_factory.get_node(random_hsm=True)
|
||||||
@@ -437,7 +437,7 @@ def test_bech32_funding(node_factory):
|
|||||||
# fund a bech32 address and then open a channel with it
|
# fund a bech32 address and then open a channel with it
|
||||||
res = l1.openchannel(l2, 20000, 'bech32')
|
res = l1.openchannel(l2, 20000, 'bech32')
|
||||||
address = res['address']
|
address = res['address']
|
||||||
assert address[0:4] == "bcrt"
|
assert address[0:4] == chainparams['bip173_prefix']
|
||||||
|
|
||||||
# probably overly paranoid checking
|
# probably overly paranoid checking
|
||||||
wallettxid = res['wallettxid']
|
wallettxid = res['wallettxid']
|
||||||
@@ -546,13 +546,13 @@ def test_address(node_factory):
|
|||||||
l2.rpc.connect(l1.info['id'], l1.daemon.opts['addr'])
|
l2.rpc.connect(l1.info['id'], l1.daemon.opts['addr'])
|
||||||
|
|
||||||
|
|
||||||
def test_listconfigs(node_factory, bitcoind):
|
def test_listconfigs(node_factory, bitcoind, chainparams):
|
||||||
l1 = node_factory.get_node()
|
l1 = node_factory.get_node()
|
||||||
|
|
||||||
configs = l1.rpc.listconfigs()
|
configs = l1.rpc.listconfigs()
|
||||||
# See utils.py
|
# See utils.py
|
||||||
assert configs['allow-deprecated-apis'] is False
|
assert configs['allow-deprecated-apis'] is False
|
||||||
assert configs['network'] == 'regtest'
|
assert configs['network'] == chainparams['name']
|
||||||
assert configs['ignore-fee-limits'] is False
|
assert configs['ignore-fee-limits'] is False
|
||||||
|
|
||||||
# Test one at a time.
|
# Test one at a time.
|
||||||
@@ -1317,17 +1317,17 @@ def test_bad_onion(node_factory, bitcoind):
|
|||||||
assert err.value.error['data']['erring_channel'] == route[1]['channel']
|
assert err.value.error['data']['erring_channel'] == route[1]['channel']
|
||||||
|
|
||||||
|
|
||||||
def test_newaddr(node_factory):
|
def test_newaddr(node_factory, chainparams):
|
||||||
l1 = node_factory.get_node()
|
l1 = node_factory.get_node()
|
||||||
p2sh = l1.rpc.newaddr('p2sh-segwit')
|
p2sh = l1.rpc.newaddr('p2sh-segwit')
|
||||||
assert 'bech32' not in p2sh
|
assert 'bech32' not in p2sh
|
||||||
assert p2sh['p2sh-segwit'].startswith('2')
|
assert p2sh['p2sh-segwit'].startswith(chainparams['p2sh_prefix'])
|
||||||
bech32 = l1.rpc.newaddr('bech32')
|
bech32 = l1.rpc.newaddr('bech32')
|
||||||
assert 'p2sh-segwit' not in bech32
|
assert 'p2sh-segwit' not in bech32
|
||||||
assert bech32['bech32'].startswith('bcrt1')
|
assert bech32['bech32'].startswith(chainparams['bip173_prefix'])
|
||||||
both = l1.rpc.newaddr('all')
|
both = l1.rpc.newaddr('all')
|
||||||
assert both['p2sh-segwit'].startswith('2')
|
assert both['p2sh-segwit'].startswith(chainparams['p2sh_prefix'])
|
||||||
assert both['bech32'].startswith('bcrt1')
|
assert both['bech32'].startswith(chainparams['bip173_prefix'])
|
||||||
|
|
||||||
|
|
||||||
def test_newaddr_deprecated(node_factory):
|
def test_newaddr_deprecated(node_factory):
|
||||||
|
|||||||
Reference in New Issue
Block a user