Browse Source

test: add initial tests for starting an external fundchannel

Test for getting through the address generation portion.
pull/2938/head
lisa neigut 6 years ago
committed by Rusty Russell
parent
commit
b0b813a171
  1. 49
      tests/test_connection.py

49
tests/test_connection.py

@ -9,6 +9,7 @@ import os
import pytest
import time
import random
import re
import shutil
import unittest
@ -818,6 +819,54 @@ def test_funding_by_utxos(node_factory, bitcoind):
l1.rpc.fundchannel(l3.info["id"], int(0.01 * 10**8), utxos=utxos)
# Check a bunch of preliminary states for calling these RPCs
def test_funding_external_wallet_corners(node_factory, bitcoind):
l1 = node_factory.get_node()
l2 = node_factory.get_node()
amount = 2**24
# Fail to open (too large)
with pytest.raises(RpcError, match=r'Amount exceeded 16777215'):
l1.rpc.fundchannel_start(l2.info['id'], amount)
amount = amount - 1
fake_txid = '929764844a8f9938b669a60a1d51a11c9e2613c7eb4776e4126f1f20c0a685c3'
with pytest.raises(RpcError, match=r'Unknown peer'):
l1.rpc.fundchannel_start(l2.info['id'], amount)
with pytest.raises(RpcError, match=r'Unknown peer'):
l1.rpc.fundchannel_continue(l2.info['id'], fake_txid)
# Should not be able to continue without being in progress.
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
with pytest.raises(RpcError, match=r'No channel funding in progress.'):
l1.rpc.fundchannel_continue(l2.info['id'], fake_txid)
def test_funding_external_wallet(node_factory, bitcoind):
l1 = node_factory.get_node()
l2 = node_factory.get_node()
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
assert(l1.rpc.listpeers()['peers'][0]['id'] == l2.info['id'])
amount = 2**24 - 1
address = l1.rpc.fundchannel_start(l2.info['id'], amount)['funding_address']
assert len(address) > 0
peer = l1.rpc.listpeers()['peers'][0]
# Peer should still be connected and in state waiting for funding_txid
assert peer['id'] == l2.info['id']
r = re.compile('Funding channel start: awaiting funding_txid with output to .*')
assert any(r.match(line) for line in peer['channels'][0]['status'])
assert 'OPENINGD' in peer['channels'][0]['state']
# Trying to start a second funding should not work, it's in progress.
with pytest.raises(RpcError, match=r'Already funding channel'):
l1.rpc.fundchannel_start(l2.info['id'], amount)
def test_lockin_between_restart(node_factory, bitcoind):
l1 = node_factory.get_node(may_reconnect=True)
l2 = node_factory.get_node(options={'funding-confirms': 3},

Loading…
Cancel
Save