Skip to content

Commit

Permalink
Remove unused variables. Fix flake8 warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
practicalswift authored and cdecker committed Feb 22, 2018
1 parent b8c6365 commit e18948a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 28 deletions.
42 changes: 17 additions & 25 deletions tests/test_lightningd.py
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,6 @@ def test_pay_optional_args(self):
payment3 = l1.rpc.listpayments(anyinv)['payments']
assert len(payment3) == 1 and payment3[0]['msatoshi'] == 500

transactions = l1.rpc.listpayments()
# Should see 3 completed transactions
assert len(l1.rpc.listpayments()['payments']) == 3

Expand Down Expand Up @@ -1190,9 +1189,6 @@ def test_onchain_first_commit(self):

l1.rpc.connect(l2.info['id'], 'localhost', l2.info['port'])

# Like fundchannel, but we'll probably fail before CHANNELD_NORMAL.
addr = l1.rpc.newaddr()['address']

self.give_funds(l1, 10**6 + 1000000)

l1.rpc.fundchannel(l2.info['id'], 10**6)
Expand Down Expand Up @@ -1395,7 +1391,7 @@ def test_onchain_middleman(self):
# l2 connects to both, so l1 can't reconnect and thus l2 drops to chain
l2.rpc.connect(l1.info['id'], 'localhost', l1.info['port'])
l2.rpc.connect(l3.info['id'], 'localhost', l3.info['port'])
c12 = self.fund_channel(l2, l1, 10**6)
self.fund_channel(l2, l1, 10**6)
c23 = self.fund_channel(l2, l3, 10**6)

# Make sure routes finalized.
Expand Down Expand Up @@ -1741,8 +1737,6 @@ def test_gossip_jsonrpc(self):
l1.daemon.wait_for_logs(['peer_out WIRE_ANNOUNCEMENT_SIGNATURES',
'peer_in WIRE_ANNOUNCEMENT_SIGNATURES'])

channel_id = channels[0]['short_channel_id']

# Just wait for the update to kick off and then check the effect
needle = "Received channel_update for channel"
l1.daemon.wait_for_log(needle)
Expand Down Expand Up @@ -1908,7 +1902,6 @@ def test_second_channel(self):
def test_routing_gossip(self):
nodes = [self.node_factory.get_node() for _ in range(5)]
l1 = nodes[0]
l5 = nodes[4]

for i in range(len(nodes) - 1):
src, dst = nodes[i], nodes[i + 1]
Expand Down Expand Up @@ -2245,7 +2238,7 @@ def test_htlc_out_timeout(self):
inv = l2.rpc.invoice(amt, 'test_htlc_out_timeout', 'desc')['bolt11']
assert l2.rpc.listinvoices('test_htlc_out_timeout')['invoices'][0]['status'] == 'unpaid'

payfuture = self.executor.submit(l1.rpc.pay, inv)
self.executor.submit(l1.rpc.pay, inv)

# l1 will disconnect, and not reconnect.
l1.daemon.wait_for_log('dev_disconnect: @WIRE_REVOKE_AND_ACK')
Expand Down Expand Up @@ -2300,7 +2293,7 @@ def test_htlc_in_timeout(self):
inv = l2.rpc.invoice(amt, 'test_htlc_in_timeout', 'desc')['bolt11']
assert l2.rpc.listinvoices('test_htlc_in_timeout')['invoices'][0]['status'] == 'unpaid'

payfuture = self.executor.submit(l1.rpc.pay, inv)
self.executor.submit(l1.rpc.pay, inv)

# l1 will disconnect and not reconnect.
l1.daemon.wait_for_log('dev_disconnect: -WIRE_REVOKE_AND_ACK')
Expand Down Expand Up @@ -2478,7 +2471,7 @@ def test_reconnect_normal(self):
'+WIRE_FUNDING_LOCKED']
l1 = self.node_factory.get_node(disconnect=disconnects)
l2 = self.node_factory.get_node()
ret = l1.rpc.connect(l2.info['id'], 'localhost', l2.info['port'])
l1.rpc.connect(l2.info['id'], 'localhost', l2.info['port'])

self.fund_channel(l1, l2, 10**6)

Expand All @@ -2491,7 +2484,7 @@ def test_reconnect_sender_add1(self):

l1 = self.node_factory.get_node(disconnect=disconnects)
l2 = self.node_factory.get_node()
ret = l1.rpc.connect(l2.info['id'], 'localhost', l2.info['port'])
l1.rpc.connect(l2.info['id'], 'localhost', l2.info['port'])

self.fund_channel(l1, l2, 10**6)

Expand Down Expand Up @@ -2519,7 +2512,7 @@ def test_reconnect_sender_add(self):
'+WIRE_REVOKE_AND_ACK']
l1 = self.node_factory.get_node(disconnect=disconnects)
l2 = self.node_factory.get_node()
ret = l1.rpc.connect(l2.info['id'], 'localhost', l2.info['port'])
l1.rpc.connect(l2.info['id'], 'localhost', l2.info['port'])

self.fund_channel(l1, l2, 10**6)

Expand All @@ -2545,7 +2538,7 @@ def test_reconnect_receiver_add(self):
'+WIRE_REVOKE_AND_ACK']
l1 = self.node_factory.get_node()
l2 = self.node_factory.get_node(disconnect=disconnects)
ret = l1.rpc.connect(l2.info['id'], 'localhost', l2.info['port'])
l1.rpc.connect(l2.info['id'], 'localhost', l2.info['port'])

self.fund_channel(l1, l2, 10**6)

Expand Down Expand Up @@ -2575,7 +2568,7 @@ def test_reconnect_receiver_fulfill(self):
'+WIRE_REVOKE_AND_ACK']
l1 = self.node_factory.get_node()
l2 = self.node_factory.get_node(disconnect=disconnects)
ret = l1.rpc.connect(l2.info['id'], 'localhost', l2.info['port'])
l1.rpc.connect(l2.info['id'], 'localhost', l2.info['port'])

self.fund_channel(l1, l2, 10**6)

Expand Down Expand Up @@ -2681,8 +2674,7 @@ def test_withdraw(self):

# Add some funds to withdraw later
for i in range(10):
txid = l1.bitcoin.rpc.sendtoaddress(addr, amount / 10**8 + 0.01)
tx = l1.bitcoin.rpc.getrawtransaction(txid)
l1.bitcoin.rpc.sendtoaddress(addr, amount / 10**8 + 0.01)

bitcoind.generate_block(1)
wait_for(lambda: len(l1.rpc.listfunds()['outputs']) == 10)
Expand Down Expand Up @@ -2824,7 +2816,7 @@ def test_funding_fail(self):
funds = 1000000

addr = l1.rpc.newaddr()['address']
txid = l1.bitcoin.rpc.sendtoaddress(addr, funds / 10**8)
l1.bitcoin.rpc.sendtoaddress(addr, funds / 10**8)
bitcoind.generate_block(1)

# Wait for it to arrive.
Expand Down Expand Up @@ -2924,7 +2916,7 @@ def test_addfunds_from_block(self):
l1 = self.node_factory.get_node(random_hsm=True)

addr = l1.rpc.newaddr()['address']
txid = l1.bitcoin.rpc.sendtoaddress(addr, 0.1)
l1.bitcoin.rpc.sendtoaddress(addr, 0.1)
l1.bitcoin.rpc.generate(1)

wait_for(lambda: len(l1.rpc.listfunds()['outputs']) == 1)
Expand Down Expand Up @@ -2955,7 +2947,7 @@ def test_channel_persistence(self):
assert(n.db_query('SELECT COUNT(id) as count FROM channels;')[0]['count'] == 1)

# Fire off a sendpay request, it'll get interrupted by a restart
fut = self.executor.submit(self.pay, l1, l2, 10000)
self.executor.submit(self.pay, l1, l2, 10000)
# Wait for it to be committed to, i.e., stored in the DB
l1.daemon.wait_for_log('peer_in WIRE_COMMITMENT_SIGNED')

Expand Down Expand Up @@ -3013,7 +3005,7 @@ def test_payment_success_persistence(self):
inv1 = l2.rpc.invoice(1000, 'inv1', 'inv1')

# Fire off a pay request, it'll get interrupted by a restart
fut = self.executor.submit(l1.rpc.pay, inv1['bolt11'])
self.executor.submit(l1.rpc.pay, inv1['bolt11'])

l1.daemon.wait_for_log('dev_disconnect: \+WIRE_COMMITMENT_SIGNED')

Expand Down Expand Up @@ -3053,7 +3045,7 @@ def test_payment_failed_persistence(self):
inv1 = l2.rpc.invoice(1000, 'inv1', 'inv1', 2)

# Fire off a pay request, it'll get interrupted by a restart
fut = self.executor.submit(l1.rpc.pay, inv1['bolt11'])
self.executor.submit(l1.rpc.pay, inv1['bolt11'])

l1.daemon.wait_for_log('dev_disconnect: \+WIRE_COMMITMENT_SIGNED')

Expand Down Expand Up @@ -3286,7 +3278,7 @@ def test_update_fee(self):
@unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1")
def test_update_all_fees(self):
l1, l2 = self.connect()
chanid = self.fund_channel(l1, l2, 10**6)
self.fund_channel(l1, l2, 10**6)

# Set all fees as positional parameters.
l1.rpc.dev_setfees('12345', '6789', '123')
Expand Down Expand Up @@ -3400,7 +3392,6 @@ def test_update_fee_reconnect(self):
l2.daemon.wait_for_log('onchaind complete, forgetting peer')

def test_io_logging(self):
disconnects = ['+WIRE_COMMITMENT_SIGNED']
l1 = self.node_factory.get_node(options=['--debug-subdaemon-io=channeld',
'--log-level=io'])
l2 = self.node_factory.get_node()
Expand Down Expand Up @@ -3518,7 +3509,7 @@ def test_multiple_channels(self):

l1.daemon.wait_for_log('WIRE_GOSSIPCTL_HAND_BACK_PEER')
l2.daemon.wait_for_log('WIRE_GOSSIPCTL_HAND_BACK_PEER')
chanid = self.fund_channel(l1, l2, 10**6)
self.fund_channel(l1, l2, 10**6)

l1.rpc.close(l2.info['id'])
l1.daemon.wait_for_log(' to CLOSINGD_COMPLETE')
Expand Down Expand Up @@ -3648,5 +3639,6 @@ def test_forget_channel(self):
l1.restart()
assert len(l1.rpc.listpeers()['peers']) == 0


if __name__ == '__main__':
unittest.main(verbosity=2)
7 changes: 4 additions & 3 deletions tools/generate-wire.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def _typesize(typename):
else:
raise ValueError('Unknown typename {}'.format(typename))


# Full (message, fieldname)-mappings
typemap = {
('update_fail_htlc', 'reason'): FieldType('u8'),
Expand All @@ -72,7 +73,6 @@ def _typesize(typename):
('node_announcement', 'rgb_color'): FieldType('u8'),
('node_announcement', 'addresses'): FieldType('u8'),
('node_announcement', 'ipv6'): FieldType('struct ipv6'),
('node_announcement', 'alias'): FieldType('u8'),
('announcement_signatures', 'short_channel_id'): FieldType('struct short_channel_id'),
('channel_announcement', 'short_channel_id'): FieldType('struct short_channel_id'),
('channel_update', 'short_channel_id'): FieldType('struct short_channel_id')
Expand Down Expand Up @@ -190,6 +190,7 @@ def _guess_type(message, fieldname, base_size):

raise ValueError('Unknown size {} for {}'.format(base_size, fieldname))


fromwire_impl_templ = """bool fromwire_{name}({ctx}const void *p{args})
{{
{fields}
Expand Down Expand Up @@ -534,6 +535,7 @@ def find_message_with_option(messages, optional_messages, name, option):
optional_messages.append(m)
return m


parser = argparse.ArgumentParser(description='Generate C from CSV')
parser.add_argument('--header', action='store_true', help="Create wire header")
parser.add_argument('--bolt', action='store_true', help="Generate wire-format for BOLT")
Expand Down Expand Up @@ -701,5 +703,4 @@ def find_message_with_option(messages, optional_messages, name, option):
includes=includes,
enumname=options.enumname,
enums=enums,
func_decls='\n'.join(decls),
))
func_decls='\n'.join(decls)))

0 comments on commit e18948a

Please sign in to comment.