Make sure our variants of feerate argument work!
(node_factory)
| 4295 | |
| 4296 | |
| 4297 | def test_feerate_arg(node_factory): |
| 4298 | """Make sure our variants of feerate argument work!""" |
| 4299 | l1 = node_factory.get_node() |
| 4300 | |
| 4301 | # These are the get_node() defaults |
| 4302 | by_blocks = {2: 15000, |
| 4303 | 6: 11000, |
| 4304 | 12: 7500, |
| 4305 | 100: 3750} |
| 4306 | |
| 4307 | # Literal values: |
| 4308 | fees = {"9999perkw": 9999, |
| 4309 | "10000perkb": 10000 // 4, |
| 4310 | 10000: 10000 // 4} |
| 4311 | |
| 4312 | fees["urgent"] = by_blocks[6] |
| 4313 | fees["normal"] = by_blocks[12] |
| 4314 | fees["slow"] = by_blocks[100] |
| 4315 | |
| 4316 | fees["opening"] = by_blocks[12] |
| 4317 | fees["mutual_close"] = by_blocks[100] |
| 4318 | fees["penalty"] = by_blocks[12] |
| 4319 | fees["unilateral_close"] = by_blocks[6] |
| 4320 | |
| 4321 | fees["2blocks"] = by_blocks[2] |
| 4322 | fees["6blocks"] = by_blocks[6] |
| 4323 | fees["12blocks"] = by_blocks[12] |
| 4324 | fees["100blocks"] = by_blocks[100] |
| 4325 | |
| 4326 | # Simple interpolation |
| 4327 | fees["9blocks"] = (by_blocks[6] + by_blocks[12]) // 2 |
| 4328 | |
| 4329 | for fee, expect in fees.items(): |
| 4330 | # Put arg in assertion, so it gets printed on failure! |
| 4331 | assert (l1.rpc.parsefeerate(fee), fee) == ({'perkw': expect}, fee) |
| 4332 | |
| 4333 | # More thorough interpolation |
| 4334 | for block in range(12, 100): |
| 4335 | # y = y1 + (x-x1)(y2-y1)/(x2-x1) |
| 4336 | fee = by_blocks[12] + (block - 12) * (by_blocks[100] - by_blocks[12]) // (100 - 12) |
| 4337 | # Rounding error is a thing! |
| 4338 | assert abs(l1.rpc.parsefeerate(f"{block}blocks")['perkw'] - fee) <= 1 |
| 4339 | |
| 4340 | |
| 4341 | @pytest.mark.skip(reason="Fails by intention for creating test gossip stores") |