Skip to content

Commit

Permalink
test_lightning.py: speed up test_closing_different_fees
Browse files Browse the repository at this point in the history
It was taking over 10 minutes under valgrind, causing Travis to time it out.

This shrinks it to its essential tests, and also batches.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell authored and cdecker committed Feb 2, 2018
1 parent bd1aa93 commit a497a99
Showing 1 changed file with 43 additions and 30 deletions.
73 changes: 43 additions & 30 deletions tests/test_lightningd.py
Original file line number Diff line number Diff line change
Expand Up @@ -982,38 +982,51 @@ def test_closing(self):

def test_closing_different_fees(self):
l1 = self.node_factory.get_node()
self.give_funds(l1, (10**6) * 5 + 1000000)

# Default feerate = 15000/7500/1000
# It will accept between upper and lower feerate, starting at normal.
for feerates in [ [ 20000, 15000, 7400 ],
[ 15000, 8000, 1000 ],
[ 15000, 6000, 1000 ],
[ 8000, 7500, 1000 ],
[ 8000, 1200, 100 ] ]:
# With and without dust
for pamount in [ 0, 545999, 546000, 546001, 10**6 // 2 ]:
l2 = self.node_factory.get_node(options=['--override-fee-rates={}/{}/{}'
.format(feerates[0],
feerates[1],
feerates[2])])

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

self.fund_channel(l1, l2, 10**6)
if pamount > 0:
self.pay(l1, l2, pamount)

l1.rpc.close(l2.info['id'])
l1.daemon.wait_for_log(' to CHANNELD_SHUTTING_DOWN')
l2.daemon.wait_for_log(' to CHANNELD_SHUTTING_DOWN')

l1.daemon.wait_for_log(' to CLOSINGD_COMPLETE')
l2.daemon.wait_for_log(' to CLOSINGD_COMPLETE')

bitcoind.generate_block(1)
l1.daemon.wait_for_log(' to ONCHAIND_MUTUAL')
l2.daemon.wait_for_log(' to ONCHAIND_MUTUAL')
# It will start at the second number, accepting anything above the first.
feerates=[ [ 20000, 15000, 7400 ],
[ 8000, 1001, 100 ] ]
amounts = [ 0, 545999, 546000 ]
num_peers = len(feerates) * len(amounts)
self.give_funds(l1, (10**6) * num_peers + 10000 * num_peers)

# Create them in a batch, but only valgrind one in three, for speed!
peers = []
for feerate in feerates:
for amount in amounts:
p = self.node_factory.get_node(options=['--override-fee-rates={}/{}/{}'
.format(feerate[0],
feerate[1],
feerate[2])])
p.feerate = feerate
p.amount = amount
l1.rpc.connect(p.info['id'], 'localhost', p.info['port'])
peers.append(p)

for p in peers:
l1.rpc.fundchannel(p.info['id'], 10**6)

bitcoind.generate_block(6)

# Now wait for them all to hit normal state, do payments
for p in peers:
p.daemon.wait_for_log('to CHANNELD_NORMAL')
if p.amount != 0:
self.pay(l1,p,100000000)

# Now close
for p in peers:
l1.rpc.close(p.info['id'])

for p in peers:
p.daemon.wait_for_log(' to CLOSINGD_COMPLETE')

bitcoind.generate_block(1)
for p in peers:
p.daemon.wait_for_log(' to ONCHAIND_MUTUAL')

l1.daemon.wait_for_logs([' to ONCHAIND_MUTUAL'] * num_peers)

@unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1")
def test_permfail(self):
Expand Down

0 comments on commit a497a99

Please sign in to comment.