Skip to content
This repository has been archived by the owner on Mar 30, 2022. It is now read-only.

Commit

Permalink
fix unit tests for CPUs w/max-local-ws==1 for gurnec#104
Browse files Browse the repository at this point in the history
  • Loading branch information
gurnec committed Sep 8, 2017
1 parent 4193e96 commit 4fab004
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions btcrecover/test/test_passwords.py
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,16 @@ def test_blockchain_secondpass_unicode_pp(self):
def test_blockchain_secondpass_no_iter_count_pp(self): # extracted from blockchain-unencrypted-wallet.aes.json which is missing a second password iter_count
self.key_tester("YnM6ujsYxz3SE7fEEekfMuIC1oII7KY//j5FMObBn7HydqVyjnaeTCZDAaC4LbJcVkxaAAAAAE/24yM=", force_kdf_purepython=True)

def init_opencl_kernel(self, devices, global_ws, int_rate = 200, **kwds):
try:
btcrpass.loaded_wallet.init_opencl_kernel(devices, global_ws, global_ws, int_rate, **kwds)
except SystemExit as e:
# this can happen with OpenCL CPUs whose max local-ws is 1, see #104
if "local-ws" in e.code and "exceeds max" in e.code:
btcrpass.loaded_wallet.init_opencl_kernel(devices, global_ws, [None] * len(global_ws), int_rate, **kwds)
else:
raise

@unittest.skipUnless(has_any_opencl_devices(), "requires OpenCL and a compatible device")
def test_bitcoincore_cl(self):
btcrpass.load_from_base64_key("YmM65iRhIMReOQ2qaldHbn++T1fYP3nXX5tMHbaA/lqEbLhFk6/1Y5F5x0QJAQBI/maR")
Expand All @@ -1563,7 +1573,7 @@ def test_bitcoincore_cl(self):
for dev in btcrpass.get_opencl_devices():
if dev.name in dev_names_tested: continue
dev_names_tested.add(dev.name)
btcrpass.loaded_wallet.init_opencl_kernel([dev], [4], [4], 200)
self.init_opencl_kernel([dev], [4])

self.assertEqual(btcrpass.return_verified_password_or_false(
[tstr("btcr-wrong-password-1"), tstr("btcr-wrong-password-2")]), (False, 2),
Expand All @@ -1581,7 +1591,7 @@ def test_bitcoincore_cl_unicode(self):
for dev in btcrpass.get_opencl_devices():
if dev.name in dev_names_tested: continue
dev_names_tested.add(dev.name)
btcrpass.loaded_wallet.init_opencl_kernel([dev], [4], [4], 200)
self.init_opencl_kernel([dev], [4])

self.assertEqual(btcrpass.return_verified_password_or_false(
["btcr-wrong-password-3", "btcr-тест-пароль", "btcr-wrong-password-4"]), ("btcr-тест-пароль", 2),
Expand All @@ -1596,7 +1606,7 @@ def test_bitcoincore_cl_no_interrupts(self):
for dev in btcrpass.get_opencl_devices():
if dev.name in dev_names_tested: continue
dev_names_tested.add(dev.name)
btcrpass.loaded_wallet.init_opencl_kernel([dev], [4], [4], 1)
self.init_opencl_kernel([dev], [4], int_rate=1)

self.assertEqual(btcrpass.return_verified_password_or_false(
[tstr("btcr-wrong-password-1"), tstr("btcr-wrong-password-2")]), (False, 2))
Expand All @@ -1613,7 +1623,7 @@ def test_bitcoincore_cl_sli(self):
self.skipTest("requires two identical OpenCL devices")

btcrpass.load_from_base64_key("YmM65iRhIMReOQ2qaldHbn++T1fYP3nXX5tMHbaA/lqEbLhFk6/1Y5F5x0QJAQBI/maR")
btcrpass.loaded_wallet.init_opencl_kernel([devices_by_name[dev.name], dev], [2, 2], [2, 2], 200)
self.init_opencl_kernel([devices_by_name[dev.name], dev], [2, 2])

self.assertEqual(btcrpass.return_verified_password_or_false(
[tstr("btcr-wrong-password-1"), tstr("btcr-wrong-password-2"), tstr("btcr-wrong-password-3"), tstr("btcr-wrong-password-4")]), (False, 4))
Expand All @@ -1631,7 +1641,7 @@ def test_armory_cl(self):
for dev in btcrpass.get_opencl_devices():
if dev.name in dev_names_tested: continue
dev_names_tested.add(dev.name)
btcrpass.loaded_wallet.init_opencl_kernel([dev], [4], [4], 200)
self.init_opencl_kernel([dev], [4])

self.assertEqual(btcrpass.return_verified_password_or_false(
[tstr("btcr-wrong-password-1"), tstr("btcr-wrong-password-2")]), (False, 2),
Expand All @@ -1649,7 +1659,7 @@ def test_armory_cl_mem_factor(self):
for dev in btcrpass.get_opencl_devices():
if dev.name in dev_names_tested: continue
dev_names_tested.add(dev.name)
btcrpass.loaded_wallet.init_opencl_kernel([dev], [8], [8], 200, save_every=3)
self.init_opencl_kernel([dev], [8], save_every=3)

self.assertEqual(btcrpass.return_verified_password_or_false(
[tstr("btcr-wrong-password-1"), tstr("btcr-wrong-password-2")]), (False, 2),
Expand All @@ -1668,7 +1678,7 @@ def test_armory_cl_no_interrupts(self):
for dev in btcrpass.get_opencl_devices():
if dev.name in dev_names_tested: continue
dev_names_tested.add(dev.name)
btcrpass.loaded_wallet.init_opencl_kernel([dev], [4], [4], 1)
self.init_opencl_kernel([dev], [4], int_rate=1)

self.assertEqual(btcrpass.return_verified_password_or_false(
[tstr("btcr-wrong-password-1"), tstr("btcr-wrong-password-2")]), (False, 2))
Expand All @@ -1686,7 +1696,7 @@ def test_armory_cl_sli(self):
self.skipTest("requires two identical OpenCL devices")

btcrpass.load_from_base64_key("YXI6r7mks1qvph4G+rRT7WlIptdr9qDqyFTfXNJ3ciuWJ12BgWX5Il+y28hLNr/u4Wl49hUi4JBeq6Jz9dVBX3vAJ6476FEAACAABAAAAGGwnwXRpPbBzC5lCOBVVWDu7mUJetBOBvzVAv0IbrboDXqA8A==")
btcrpass.loaded_wallet.init_opencl_kernel([devices_by_name[dev.name], dev], [4, 4], [4, 4], 200)
self.init_opencl_kernel([devices_by_name[dev.name], dev], [4, 4])

self.assertEqual(btcrpass.return_verified_password_or_false(
[tstr("btcr-wrong-password-1"), tstr("btcr-wrong-password-2"), tstr("btcr-wrong-password-3"), tstr("btcr-wrong-password-4"),
Expand Down

0 comments on commit 4fab004

Please sign in to comment.