1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-25 07:48:10 +00:00

Fix tests broken by API changes

This commit is contained in:
Yura Pakhuchiy 2018-07-02 14:42:11 +07:00 committed by Pavol Rusnak
parent d09547fec3
commit 4237adb7cc
3 changed files with 18 additions and 14 deletions

View File

@ -12,7 +12,7 @@ class TestAddress(unittest.TestCase):
coin = coins.by_name('Testnet') coin = coins.by_name('Testnet')
address = address_p2wpkh_in_p2sh( address = address_p2wpkh_in_p2sh(
unhexlify('03a1af804ac108a8a51782198c2d034b28bf90c8803f5a53f76276fa69a4eae77f'), unhexlify('03a1af804ac108a8a51782198c2d034b28bf90c8803f5a53f76276fa69a4eae77f'),
coin.address_type_p2sh coin
) )
self.assertEqual(address, '2Mww8dCYPUpKHofjgcXcBCEGmniw9CoaiD2') self.assertEqual(address, '2Mww8dCYPUpKHofjgcXcBCEGmniw9CoaiD2')
@ -22,17 +22,17 @@ class TestAddress(unittest.TestCase):
root = bip32.from_seed(seed, 'secp256k1') root = bip32.from_seed(seed, 'secp256k1')
node = node_derive(root, [49 | 0x80000000, 1 | 0x80000000, 0 | 0x80000000, 1, 0]) node = node_derive(root, [49 | 0x80000000, 1 | 0x80000000, 0 | 0x80000000, 1, 0])
address = address_p2wpkh_in_p2sh(node.public_key(), coin.address_type_p2sh) address = address_p2wpkh_in_p2sh(node.public_key(), coin)
self.assertEqual(address, '2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX') self.assertEqual(address, '2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX')
node = node_derive(root, [49 | 0x80000000, 1 | 0x80000000, 0 | 0x80000000, 1, 1]) node = node_derive(root, [49 | 0x80000000, 1 | 0x80000000, 0 | 0x80000000, 1, 1])
address = address_p2wpkh_in_p2sh(node.public_key(), coin.address_type_p2sh) address = address_p2wpkh_in_p2sh(node.public_key(), coin)
self.assertEqual(address, '2NFWLCJQBSpz1oUJwwLpX8ECifFWGznBVqs') self.assertEqual(address, '2NFWLCJQBSpz1oUJwwLpX8ECifFWGznBVqs')
node = node_derive(root, [49 | 0x80000000, 1 | 0x80000000, 0 | 0x80000000, 0, 0]) node = node_derive(root, [49 | 0x80000000, 1 | 0x80000000, 0 | 0x80000000, 0, 0])
address = address_p2wpkh_in_p2sh(node.public_key(), coin.address_type_p2sh) address = address_p2wpkh_in_p2sh(node.public_key(), coin)
self.assertEqual(address, '2N4Q5FhU2497BryFfUgbqkAJE87aKHUhXMp') self.assertEqual(address, '2N4Q5FhU2497BryFfUgbqkAJE87aKHUhXMp')
@ -50,7 +50,7 @@ class TestAddress(unittest.TestCase):
address = address_p2sh( address = address_p2sh(
unhexlify('7a55d61848e77ca266e79a39bfc85c580a6426c9'), unhexlify('7a55d61848e77ca266e79a39bfc85c580a6426c9'),
coin.address_type_p2sh coin
) )
self.assertEqual(address, '2N4Q5FhU2497BryFfUgbqkAJE87aKHUhXMp') self.assertEqual(address, '2N4Q5FhU2497BryFfUgbqkAJE87aKHUhXMp')
@ -74,7 +74,7 @@ class TestAddress(unittest.TestCase):
# test data from Mastering Bitcoin # test data from Mastering Bitcoin
address = address_p2wsh_in_p2sh( address = address_p2wsh_in_p2sh(
unhexlify('9592d601848d04b172905e0ddb0adde59f1590f1e553ffc81ddc4b0ed927dd73'), unhexlify('9592d601848d04b172905e0ddb0adde59f1590f1e553ffc81ddc4b0ed927dd73'),
coin.address_type_p2sh coin
) )
self.assertEqual(address, '3Dwz1MXhM6EfFoJChHCxh1jWHb8GQqRenG') self.assertEqual(address, '3Dwz1MXhM6EfFoJChHCxh1jWHb8GQqRenG')
@ -96,7 +96,7 @@ class TestAddress(unittest.TestCase):
unhexlify('02fe6f0a5a297eb38c391581c4413e084773ea23954d93f7753db7dc0adc188b2f'), unhexlify('02fe6f0a5a297eb38c391581c4413e084773ea23954d93f7753db7dc0adc188b2f'),
unhexlify('02ff12471208c14bd580709cb2358d98975247d8765f92bc25eab3b2763ed605f8'), unhexlify('02ff12471208c14bd580709cb2358d98975247d8765f92bc25eab3b2763ed605f8'),
] ]
address = address_multisig_p2sh(pubkeys, 2, coin.address_type_p2sh) address = address_multisig_p2sh(pubkeys, 2, coin)
self.assertEqual(address, '39bgKC7RFbpoCRbtD5KEdkYKtNyhpsNa3Z') self.assertEqual(address, '39bgKC7RFbpoCRbtD5KEdkYKtNyhpsNa3Z')
def test_multisig_address_p2wsh_in_p2sh(self): def test_multisig_address_p2wsh_in_p2sh(self):
@ -108,7 +108,7 @@ class TestAddress(unittest.TestCase):
unhexlify('0320ce424c6d61f352ccfea60d209651672cfb03b2dc77d1d64d3ba519aec756ae'), unhexlify('0320ce424c6d61f352ccfea60d209651672cfb03b2dc77d1d64d3ba519aec756ae'),
] ]
address = address_multisig_p2wsh_in_p2sh(pubkeys, 2, coin.address_type_p2sh) address = address_multisig_p2wsh_in_p2sh(pubkeys, 2, coin)
self.assertEqual(address, '2MsZ2fpGKUydzY62v6trPHR8eCx5JTy1Dpa') self.assertEqual(address, '2MsZ2fpGKUydzY62v6trPHR8eCx5JTy1Dpa')
# def test_multisig_address_p2wsh(self): # def test_multisig_address_p2wsh(self):

View File

@ -45,14 +45,16 @@ class TestSegwitBip143NativeP2WPKH(unittest.TestCase):
bip143 = Bip143() bip143 = Bip143()
bip143.add_prevouts(self.inp1) bip143.add_prevouts(self.inp1)
bip143.add_prevouts(self.inp2) bip143.add_prevouts(self.inp2)
self.assertEqual(hexlify(bip143.get_prevouts_hash()), b'96b827c8483d4e9b96712b6713a7b68d6e8003a781feba36c31143470b4efd37') coin = coins.by_name(self.tx.coin_name)
self.assertEqual(hexlify(bip143.get_prevouts_hash(coin)), b'96b827c8483d4e9b96712b6713a7b68d6e8003a781feba36c31143470b4efd37')
def test_sequence(self): def test_sequence(self):
bip143 = Bip143() bip143 = Bip143()
bip143.add_sequence(self.inp1) bip143.add_sequence(self.inp1)
bip143.add_sequence(self.inp2) bip143.add_sequence(self.inp2)
self.assertEqual(hexlify(bip143.get_sequence_hash()), b'52b0a642eea2fb7ae638c36f6252b6750293dbe574a806984b8e4d8548339a3b') coin = coins.by_name(self.tx.coin_name)
self.assertEqual(hexlify(bip143.get_sequence_hash(coin)), b'52b0a642eea2fb7ae638c36f6252b6750293dbe574a806984b8e4d8548339a3b')
def test_outputs(self): def test_outputs(self):
@ -68,7 +70,7 @@ class TestSegwitBip143NativeP2WPKH(unittest.TestCase):
txo_bin.script_pubkey = output_derive_script(txo, coin, root) txo_bin.script_pubkey = output_derive_script(txo, coin, root)
bip143.add_output(txo_bin) bip143.add_output(txo_bin)
self.assertEqual(hexlify(bip143.get_outputs_hash()), self.assertEqual(hexlify(bip143.get_outputs_hash(coin)),
b'863ef3e1a92afbfdb97f31ad0fc7683ee943e9abcf2501590ff8f6551f47e5e5') b'863ef3e1a92afbfdb97f31ad0fc7683ee943e9abcf2501590ff8f6551f47e5e5')
def test_preimage_testdata(self): def test_preimage_testdata(self):

View File

@ -36,13 +36,15 @@ class TestSegwitBip143(unittest.TestCase):
bip143 = Bip143() bip143 = Bip143()
bip143.add_prevouts(self.inp1) bip143.add_prevouts(self.inp1)
self.assertEqual(hexlify(bip143.get_prevouts_hash()), b'b0287b4a252ac05af83d2dcef00ba313af78a3e9c329afa216eb3aa2a7b4613a') coin = coins.by_name(self.tx.coin_name)
self.assertEqual(hexlify(bip143.get_prevouts_hash(coin)), b'b0287b4a252ac05af83d2dcef00ba313af78a3e9c329afa216eb3aa2a7b4613a')
def test_bip143_sequence(self): def test_bip143_sequence(self):
bip143 = Bip143() bip143 = Bip143()
bip143.add_sequence(self.inp1) bip143.add_sequence(self.inp1)
self.assertEqual(hexlify(bip143.get_sequence_hash()), b'18606b350cd8bf565266bc352f0caddcf01e8fa789dd8a15386327cf8cabe198') coin = coins.by_name(self.tx.coin_name)
self.assertEqual(hexlify(bip143.get_sequence_hash(coin)), b'18606b350cd8bf565266bc352f0caddcf01e8fa789dd8a15386327cf8cabe198')
def test_bip143_outputs(self): def test_bip143_outputs(self):
@ -58,7 +60,7 @@ class TestSegwitBip143(unittest.TestCase):
txo_bin.script_pubkey = output_derive_script(txo, coin, root) txo_bin.script_pubkey = output_derive_script(txo, coin, root)
bip143.add_output(txo_bin) bip143.add_output(txo_bin)
self.assertEqual(hexlify(bip143.get_outputs_hash()), self.assertEqual(hexlify(bip143.get_outputs_hash(coin)),
b'de984f44532e2173ca0d64314fcefe6d30da6f8cf27bafa706da61df8a226c83') b'de984f44532e2173ca0d64314fcefe6d30da6f8cf27bafa706da61df8a226c83')
def test_bip143_preimage_testdata(self): def test_bip143_preimage_testdata(self):