1
0

tests/test_txbatcher.py: de-duplicate "create wallet" logic

This commit is contained in:
SomberNight
2025-04-01 15:00:23 +00:00
parent 664c4b25d1
commit 2807be08c8
2 changed files with 10 additions and 15 deletions

View File

@@ -79,7 +79,6 @@ from .fee_policy import FeePolicy
class TxBatcher(Logger): class TxBatcher(Logger):
SLEEP_INTERVAL = 1 SLEEP_INTERVAL = 1
RETRY_DELAY = 60
def __init__(self, wallet): def __init__(self, wallet):
Logger.__init__(self) Logger.__init__(self)

View File

@@ -81,6 +81,13 @@ class TestTxBatcher(ElectrumTestCase):
ks = keystore.from_seed(seed_words, passphrase='', for_multisig=False) ks = keystore.from_seed(seed_words, passphrase='', for_multisig=False)
return WalletIntegrityHelper.create_standard_wallet(ks, gap_limit=gap_limit, config=config) return WalletIntegrityHelper.create_standard_wallet(ks, gap_limit=gap_limit, config=config)
def _create_wallet(self):
wallet = self.create_standard_wallet_from_seed(WALLET_SEED)
wallet.start_network(self.network)
wallet.txbatcher.SLEEP_INTERVAL = 0.01
self.network.wallets.append(wallet)
return wallet
@mock.patch.object(wallet.Abstract_Wallet, 'save_db') @mock.patch.object(wallet.Abstract_Wallet, 'save_db')
async def test_batch_payments(self, mock_save_db): async def test_batch_payments(self, mock_save_db):
# output 1: tx1(o1) --------------- # output 1: tx1(o1) ---------------
@@ -92,11 +99,7 @@ class TestTxBatcher(ElectrumTestCase):
# txbatcher creates a new transaction tx2, child of tx1 # txbatcher creates a new transaction tx2, child of tx1
# #
OUTGOING_ADDRESS = 'tb1q7rl9cxr85962ztnsze089zs8ycv52hk43f3m9n' OUTGOING_ADDRESS = 'tb1q7rl9cxr85962ztnsze089zs8ycv52hk43f3m9n'
# create wallet wallet = self._create_wallet()
wallet = self.create_standard_wallet_from_seed(WALLET_SEED)
wallet.start_network(self.network)
wallet.txbatcher.SLEEP_INTERVAL = 0.01
self.network.wallets.append(wallet)
# fund wallet # fund wallet
funding_tx = Transaction(FUNDING_TX) funding_tx = Transaction(FUNDING_TX)
await self.network.try_broadcasting(funding_tx, 'funding') await self.network.try_broadcasting(funding_tx, 'funding')
@@ -137,11 +140,7 @@ class TestTxBatcher(ElectrumTestCase):
The user tries to create tx2, that pays an invoice for 90k sats. The user tries to create tx2, that pays an invoice for 90k sats.
The tx batcher fails to batch, and should create a child transaction The tx batcher fails to batch, and should create a child transaction
""" """
wallet = self.create_standard_wallet_from_seed(WALLET_SEED) wallet = self._create_wallet()
wallet.start_network(self.network)
wallet.txbatcher.SLEEP_INTERVAL = 0.01
wallet.txbatcher.RETRY_DELAY = 0.60
self.network.wallets.append(wallet)
# fund wallet # fund wallet
funding_tx = Transaction(FUNDING_TX) funding_tx = Transaction(FUNDING_TX)
@@ -168,10 +167,7 @@ class TestTxBatcher(ElectrumTestCase):
async def test_sweep_from_submarine_swap(self, mock_save_db): async def test_sweep_from_submarine_swap(self, mock_save_db):
self.maxDiff = None self.maxDiff = None
# create wallet # create wallet
wallet = self.create_standard_wallet_from_seed(WALLET_SEED) wallet = self._create_wallet()
wallet.start_network(self.network)
wallet.txbatcher.SLEEP_INTERVAL = 0.01
self.network.wallets.append(wallet)
# add swap data # add swap data
swap_data = SwapData( swap_data = SwapData(
is_reverse=True, is_reverse=True,