Test manipulating information in layers
(node_factory)
| 129 | |
| 130 | |
| 131 | def test_layers(node_factory): |
| 132 | """Test manipulating information in layers""" |
| 133 | # remove xpay, since it creates a layer! |
| 134 | l1, l2, l3 = node_factory.line_graph(3, wait_for_announce=True, |
| 135 | opts={'disable-plugin': 'cln-xpay'}) |
| 136 | |
| 137 | assert l2.rpc.askrene_listlayers() == {'layers': []} |
| 138 | with pytest.raises(RpcError, match="Unknown layer"): |
| 139 | l2.rpc.askrene_listlayers('test_layers') |
| 140 | |
| 141 | expect = {'layer': 'test_layers', |
| 142 | 'persistent': False, |
| 143 | 'disabled_nodes': [], |
| 144 | 'created_channels': [], |
| 145 | 'channel_updates': [], |
| 146 | 'constraints': [], |
| 147 | 'biases': [], |
| 148 | 'node_biases': []} |
| 149 | l2.rpc.askrene_create_layer('test_layers') |
| 150 | l2.rpc.askrene_disable_node('test_layers', l1.info['id']) |
| 151 | expect['disabled_nodes'].append(l1.info['id']) |
| 152 | assert l2.rpc.askrene_listlayers('test_layers') == {'layers': [expect]} |
| 153 | assert l2.rpc.askrene_listlayers() == {'layers': [expect]} |
| 154 | with pytest.raises(RpcError, match="Unknown layer"): |
| 155 | l2.rpc.askrene_listlayers('test_layers2') |
| 156 | |
| 157 | l2.rpc.askrene_update_channel('test_layers', "0x0x1/0", False) |
| 158 | expect['channel_updates'].append({'short_channel_id_dir': "0x0x1/0", |
| 159 | 'enabled': False}) |
| 160 | assert l2.rpc.askrene_listlayers('test_layers') == {'layers': [expect]} |
| 161 | with pytest.raises(RpcError, match="Layer already exists"): |
| 162 | l2.rpc.askrene_create_layer('test_layers') |
| 163 | |
| 164 | # Tell it l3 connects to l1! |
| 165 | l2.rpc.askrene_create_channel('test_layers', |
| 166 | l3.info['id'], |
| 167 | l1.info['id'], |
| 168 | '0x0x1', |
| 169 | '1000000sat') |
| 170 | # src/dst gets turned into BOLT 7 order |
| 171 | expect['created_channels'].append({'source': l1.info['id'], |
| 172 | 'destination': l3.info['id'], |
| 173 | 'short_channel_id': '0x0x1', |
| 174 | 'capacity_msat': 1000000000}) |
| 175 | assert l2.rpc.askrene_listlayers('test_layers') == {'layers': [expect]} |
| 176 | |
| 177 | # And give details. |
| 178 | l2.rpc.askrene_update_channel(layer='test_layers', |
| 179 | short_channel_id_dir='0x0x1/0', |
| 180 | htlc_minimum_msat=100, |
| 181 | htlc_maximum_msat=900000000, |
| 182 | fee_base_msat=1, |
| 183 | fee_proportional_millionths=2, |
| 184 | cltv_expiry_delta=18) |
| 185 | # This is *still* disabled, since we disabled it above! |
| 186 | expect['channel_updates'] = [{'short_channel_id_dir': '0x0x1/0', |
| 187 | 'enabled': False, |
| 188 | 'htlc_minimum_msat': 100, |
nothing calls this directly
no test coverage detected