Browse Source

fix tests patching

add-joinmarket
zebra-lucky 1 year ago
parent
commit
80dd424480
  1. 12
      electrum/plugins/joinmarket/tests/__init__.py
  2. 12
      electrum/plugins/joinmarket/tests/test_jm_main.py

12
electrum/plugins/joinmarket/tests/__init__.py

@ -1,11 +1,10 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import asyncio
from types import SimpleNamespace from types import SimpleNamespace
from typing import List from typing import List
from unittest import mock from unittest import mock
from electrum import util, wallet, SimpleConfig from electrum import util, storage, SimpleConfig
from electrum.bitcoin import address_to_scripthash from electrum.bitcoin import address_to_scripthash
from electrum.transaction import Transaction from electrum.transaction import Transaction
from electrum.wallet import restore_wallet_from_text from electrum.wallet import restore_wallet_from_text
@ -282,14 +281,12 @@ class JMTestCase(ElectrumTestCase):
TESTNET = True TESTNET = True
def setUp(self): async def asyncSetUp(self):
super().setUp() await super().asyncSetUp()
patcher = mock.patch.object(wallet.Abstract_Wallet, 'save_db') patcher = mock.patch.object(storage.WalletStorage, 'write')
self.mock_save_db = patcher.start() self.mock_save_db = patcher.start()
self.addCleanup(patcher.stop) self.addCleanup(patcher.stop)
async def asyncSetUp(self):
await super().asyncSetUp()
self.asyncio_loop = util.get_asyncio_loop() self.asyncio_loop = util.get_asyncio_loop()
self.config = SimpleConfig({'electrum_path': self.electrum_path}) self.config = SimpleConfig({'electrum_path': self.electrum_path})
self.config.FEE_EST_DYNAMIC = False self.config.FEE_EST_DYNAMIC = False
@ -321,4 +318,3 @@ class JMTestCase(ElectrumTestCase):
w.adb.add_transaction(Transaction(tx1_str)) w.adb.add_transaction(Transaction(tx1_str))
w.adb.add_verified_tx(tx1_txid, util.TxMinedInfo( w.adb.add_verified_tx(tx1_txid, util.TxMinedInfo(
int(1e6), '', '', '', '')) int(1e6), '', '', '', ''))
await asyncio.sleep(0.2) # FIXME dirty fix to fix patching of save_db

12
electrum/plugins/joinmarket/tests/test_jm_main.py

@ -1,10 +1,9 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import asyncio
import copy import copy
from unittest import mock from unittest import mock
from electrum import constants, util, wallet, SimpleConfig from electrum import constants, util, storage, SimpleConfig
from electrum.wallet import restore_wallet_from_text from electrum.wallet import restore_wallet_from_text
from tests import ElectrumTestCase from tests import ElectrumTestCase
@ -20,14 +19,12 @@ class JMManagerInitTestCase(ElectrumTestCase):
TESTNET = True TESTNET = True
def setUp(self): async def asyncSetUp(self):
super().setUp() await super().asyncSetUp()
patcher = mock.patch.object(wallet.Abstract_Wallet, 'save_db') patcher = mock.patch.object(storage.WalletStorage, 'write')
self.mock_save_db = patcher.start() self.mock_save_db = patcher.start()
self.addCleanup(patcher.stop) self.addCleanup(patcher.stop)
async def asyncSetUp(self):
await super().asyncSetUp()
self.asyncio_loop = util.get_asyncio_loop() self.asyncio_loop = util.get_asyncio_loop()
self.config = SimpleConfig({'electrum_path': self.electrum_path}) self.config = SimpleConfig({'electrum_path': self.electrum_path})
self.config.FEE_EST_DYNAMIC = False self.config.FEE_EST_DYNAMIC = False
@ -44,7 +41,6 @@ class JMManagerInitTestCase(ElectrumTestCase):
self.w._up_to_date = True self.w._up_to_date = True
self.w.db.put('stored_height', int(1e7)) self.w.db.put('stored_height', int(1e7))
self.network = NetworkMock(self.asyncio_loop, self.config, w) self.network = NetworkMock(self.asyncio_loop, self.config, w)
await asyncio.sleep(0.2) # FIXME dirty fix to fix patching of save_db
async def test_init(self): async def test_init(self):
w = self.w w = self.w

Loading…
Cancel
Save