l2 uses the reject_odd_funding_amounts plugin to reject some openings.
(node_factory, bitcoind)
| 633 | @pytest.mark.openchannel('v1') |
| 634 | @pytest.mark.openchannel('v2') |
| 635 | def test_openchannel_hook(node_factory, bitcoind): |
| 636 | """ l2 uses the reject_odd_funding_amounts plugin to reject some openings. |
| 637 | """ |
| 638 | opts = [{}, {'plugin': os.path.join(os.getcwd(), 'tests/plugins/reject_odd_funding_amounts.py')}] |
| 639 | l1, l2 = node_factory.line_graph(2, fundchannel=False, opts=opts) |
| 640 | l1.fundwallet(10**6) |
| 641 | |
| 642 | # Even amount: works. |
| 643 | l1.rpc.fundchannel(l2.info['id'], 100000) |
| 644 | |
| 645 | # Make sure plugin got all the vars we expect |
| 646 | expected = { |
| 647 | 'channel_flags': '1', |
| 648 | 'dust_limit_msat': 546000, |
| 649 | 'htlc_minimum_msat': 0, |
| 650 | 'id': l1.info['id'], |
| 651 | 'max_accepted_htlcs': '483', |
| 652 | 'max_htlc_value_in_flight_msat': 18446744073709551615, |
| 653 | 'to_self_delay': '5', |
| 654 | } |
| 655 | |
| 656 | if l2.config('experimental-dual-fund'): |
| 657 | # openchannel2 var checks |
| 658 | expected.update({ |
| 659 | 'channel_id': '.*', |
| 660 | 'commitment_feerate_per_kw': '7500', |
| 661 | 'funding_feerate_per_kw': '7500', |
| 662 | 'feerate_our_max': '150000', |
| 663 | 'feerate_our_min': '1875', |
| 664 | 'locktime': '.*', |
| 665 | 'their_funding_msat': 100000000, |
| 666 | 'channel_max_msat': 16777215000, |
| 667 | }) |
| 668 | else: |
| 669 | expected.update({ |
| 670 | 'channel_reserve_msat': 1000000, |
| 671 | 'feerate_per_kw': '7500', |
| 672 | 'funding_msat': 100000000, |
| 673 | 'push_msat': 0, |
| 674 | }) |
| 675 | |
| 676 | l2.daemon.wait_for_log('reject_odd_funding_amounts.py: {} VARS'.format(len(expected))) |
| 677 | for k, v in expected.items(): |
| 678 | assert l2.daemon.is_in_log('reject_odd_funding_amounts.py: {}={}'.format(k, v)) |
| 679 | |
| 680 | # Close it. |
| 681 | txid = l1.rpc.close(l2.info['id'])['txid'] |
| 682 | bitcoind.generate_block(1, txid) |
| 683 | wait_for(lambda: [c['state'] for c in only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['channels']] == ['ONCHAIN']) |
| 684 | |
| 685 | # Odd amount: fails |
| 686 | l1.connect(l2) |
| 687 | with pytest.raises(RpcError, match=r"I don't like odd amounts"): |
| 688 | l1.rpc.fundchannel(l2.info['id'], 100001) |
| 689 | |
| 690 | |
| 691 | @pytest.mark.openchannel('v1') |
nothing calls this directly
no test coverage detected