Minor cleanups.

1. connect convenience variable for improved readabilty.
2. a comment explaining that timer is on channel, not HTLC.
3. use modern python style in test_htlc_send_timeout

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2018-08-10 11:01:40 +09:30 committed by Christian Decker
parent 63e4ea17af
commit 65c882ca3a
3 changed files with 14 additions and 12 deletions

View File

@ -1073,6 +1073,7 @@ static void try_reach_one_addr(struct reaching *reach)
{
int fd, af;
bool use_proxy = reach->daemon->use_proxy_always;
const struct wireaddr_internal *addr = &reach->addrs[reach->addrnum];
if (reach->addrnum == tal_count(reach->addrs)) {
connect_failed(reach->daemon, &reach->id, reach->seconds_waited,
@ -1084,7 +1085,7 @@ static void try_reach_one_addr(struct reaching *reach)
/* Might not even be able to create eg. IPv6 sockets */
af = -1;
switch (reach->addrs[reach->addrnum].itype) {
switch (addr->itype) {
case ADDR_INTERNAL_SOCKNAME:
af = AF_LOCAL;
/* Local sockets don't use tor proxy */
@ -1100,7 +1101,7 @@ static void try_reach_one_addr(struct reaching *reach)
use_proxy = true;
break;
case ADDR_INTERNAL_WIREADDR:
switch (reach->addrs[reach->addrnum].u.wireaddr.type) {
switch (addr->u.wireaddr.type) {
case ADDR_TYPE_TOR_V2:
case ADDR_TYPE_TOR_V3:
use_proxy = true;
@ -1135,7 +1136,7 @@ static void try_reach_one_addr(struct reaching *reach)
tal_append_fmt(&reach->errors,
"%s: opening %i socket gave %s. ",
type_to_string(tmpctx, struct wireaddr_internal,
&reach->addrs[reach->addrnum]),
addr),
af, strerror(errno));
reach->addrnum++;
try_reach_one_addr(reach);

View File

@ -445,7 +445,7 @@ enum onion_type send_htlc_out(struct channel *out, u64 amount, u32 cltv,
payment_hash, onion_routing_packet, in);
tal_add_destructor(hout, destroy_hout_subd_died);
/* We give it 30 seconds to commit htlc. */
/* Give channel 30 seconds to commit (first) htlc. */
if (!out->htlc_timeout)
out->htlc_timeout = new_reltimer(&out->peer->ld->timers,
out, time_from_sec(30),

View File

@ -807,15 +807,16 @@ def test_htlc_send_timeout(node_factory, bitcoind):
# tries to ping before sending WIRE_COMMITMENT_SIGNED.
time.sleep(30)
inv = l3.rpc.invoice(123000, 'test_htlc_send_timeout', 'description')
try:
with pytest.raises(RpcError) as excinfo:
l1.rpc.pay(inv['bolt11'])
except RpcError as err:
# Complaints it couldn't find route.
assert err.error['code'] == 205
# Temporary channel failure
assert only_one(err.error['data']['failures'])['failcode'] == 0x1007
assert only_one(err.error['data']['failures'])['erring_node'] == l2.info['id']
assert only_one(err.error['data']['failures'])['erring_channel'] == chanid2
err = excinfo.value
# Complaints it couldn't find route.
assert err.error['code'] == 205
# Temporary channel failure
assert only_one(err.error['data']['failures'])['failcode'] == 0x1007
assert only_one(err.error['data']['failures'])['erring_node'] == l2.info['id']
assert only_one(err.error['data']['failures'])['erring_channel'] == chanid2
# L1 should send a ping beforehand, and get reply, then send commitment.
l1.daemon.wait_for_log('channeld.*:\[OUT\] 0012')