lightningd: correctly store our own channel_reserve_satoshis

openingd calculates our reserve based on the channel amount (even if
we're funding, to keep the calculation in one place), but it wasn't
reporting it back to the master daemon.  We initialized it to 0 so that
valgrind wouldn't get upset, as it's part of a structure we send over
the wire.

Have openingd report back, and also initialize it to an impossible value
as extra assurance.  And remove a stray (harmless but weird) semicolon.

Reported-by: Gálli Zoltán
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2018-07-31 14:04:42 +09:30
committed by Christian Decker
parent 6d79f7679c
commit 8f38a46584
4 changed files with 15 additions and 8 deletions

View File

@@ -7,7 +7,6 @@ from utils import wait_for
import copy
import json
import logging
import pytest
import queue
import os
import random
@@ -5114,7 +5113,6 @@ class LightningDTests(BaseLightningDTests):
# fundee will also forget and disconnect from peer.
assert len(l2.rpc.listpeers(l1.info['id'])['peers']) == 0
@pytest.mark.xfail(strict=True)
def test_reserve_enforcement(self):
"""Channeld should disallow you spending into your reserve"""
l1, l2 = self.connect(may_reconnect=True)
@@ -5125,6 +5123,9 @@ class LightningDTests(BaseLightningDTests):
l2.stop()
# They should both aim for 1%.
assert l2.db_query('SELECT channel_reserve_satoshis FROM channel_configs') == [{'channel_reserve_satoshis': 10**6 // 100}, {'channel_reserve_satoshis': 10**6 // 100}]
# Edit db to reduce reserve to 0 so it will try to violate it.
l2.db_query('UPDATE channel_configs SET channel_reserve_satoshis=0',
use_copy=False)