tests: test for fundchannel fail with tiny utxo

Tony Giorgio <tonygiorgio@protonmail.com> says:

Reproduce:

1.  Add 1 600 sat UTXO to a fresh node

2.  Verify the fundchannel command fails with a low fee rate:

```
./lightning-cli fundchannel 0366abc8eb4da61e31a8d2c4520d31cabdf58cc5250f855657397f3dd62493938a 100000 1000
{
   "code": 301,
   "message": "Could not afford 100000sat using all 1 available UTXOs: 99522sat short"
}
```

3.  Now do the command again, but with a higher fee rate, making the 600 sat UTXO uneconomical:

```
./lightning-cli fundchannel 0366abc8eb4da61e31a8d2c4520d31cabdf58cc5250f855657397f3dd62493938a 100000 10000
```

4. Observe the RPC call and the logs. The RPC call will never return, and the logs will stop after this:

```
2023-04-16T10:58:45.839Z DEBUG   plugin-spenderp: mfc 34: multiconnect done.
2023-04-16T10:58:45.839Z DEBUG   plugin-spenderp: mfc 34: 'parsefeerate' done
2023-04-16T10:58:45.839Z DEBUG   plugin-spenderp: mfc 34: fundpsbt.
```

5. Keep CLN running long enough and you'll eventually run OOM.
This commit is contained in:
Rusty Russell 2023-09-13 09:55:38 +09:30
parent a3d393a24d
commit 47f4e11c87

View File

@ -2418,3 +2418,18 @@ def test_anchor_min_emergency(bitcoind, node_factory):
l1.rpc.withdraw(addr2, 'all')
bitcoind.generate_block(1, wait_for_mempool=1)
wait_for(lambda: l1.rpc.listfunds()['outputs'] == [])
@pytest.mark.xfail(strict=True)
def test_fundchannel_utxo_too_small(bitcoind, node_factory):
l1, l2 = node_factory.get_nodes(2)
# Add 1 600 sat UTXO to a fresh node
bitcoind.rpc.sendtoaddress(l1.rpc.newaddr()['bech32'], 0.00000600)
bitcoind.generate_block(1, wait_for_mempool=1)
wait_for(lambda: len(l1.rpc.listfunds()['outputs']) == 1)
# a higher fee rate, making the 600 sat UTXO uneconomical:
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
with pytest.raises(RpcError, match=r'Could not afford 100000sat using all 0 available UTXOs'):
l1.rpc.fundchannel(l2.info['id'], 100000, 10000)