MCPcopy Create free account
hub / github.com/ElementsProject/lightning / check_route_as_expected

Function check_route_as_expected

tests/test_askrene.py:642–662  ·  view source on GitHub ↗

Make sure all fields in paths are match those in routes

(routes, paths)

Source from the content-addressed store, hash-verified

640
641
642def check_route_as_expected(routes, paths):
643 """Make sure all fields in paths are match those in routes"""
644 def dict_subset_eq(a, b):
645 """Is every key in B is the same in A?"""
646 return all(a.get(key) == b[key] for key in b)
647
648 for path in paths:
649 found = False
650 for i in range(len(routes)):
651 route = routes[i]
652 if len(route['path']) != len(path):
653 continue
654 if all(dict_subset_eq(route['path'][i], path[i]) for i in range(len(path))):
655 del routes[i]
656 found = True
657 break
658 if not found:
659 raise ValueError("Could not find path {} in paths {}".format(path, routes))
660
661 if routes != []:
662 raise ValueError("Did not expect paths {}".format(routes))
663
664
665def check_getroute_paths(node,

Callers 5

check_getroute_pathsFunction · 0.85
test_sourcefree_on_modsFunction · 0.85
test_max_htlcFunction · 0.85
test_min_htlcFunction · 0.85
check_getroute_routesFunction · 0.85

Calls 1

dict_subset_eqFunction · 0.85

Tested by

no test coverage detected