@@ -2168,52 +2168,36 @@ def test_funding_fail(self):
2168
2168
l2 = self .node_factory .get_node (options = ['--locktime-blocks={}' .format (max_locktime + 1 )])
2169
2169
l1 .rpc .connect (l2 .info ['id' ], 'localhost' , l2 .info ['port' ])
2170
2170
2171
+ funds = 1000000
2172
+
2171
2173
addr = l1 .rpc .newaddr ()['address' ]
2172
- txid = l1 .bitcoin .rpc .sendtoaddress (addr , 0.01 )
2174
+ txid = l1 .bitcoin .rpc .sendtoaddress (addr , funds / 10 ** 8 )
2173
2175
bitcoind .generate_block (1 )
2174
2176
2175
2177
# Wait for it to arrive.
2176
2178
wait_for (lambda : len (l1 .rpc .listfunds ()['outputs' ]) > 0 )
2177
2179
2178
2180
# Fail because l1 dislikes l2's huge locktime.
2179
- try :
2180
- l1 .rpc .fundchannel (l2 .info ['id' ], 100000 )
2181
- except ValueError as verr :
2182
- str (verr ).index ('to_self_delay {} larger than {}'
2183
- .format (max_locktime + 1 , max_locktime ))
2184
- except Exception as err :
2185
- self .fail ("Unexpected exception {}" .format (err ))
2186
- else :
2187
- self .fail ("huge locktime ignored?" )
2188
-
2189
- # We don't have enough left to cover fees if we try to spend it all.
2190
- try :
2191
- l1 .rpc .fundchannel (l2 .info ['id' ], 1000000 )
2192
- except ValueError as verr :
2193
- str (verr ).index ('Cannot afford funding transaction' )
2194
- except Exception as err :
2195
- self .fail ("Unexpected exception {}" .format (err ))
2196
- else :
2197
- self .fail ("We somehow covered fees?" )
2198
-
2199
- # Should still be connected.
2181
+ self .assertRaisesRegex (ValueError , r'to_self_delay \d+ larger than \d+' ,
2182
+ l1 .rpc .fundchannel , l2 .info ['id' ], int (funds / 10 ))
2200
2183
assert l1 .rpc .getpeers ()['peers' ][0 ]['connected' ]
2201
2184
assert l2 .rpc .getpeers ()['peers' ][0 ]['connected' ]
2202
2185
2203
2186
# Restart l2 without ridiculous locktime.
2204
- l2 .daemon .proc .terminate ()
2205
-
2206
2187
l2 .daemon .cmd_line .remove ('--locktime-blocks={}' .format (max_locktime + 1 ))
2188
+ l2 .restart ()
2189
+ l1 .rpc .connect (l2 .info ['id' ], 'localhost' , l2 .info ['port' ])
2207
2190
2208
- # Wait for l1 to notice
2209
- wait_for (lambda : len (l1 .rpc .getpeers ()['peers' ]) == 0 )
2191
+ # We don't have enough left to cover fees if we try to spend it all.
2192
+ self .assertRaisesRegex (ValueError , r'Cannot afford funding transaction' ,
2193
+ l1 .rpc .fundchannel , l2 .info ['id' ], funds )
2210
2194
2211
- # Now restart l2, reconnect .
2212
- l2 . daemon . start ()
2213
- l1 .rpc .connect ( l2 . info [ 'id' ], 'localhost' , l2 . info [ 'port' ])
2195
+ # Should still be connected .
2196
+ assert l1 . rpc . getpeers ()[ 'peers' ][ 0 ][ 'connected' ]
2197
+ assert l2 .rpc .getpeers ()[ 'peers' ][ 0 ][ 'connected' ]
2214
2198
2215
2199
# This works.
2216
- l1 .rpc .fundchannel (l2 .info ['id' ], int (0.01 * 10 ** 8 / 2 ))
2200
+ l1 .rpc .fundchannel (l2 .info ['id' ], int (funds / 10 ))
2217
2201
2218
2202
def test_addfunds_from_block (self ):
2219
2203
"""Send funds to the daemon without telling it explicitly
0 commit comments