electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 4bda6f5e61da3df0f2cd678c542fffd49045ee9c
parent 093a03ebcfbac74314fd3bd912f566eb03270510
Author: SomberNight <somber.night@protonmail.com>
Date:   Thu, 10 Dec 2020 14:30:27 +0100

test_wallet_vertical: add test case for pre-2.7 "2fa" seed

Diffstat:
Melectrum/tests/test_wallet_vertical.py | 38+++++++++++++++++++++++++++++++++++++-
1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/electrum/tests/test_wallet_vertical.py b/electrum/tests/test_wallet_vertical.py @@ -159,7 +159,43 @@ class TestWalletKeystoreAddressIntegrityForMainnet(ElectrumTestCase): self.assertEqual(w.get_change_addresses()[0], '1KRW8pH6HFHZh889VDq6fEKvmrsmApwNfe') @mock.patch.object(wallet.Abstract_Wallet, 'save_db') - def test_electrum_seed_2fa_legacy(self, mock_save_db): + def test_electrum_seed_2fa_legacy_pre27(self, mock_save_db): + # pre-version-2.7 2fa seed + seed_words = 'bind clever room kidney crucial sausage spy edit canvas soul liquid ribbon slam open alpha suffer gate relax voice carpet law hill woman tonight abstract' + self.assertEqual(seed_type(seed_words), '2fa') + + xprv1, xpub1, xprv2, xpub2 = trustedcoin.TrustedCoinPlugin.xkeys_from_seed(seed_words, '') + + ks1 = keystore.from_xprv(xprv1) + self.assertTrue(isinstance(ks1, keystore.BIP32_KeyStore)) + self.assertEqual(ks1.xprv, 'xprv9s21ZrQH143K2TsDemiaPqaTuBkW3gns4sGi9f65pWtg27nmmmAut6fErgaHFxj3d4rHgyFKjhvtAUafqF3wwU8Bkou8LefQgBtRWjUKN3V') + self.assertEqual(ks1.xpub, 'xpub661MyMwAqRbcEwwgkoFakyXCTDazT9WiS6CJx3VhNrRetv7vKJVARtyihwCVatSsUtVsEYcvdxhvDtkSk8qKV3VVtcL3csz6sQTbGzmEckd') + self.assertEqual(ks1.xpub, xpub1) + + ks2 = keystore.from_xprv(xprv2) + self.assertTrue(isinstance(ks2, keystore.BIP32_KeyStore)) + self.assertEqual(ks2.xprv, 'xprv9s21ZrQH143K3r6H1h91TqRECE7tmDB5PYGZDKPuSjefTzNbDMauUMUnjsUSv8X8nuzQsrtGmtCuA51CNz7XimRj2HPYxUxXGGf4KB7M74y') + self.assertEqual(ks2.xpub, 'xpub661MyMwAqRbcGLAk7ig1pyMxkFxPAftvkmCA1hoX15BeLnhjktuA29oGb7bh9opQgNERu6iWhwcY6b5bZX57dYsGo7zYjwXTNCryfKuPfek') + self.assertEqual(ks2.xpub, xpub2) + + long_user_id, short_id = trustedcoin.get_user_id( + {'x1/': {'xpub': xpub1}, + 'x2/': {'xpub': xpub2}}) + xtype = bip32.xpub_type(xpub1) + xpub3 = trustedcoin.make_xpub(trustedcoin.get_signing_xpub(xtype), long_user_id) + ks3 = keystore.from_xpub(xpub3) + WalletIntegrityHelper.check_xpub_keystore_sanity(self, ks3) + self.assertTrue(isinstance(ks3, keystore.BIP32_KeyStore)) + + w = WalletIntegrityHelper.create_multisig_wallet([ks1, ks2, ks3], '2of3', config=self.config) + self.assertEqual(w.txin_type, 'p2sh') + + self.assertEqual(w.get_receiving_addresses()[0], '3Bw5jczNModhFAbvfwvUHbdGrC2Lh2qRQp') + self.assertEqual(w.get_change_addresses()[0], '3Ke6pKrmtSyyQaMob1ES4pk8siAAkRmst9') + + @mock.patch.object(wallet.Abstract_Wallet, 'save_db') + def test_electrum_seed_2fa_legacy_post27(self, mock_save_db): + # post-version-2.7 2fa seed seed_words = 'kiss live scene rude gate step hip quarter bunker oxygen motor glove' self.assertEqual(seed_type(seed_words), '2fa')