From a9d0e3fca9dd756b7629890f04429a056d893a88 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Wed, 24 Feb 2021 12:54:43 +0100 Subject: [PATCH] tests: try to eliminate random failures from mpp_split tests closes: #7062 --- electrum/mpp_split.py | 2 +- electrum/tests/test_mpp_split.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/electrum/mpp_split.py b/electrum/mpp_split.py index d0a1d60a5..3eafe7ee7 100644 --- a/electrum/mpp_split.py +++ b/electrum/mpp_split.py @@ -24,7 +24,7 @@ def unique_hierarchy(hierarchy: Dict[int, List[Dict[bytes, int]]]) -> Dict[int, for config in configs: # config dict can be out of order, so sort, otherwise not unique unique_configs.add(tuple((c, config[c]) for c in sorted(config.keys()))) - for unique_config in unique_configs: + for unique_config in sorted(unique_configs): new_hierarchy[number_parts].append( {t[0]: t[1] for t in unique_config}) return new_hierarchy diff --git a/electrum/tests/test_mpp_split.py b/electrum/tests/test_mpp_split.py index 00889d4e9..b690f3109 100644 --- a/electrum/tests/test_mpp_split.py +++ b/electrum/tests/test_mpp_split.py @@ -1,3 +1,5 @@ +import random + import electrum.mpp_split as mpp_split # side effect for PART_PENALTY from electrum.lnutil import NoPathFound @@ -9,6 +11,8 @@ PART_PENALTY = mpp_split.PART_PENALTY class TestMppSplit(ElectrumTestCase): def setUp(self): super().setUp() + # to make tests reproducible: + random.seed(0) # undo side effect mpp_split.PART_PENALTY = PART_PENALTY self.channels_with_funds = {