mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-01 17:47:30 +01:00
test_lightningd.py: return short channel id from fund_channel helper.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
79962b3588
commit
c2dd0cb295
1 changed files with 12 additions and 4 deletions
|
@ -216,6 +216,7 @@ class LightningDTests(BaseLightningDTests):
|
|||
l2.daemon.wait_for_log('WIRE_GOSSIPCTL_HANDLE_PEER')
|
||||
return l1,l2
|
||||
|
||||
# Returns the short channel-id: <blocknum>:<txnum>:<outnum>
|
||||
def fund_channel(self, l1, l2, amount):
|
||||
addr = l1.rpc.newaddr()['address']
|
||||
|
||||
|
@ -223,15 +224,22 @@ class LightningDTests(BaseLightningDTests):
|
|||
tx = l1.bitcoin.rpc.getrawtransaction(txid)
|
||||
|
||||
l1.rpc.addfunds(tx)
|
||||
l1.rpc.fundchannel(l2.info['id'], amount)
|
||||
# Technically, this is async to fundchannel.
|
||||
l1.daemon.wait_for_log('sendrawtx exit 0')
|
||||
|
||||
# Generate a block, so we know next tx will be first in block.
|
||||
l1.bitcoin.rpc.generate(1)
|
||||
|
||||
tx = l1.rpc.fundchannel(l2.info['id'], amount)['tx']
|
||||
# Technically, this is async to fundchannel.
|
||||
l1.daemon.wait_for_log('sendrawtx exit 0')
|
||||
l1.bitcoin.rpc.generate(1)
|
||||
l1.daemon.wait_for_log('-> CHANNELD_NORMAL')
|
||||
l2.daemon.wait_for_log('-> CHANNELD_NORMAL')
|
||||
|
||||
# Hacky way to find our output.
|
||||
for out in bitcoind.rpc.decoderawtransaction(tx)['vout']:
|
||||
if out['scriptPubKey']['type'] == 'witness_v0_scripthash' and out['value'] == Decimal(amount) / 10**8:
|
||||
return "{}:1:{}".format(bitcoind.rpc.getblockcount(), out['n'])
|
||||
raise ValueError("Can't find {} payment in {}".format(amount, tx))
|
||||
|
||||
def pay(self, lsrc, ldst, amt, label=None, async=False):
|
||||
if not label:
|
||||
label = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(20))
|
||||
|
|
Loading…
Add table
Reference in a new issue