electrum

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

commit 0657bb1b36f894a789762904035ad58a8110b6e9
parent 664b0c234eca5afec9a7de9c7533cbc41227af14
Author: SomberNight <somber.night@protonmail.com>
Date:   Fri, 14 Dec 2018 23:01:52 +0100

test_wallet_vertical: add segwit 2fa test

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

diff --git a/electrum/tests/test_wallet_vertical.py b/electrum/tests/test_wallet_vertical.py @@ -157,7 +157,7 @@ class TestWalletKeystoreAddressIntegrityForMainnet(SequentialTestCase): @needs_test_with_all_ecc_implementations @mock.patch.object(storage.WalletStorage, '_write') - def test_electrum_seed_2fa(self, mock_write): + def test_electrum_seed_2fa_legacy(self, mock_write): seed_words = 'kiss live scene rude gate step hip quarter bunker oxygen motor glove' self.assertEqual(bitcoin.seed_type(seed_words), '2fa') @@ -192,6 +192,41 @@ class TestWalletKeystoreAddressIntegrityForMainnet(SequentialTestCase): @needs_test_with_all_ecc_implementations @mock.patch.object(storage.WalletStorage, '_write') + def test_electrum_seed_2fa_segwit(self, mock_write): + seed_words = 'universe topic remind silver february ranch shine worth innocent cattle enhance wise' + self.assertEqual(bitcoin.seed_type(seed_words), '2fa_segwit') + + 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, 'ZprvAm1R3RZMrkSLYKZer8QECGoc8oA1RQuKfsztHkBTmi2yF8RhmN1JRb7Ag69mMrL88sP67WiaegaSSDnKndorWEpFr7a5B2QgrD7TkERSYX6') + self.assertEqual(ks1.xpub, 'Zpub6yzmSw6Fh7zdkoe7x9wEZQkLgpzVpsdB36vV68b5L3Zx7vkrJuKYyPReXMSjBegmtUjFBxP2uZEdL87cYvtTtGaVuwtRRCTSFUsoAdKZMge') + self.assertEqual(ks1.xpub, xpub1) + + ks2 = keystore.from_xprv(xprv2) + self.assertTrue(isinstance(ks2, keystore.BIP32_KeyStore)) + self.assertEqual(ks2.xprv, 'ZprvAm1R3RZMrkSLab4jVKTwuroBgKEfnsmK9CQa1ErkuRzpsPauYuv9z2UzhDNn9YgbLHcmXpmxbNq4MdDRAUM5B2N9Wr3Uq9yp2c4AtTJDFdi') + self.assertEqual(ks2.xpub, 'Zpub6yzmSw6Fh7zdo59CbLzxGzjvEM5ACLVAWRLAodGNTmXokBv46TEQXpoUYUaoxPCeynysxg7APfScikCQ2jhCfM3NcNEk46BCVfSSrdrSkbR') + 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') + self.assertEqual(w.txin_type, 'p2wsh') + + self.assertEqual(w.get_receiving_addresses()[0], 'bc1qpmufh0zjp5prfsrk2yskcy82sa26srqkd97j0457andc6m0gh5asw7kqd2') + self.assertEqual(w.get_change_addresses()[0], 'bc1qd4q50nft7kxm9yglfnpup9ed2ukj3tkxp793y0zya8dc9m39jcwq308dxz') + + @needs_test_with_all_ecc_implementations + @mock.patch.object(storage.WalletStorage, '_write') def test_bip39_seed_bip44_standard(self, mock_write): seed_words = 'treat dwarf wealth gasp brass outside high rent blood crowd make initial' self.assertEqual(keystore.bip39_is_checksum_valid(seed_words), (True, True))