diff --git a/tests/test_blockchain.py b/tests/test_blockchain.py index aaf6ca306..0e9cf1a2d 100644 --- a/tests/test_blockchain.py +++ b/tests/test_blockchain.py @@ -57,9 +57,9 @@ class TestBlockchain(ElectrumTestCase): def setUp(self): super().setUp() - self.data_dir = self.electrum_path + self.config = SimpleConfig({'electrum_path': self.electrum_path}) + self.data_dir = self.config.path make_dir(os.path.join(self.data_dir, 'forks')) - self.config = SimpleConfig({'electrum_path': self.data_dir}) blockchain.blockchains = {} def _append_header(self, chain: Blockchain, header: dict): diff --git a/tests/test_commands.py b/tests/test_commands.py index f294c6da5..d67480733 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -197,7 +197,7 @@ class TestCommandsTestnet(ElectrumTestCase): super().setUp() self.config = SimpleConfig({'electrum_path': self.electrum_path}) self.config.NETWORK_OFFLINE = True - shutil.copytree(os.path.join(os.path.dirname(__file__), "fiat_fx_data"), os.path.join(self.electrum_path, "cache")) + shutil.copytree(os.path.join(os.path.dirname(__file__), "fiat_fx_data"), os.path.join(self.config.path, "cache")) self.config.FX_EXCHANGE = "BitFinex" self.config.FX_CURRENCY = "EUR" self._default_default_timezone = electrum.util.DEFAULT_TIMEZONE diff --git a/tests/test_lnpeer.py b/tests/test_lnpeer.py index 3b9b6f293..2716e8458 100644 --- a/tests/test_lnpeer.py +++ b/tests/test_lnpeer.py @@ -1656,8 +1656,16 @@ class TestPeerDirect(TestPeer): min_final_cltv_delta=400, payment_secret=lnaddr1.payment_secret, ) - await asyncio.sleep(bob_wallet.MPP_EXPIRY // 2) # give bob time to receive the htlc bob_payment_key = bob_wallet._get_payment_key(lnaddr1.paymenthash).hex() + # wait until bob has received both HTLCs (anchor channels need more commitment round-trips) + deadline = time.monotonic() + bob_wallet.MPP_EXPIRY * 2 + while True: + mpp_set = bob_wallet.received_mpp_htlcs.get(bob_payment_key) + if mpp_set is not None and len(mpp_set.htlcs) >= 2: + break + if time.monotonic() > deadline: + self.fail(f"timed out waiting for bob to receive both HTLCs: {bob_wallet.received_mpp_htlcs=}") + await asyncio.sleep(0.05) assert bob_wallet.received_mpp_htlcs[bob_payment_key].resolution == RecvMPPResolution.WAITING assert len(bob_wallet.received_mpp_htlcs[bob_payment_key].htlcs) == 2 # now wait until bob expires the mpp (set) diff --git a/tests/test_simple_config.py b/tests/test_simple_config.py index 6b8ade704..9d5fc73de 100644 --- a/tests/test_simple_config.py +++ b/tests/test_simple_config.py @@ -107,7 +107,7 @@ class Test_SimpleConfig(ElectrumTestCase): read_user_dir_function=read_user_dir) config.save_user_config() contents = None - with open(os.path.join(self.electrum_dir, "config"), "r") as f: + with open(os.path.join(config.path, "config"), "r") as f: contents = f.read() result = ast.literal_eval(contents) result.pop('config_version', None) diff --git a/tests/test_wallet.py b/tests/test_wallet.py index de1a278a6..e4ddef3be 100644 --- a/tests/test_wallet.py +++ b/tests/test_wallet.py @@ -225,8 +225,8 @@ class TestHistoryExport(ElectrumTestCase): self.patch_timezone.start() time.tzset() super(TestHistoryExport, self).setUp() - shutil.copytree(Path(__file__).parent / "fiat_fx_data", Path(self.electrum_path) / "cache") self.config = SimpleConfig({'electrum_path': self.electrum_path}) + shutil.copytree(Path(__file__).parent / "fiat_fx_data", Path(self.config.path) / "cache") def tearDown(self): super(TestHistoryExport, self).tearDown()