(node_factory, bitcoind)
| 2052 | |
| 2053 | |
| 2054 | def test_setchannel_usage(node_factory, bitcoind): |
| 2055 | # TEST SETUP |
| 2056 | # |
| 2057 | # [l1] ---> [l2] (channel funded) |
| 2058 | # | |
| 2059 | # o - - > [l3] (only connected) |
| 2060 | # |
| 2061 | # - check initial SQL values |
| 2062 | # - check setchannel can be used |
| 2063 | # - checks command's return object format |
| 2064 | # - check custom SQL fee values |
| 2065 | # - check values in local nodes listchannels output |
| 2066 | # - json throws exception on negative values |
| 2067 | # - checks if peer id can be used instead of scid |
| 2068 | # - checks fee_base_msat and fee_proportional_millionths in `listpeers` out |
| 2069 | DEF_BASE = 10 |
| 2070 | DEF_BASE_MSAT = Millisatoshi(DEF_BASE) |
| 2071 | DEF_PPM = 100 |
| 2072 | # Minus reserve |
| 2073 | MAX_HTLC = Millisatoshi(int(FUNDAMOUNT * 1000 * 0.99)) |
| 2074 | |
| 2075 | l1, l2, l3 = node_factory.get_nodes(3, |
| 2076 | opts={'fee-base': DEF_BASE, 'fee-per-satoshi': DEF_PPM}) |
| 2077 | node_factory.join_nodes([l1, l2]) |
| 2078 | l1.rpc.connect(l3.info['id'], 'localhost', l3.port) |
| 2079 | |
| 2080 | def channel_get_config(scid): |
| 2081 | return l1.db.query( |
| 2082 | 'SELECT feerate_base, feerate_ppm, htlc_minimum_msat, htlc_maximum_msat FROM channels ' |
| 2083 | 'WHERE scid={};'.format(scid_to_int(scid))) |
| 2084 | |
| 2085 | # get short channel id |
| 2086 | scid = l1.get_channel_scid(l2) |
| 2087 | |
| 2088 | # feerates should be init with global config |
| 2089 | db_fees = l1.db_query('SELECT feerate_base, feerate_ppm, htlc_maximum_msat FROM channels;') |
| 2090 | assert(db_fees[0]['feerate_base'] == DEF_BASE) |
| 2091 | assert(db_fees[0]['feerate_ppm'] == DEF_PPM) |
| 2092 | # This will be the capacity - reserves: |
| 2093 | assert(db_fees[0]['htlc_maximum_msat'] == MAX_HTLC) |
| 2094 | # this is also what listpeers should return |
| 2095 | channel = only_one(l1.rpc.listpeerchannels()['channels']) |
| 2096 | assert channel['fee_base_msat'] == DEF_BASE_MSAT |
| 2097 | assert channel['fee_proportional_millionths'] == DEF_PPM |
| 2098 | assert channel['maximum_htlc_out_msat'] == MAX_HTLC |
| 2099 | |
| 2100 | # custom setchannel scid <feebase> <feeppm> <htlcmin> <htlcmax> |
| 2101 | result = l1.rpc.setchannel(scid, 1337, 137, 17, 133337) |
| 2102 | |
| 2103 | # check result format |
| 2104 | assert(len(result['channels']) == 1) |
| 2105 | assert(re.match('^[0-9a-f]{64}$', result['channels'][0]['channel_id'])) |
| 2106 | assert(result['channels'][0]['peer_id'] == l2.info['id']) |
| 2107 | assert(result['channels'][0]['short_channel_id'] == scid) |
| 2108 | assert(result['channels'][0]['fee_base_msat'] == 1337) |
| 2109 | assert(result['channels'][0]['fee_proportional_millionths'] == 137) |
| 2110 | assert(result['channels'][0]['minimum_htlc_out_msat'] == 17) |
| 2111 | assert(result['channels'][0]['maximum_htlc_out_msat'] == 133337) |
nothing calls this directly
no test coverage detected