Skip to content

Commit

Permalink
Fix unittest with incorrect blockcounts
Browse files Browse the repository at this point in the history
  • Loading branch information
Cryp Toon committed Mar 14, 2024
1 parent bdba7a5 commit 784e994
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
26 changes: 10 additions & 16 deletions tests/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,22 +603,16 @@ def test_service_network_litecoin_legacy(self):
self.assertIn(txid, [utxo['txid'] for utxo in utxos])

def test_service_blockcount(self):
srv = ServiceTest(min_providers=3)
n_blocks = None
for provider in srv.results:
if n_blocks is not None:
self.assertAlmostEqual(srv.results[provider], n_blocks, delta=5000,
msg="Provider %s value %d != %d" % (provider, srv.results[provider], n_blocks))
n_blocks = srv.results[provider]

# Test Litecoin network
srv = ServiceTest(min_providers=3, network='litecoin')
n_blocks = None
for provider in srv.results:
if n_blocks is not None:
self.assertAlmostEqual(srv.results[provider], n_blocks, delta=5000,
msg="Provider %s value %d != %d" % (provider, srv.results[provider], n_blocks))
n_blocks = srv.results[provider]
for nw in ['bitcoin', 'litecoin', 'testnet']:
srv = ServiceTest(min_providers=3, cache_uri='', network=nw)
srv.blockcount()
n_blocks = None
for provider in srv.results:
if n_blocks is not None:
self.assertAlmostEqual(srv.results[provider], n_blocks, delta=5000 if nw == 'testnet' else 3,
msg="Network %s, provider %s value %d != %d" %
(nw, provider, srv.results[provider], n_blocks))
n_blocks = srv.results[provider]

def test_service_max_providers(self):
srv = ServiceTest(max_providers=1, cache_uri='')
Expand Down
3 changes: 2 additions & 1 deletion tests/test_wallets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2271,7 +2271,8 @@ def test_wallet_anti_fee_sniping(self):
w.utxo_add(w.get_key().address, 1234567, os.urandom(32).hex(), 1)
t = w.send_to('tb1qrjtz22q59e76mhumy0p586cqukatw5vcd0xvvz', 123456)
block_height = Service(network='testnet').blockcount()
self.assertEqual(t.locktime, block_height+1)
# Bitaps and Bitgo return incorrect blockcount for testnet, so set delta to 5000
self.assertAlmostEqual(t.locktime, block_height+1, delta=5000)

w2 = wallet_create_or_open('antifeesnipingtestwallet2', network='testnet', anti_fee_sniping=True)
w2.utxo_add(w2.get_key().address, 1234567, os.urandom(32).hex(), 1)
Expand Down

0 comments on commit 784e994

Please sign in to comment.