-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Let gossipd automatically announce the node when a local channel_announcement is queued #413
Changes from 1 commit
98b1a66
37e9d14
4c13032
7427c8a
abe9192
dfc5a6e
aa67236
88218a0
c1b4f41
e99f69e
6793efe
139774c
c984fb2
6889fe7
616bc26
06a0188
62634e9
c552fa8
b9eddbe
09151fd
a4512ea
2a2902b
a22d341
c787e51
234b412
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2116,6 +2116,61 @@ def test_funding_change(self): | |
assert outputs[0] > 8990000 | ||
assert outputs[2] == 10000000 | ||
|
||
def test_funding_fail(self): | ||
"""Add some funds, fund a channel without enough funds""" | ||
# Previous runs with same bitcoind can leave funds! | ||
l1 = self.node_factory.get_node(random_hsm=True) | ||
max_locktime = 3 * 6 * 24 | ||
l2 = self.node_factory.get_node(options=['--locktime-blocks={}'.format(max_locktime + 1)]) | ||
l1.rpc.connect(l2.info['id'], 'localhost', l2.info['port']) | ||
|
||
addr = l1.rpc.newaddr()['address'] | ||
txid = l1.bitcoin.rpc.sendtoaddress(addr, 0.01) | ||
bitcoind.generate_block(1) | ||
|
||
# Wait for it to arrive. | ||
wait_for(lambda: len(l1.rpc.listfunds()['outputs']) > 0) | ||
|
||
# Fail because l1 dislikes l2's huge locktime. | ||
try: | ||
l1.rpc.fundchannel(l2.info['id'], 100000) | ||
except ValueError as verr: | ||
str(verr).index('to_self_delay {} larger than {}' | ||
.format(max_locktime+1, max_locktime)) | ||
except Exception as err: | ||
self.fail("Unexpected exception {}".format(err)) | ||
else: | ||
self.fail("huge locktime ignored?") | ||
|
||
# We don't have enough left to cover fees if we try to spend it all. | ||
try: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't this implicitly assume an ordering of the internal checks, i.e., first we check the funding amounts and only then we check the locktimes? After all we didn't change the locktime blocks, but now expect a different exception. Spinning up a third node, with compatible locktimes to l1, and then connecting to l1 but with the wrong funding amount gets rid of this assumption. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The commit I added to the end of the PR now changes the max-locktime and restarts There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, much cleaner. Thanks! |
||
l1.rpc.fundchannel(l2.info['id'], 1000000) | ||
except ValueError as verr: | ||
str(verr).index('Cannot afford funding transaction') | ||
except Exception as err: | ||
self.fail("Unexpected exception {}".format(err)) | ||
else: | ||
self.fail("We somehow covered fees?") | ||
|
||
# Should still be connected. | ||
assert l1.rpc.getpeers()['peers'][0]['connected'] | ||
assert l2.rpc.getpeers()['peers'][0]['connected'] | ||
|
||
# Restart l2 without ridiculous locktime. | ||
l2.daemon.proc.terminate() | ||
|
||
l2.daemon.cmd_line.remove('--locktime-blocks={}'.format(max_locktime + 1)) | ||
|
||
# Wait for l1 to notice | ||
wait_for(lambda: len(l1.rpc.getpeers()['peers']) == 0) | ||
|
||
# Now restart l2, reconnect. | ||
l2.daemon.start() | ||
l1.rpc.connect(l2.info['id'], 'localhost', l2.info['port']) | ||
|
||
# This works. | ||
l1.rpc.fundchannel(l2.info['id'], int(0.01 * 10**8 / 2)) | ||
|
||
def test_addfunds_from_block(self): | ||
"""Send funds to the daemon without telling it explicitly | ||
""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These expected exceptions can be implemented using assertRaises or assertRaisesRegex. They're a bit shorter and will ensure failure if the expected exception is not raised.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a commit to the end of the PR to address this.