(node_factory, bitcoind)
| 4522 | |
| 4523 | |
| 4524 | def test_setconfig(node_factory, bitcoind): |
| 4525 | l1, l2 = node_factory.line_graph(2, fundchannel=False) |
| 4526 | configfile = os.path.join(l2.daemon.opts.get("lightning-dir"), TEST_NETWORK, 'config') |
| 4527 | setconfigfile = configfile + ".setconfig" |
| 4528 | |
| 4529 | assert (l2.rpc.listconfigs('min-capacity-sat')['configs'] |
| 4530 | == {'min-capacity-sat': |
| 4531 | {'source': 'default', |
| 4532 | 'value_int': 10000, |
| 4533 | 'dynamic': True}}) |
| 4534 | |
| 4535 | with pytest.raises(RpcError, match='requires a value'): |
| 4536 | l2.rpc.setconfig('min-capacity-sat') |
| 4537 | |
| 4538 | with pytest.raises(RpcError, match='requires a value'): |
| 4539 | l2.rpc.setconfig(config='min-capacity-sat') |
| 4540 | |
| 4541 | with pytest.raises(RpcError, match='is not a number'): |
| 4542 | l2.rpc.setconfig(config='min-capacity-sat', val="abcd") |
| 4543 | |
| 4544 | # Check will fail the same way. |
| 4545 | with pytest.raises(RpcError, match='requires a value'): |
| 4546 | l2.rpc.check('setconfig', config='min-capacity-sat') |
| 4547 | |
| 4548 | with pytest.raises(RpcError, match='is not a number'): |
| 4549 | l2.rpc.check('setconfig', config='min-capacity-sat', val="abcd") |
| 4550 | |
| 4551 | # Check will pass, but NOT change value. |
| 4552 | assert l2.rpc.check(command_to_check='setconfig', config='min-capacity-sat', val=500000) == {'command_to_check': 'setconfig'} |
| 4553 | |
| 4554 | assert (l2.rpc.listconfigs('min-capacity-sat')['configs'] |
| 4555 | == {'min-capacity-sat': |
| 4556 | {'source': 'default', |
| 4557 | 'value_int': 10000, |
| 4558 | 'dynamic': True}}) |
| 4559 | |
| 4560 | ret = l2.rpc.setconfig(config='min-capacity-sat', val=500000) |
| 4561 | assert ret == {'config': |
| 4562 | {'config': 'min-capacity-sat', |
| 4563 | 'source': '{}:2'.format(setconfigfile), |
| 4564 | 'value_int': 500000, |
| 4565 | 'dynamic': True}} |
| 4566 | |
| 4567 | with open(setconfigfile, 'r') as f: |
| 4568 | lines = f.read().splitlines() |
| 4569 | assert lines == ["# Created and update by setconfig, but you can edit this manually when node is stopped.", "min-capacity-sat=500000"] |
| 4570 | |
| 4571 | # Now we need to meet minumum |
| 4572 | with pytest.raises(RpcError, match='which is below 500000sat'): |
| 4573 | l1.fundchannel(l2, 400000) |
| 4574 | |
| 4575 | l1.fundchannel(l2, 10**6) |
| 4576 | txid = only_one(l1.rpc.close(l2.info['id'])['txids']) |
| 4577 | # Make sure we're completely closed! |
| 4578 | bitcoind.generate_block(1, wait_for_mempool=txid) |
| 4579 | sync_blockheight(bitcoind, [l1, l2]) |
| 4580 | |
| 4581 | # It's persistent! |
nothing calls this directly
no test coverage detected