Skip to content
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

Merged
merged 25 commits into from
Dec 17, 2017
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
98b1a66
gossip: Remove HSM_FD from handshake
cdecker Nov 24, 2017
37e9d14
routing: Make routing_state aware of its own ID
cdecker Dec 2, 2017
4c13032
opts: Change alias to be u8*, better matches the unicode nature
cdecker Nov 24, 2017
7427c8a
gossip: Passing alias, color and wireaddrs through to gossipd
cdecker Nov 24, 2017
abe9192
routing: Return boolean from handle_channel_announcement
cdecker Nov 24, 2017
dfc5a6e
routing: Add local and sigfail to trace when receiving cannounce
cdecker Dec 2, 2017
aa67236
gossip: Forward when we don't have a valid node_announcement yet
cdecker Dec 4, 2017
88218a0
routing: Do not set an empty channel_announcement if none is given
cdecker Dec 4, 2017
c1b4f41
json_fund_channel: give more details than "peer died".
rustyrussell Dec 5, 2017
e99f69e
subd: add transaction to subd exit corner case.
rustyrussell Dec 5, 2017
6793efe
wireaddr: marshal empty address properly.
rustyrussell Dec 5, 2017
139774c
openingd: return to master for more gossip when negotiation fails.
rustyrussell Dec 6, 2017
c984fb2
openingd: handle ERROR packets (if other end fails negotiation).
rustyrussell Dec 6, 2017
6889fe7
test_lightningd: add test for funding failures.
rustyrussell Dec 6, 2017
616bc26
daemon_conn: helper to release daemon_conn.
rustyrussell Dec 6, 2017
06a0188
gossipd: split peer structure to clearly separate local and remote fi…
rustyrussell Dec 6, 2017
62634e9
Makefile: make gossipd objects depend correctly on its own headers.
rustyrussell Dec 11, 2017
c552fa8
subd: if a required daemon exits, wait instead of killing it.
rustyrussell Dec 11, 2017
b9eddbe
gossipd: don't hand length to route code, it's implied.
rustyrussell Dec 11, 2017
09151fd
gossipd: hand back peer, don't hand a new peer.
rustyrussell Dec 11, 2017
a4512ea
gossipd: don't increment broadcast_index until *after* message sent.
rustyrussell Dec 11, 2017
2a2902b
gossipd: hand out gossip_index to other daemons.
rustyrussell Dec 11, 2017
a22d341
pytest: Fix a flaky channel_reenable test
cdecker Dec 12, 2017
c787e51
channel: Directly send announcements and updates to gossipd
cdecker Dec 12, 2017
234b412
pytest: Minor cleanup
cdecker Dec 13, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions tests/test_lightningd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}'
Copy link
Member Author

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.

Copy link
Member Author

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.

.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:
Copy link
Member Author

Choose a reason for hiding this comment

The 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.

Copy link
Member Author

Choose a reason for hiding this comment

The 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 l2, which we'd be doing in the next step anyway.

Copy link
Contributor

Choose a reason for hiding this comment

The 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
"""
Expand Down