Test invalid UTF-8 encodings in rune: used to make us kill the offers plugin which implements decode, as it gave bad utf8!
(node_factory)
| 458 | |
| 459 | |
| 460 | def test_badrune(node_factory): |
| 461 | """Test invalid UTF-8 encodings in rune: used to make us kill the offers plugin which implements decode, as it gave bad utf8!""" |
| 462 | l1 = node_factory.get_node() |
| 463 | l1.rpc.decode('5zi6-ugA6hC4_XZ0R7snl5IuiQX4ugL4gm9BQKYaKUU9gCZtZXRob2RebGlzdHxtZXRob2ReZ2V0fG1ldGhvZD1zdW1tYXJ5Jm1ldGhvZC9saXN0ZGF0YXN0b3Jl') |
| 464 | rune = l1.rpc.createrune(restrictions="readonly") |
| 465 | |
| 466 | binrune = base64.urlsafe_b64decode(rune['rune']) |
| 467 | # Mangle each part, try decode. Skip most of the boring chars |
| 468 | # (just '|', '&', '#'). |
| 469 | for i in range(32, len(binrune)): |
| 470 | for span in (range(0, 32), (124, 38, 35), range(127, 256)): |
| 471 | for c in span: |
| 472 | modrune = binrune[:i] + bytes([c]) + binrune[i + 1:] |
| 473 | try: |
| 474 | l1.rpc.decode(base64.urlsafe_b64encode(modrune).decode('utf8')) |
| 475 | except RpcError: |
| 476 | pass |
| 477 | |
| 478 | |
| 479 | def test_checkrune(node_factory): |