From b6dc73ce9c9ef444205bf61f9173816ca0ce0fa9 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Mon, 31 Jul 2017 13:56:25 +0200 Subject: [PATCH] tests: fix bytes/str problem in test_msg_ethereum_signtx --- .../device_tests/test_msg_ethereum_signtx.py | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/tests/device_tests/test_msg_ethereum_signtx.py b/tests/device_tests/test_msg_ethereum_signtx.py index 8b13dd014c..885ab3b5a4 100644 --- a/tests/device_tests/test_msg_ethereum_signtx.py +++ b/tests/device_tests/test_msg_ethereum_signtx.py @@ -34,8 +34,8 @@ class TestMsgEthereumSigntx(common.TrezorTest): to=binascii.unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'), value=10) self.assertEqual(sig_v, 27) - self.assertEqual(binascii.hexlify(sig_r), '9b61192a161d056c66cfbbd331edb2d783a0193bd4f65f49ee965f791d898f72') - self.assertEqual(binascii.hexlify(sig_s), '49c0bbe35131592c6ed5c871ac457feeb16a1493f64237387fab9b83c1a202f7') + self.assertEqual(binascii.hexlify(sig_r), b'9b61192a161d056c66cfbbd331edb2d783a0193bd4f65f49ee965f791d898f72') + self.assertEqual(binascii.hexlify(sig_s), b'49c0bbe35131592c6ed5c871ac457feeb16a1493f64237387fab9b83c1a202f7') sig_v, sig_r, sig_s = self.client.ethereum_sign_tx( n=[0, 0], @@ -45,8 +45,8 @@ class TestMsgEthereumSigntx(common.TrezorTest): to=binascii.unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'), value=12345678901234567890) self.assertEqual(sig_v, 28) - self.assertEqual(binascii.hexlify(sig_r), '6de597b8ec1b46501e5b159676e132c1aa78a95bd5892ef23560a9867528975a') - self.assertEqual(binascii.hexlify(sig_s), '6e33c4230b1ecf96a8dbb514b4aec0a6d6ba53f8991c8143f77812aa6daa993f') + self.assertEqual(binascii.hexlify(sig_r), b'6de597b8ec1b46501e5b159676e132c1aa78a95bd5892ef23560a9867528975a') + self.assertEqual(binascii.hexlify(sig_s), b'6e33c4230b1ecf96a8dbb514b4aec0a6d6ba53f8991c8143f77812aa6daa993f') def test_ethereum_signtx_data(self): self.setup_mnemonic_nopin_nopassphrase() @@ -58,10 +58,10 @@ class TestMsgEthereumSigntx(common.TrezorTest): gas_limit=20, to=binascii.unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'), value=10, - data='abcdefghijklmnop' * 16) + data=b'abcdefghijklmnop' * 16) self.assertEqual(sig_v, 28) - self.assertEqual(binascii.hexlify(sig_r), '6da89ed8627a491bedc9e0382f37707ac4e5102e25e7a1234cb697cedb7cd2c0') - self.assertEqual(binascii.hexlify(sig_s), '691f73b145647623e2d115b208a7c3455a6a8a83e3b4db5b9c6d9bc75825038a') + self.assertEqual(binascii.hexlify(sig_r), b'6da89ed8627a491bedc9e0382f37707ac4e5102e25e7a1234cb697cedb7cd2c0') + self.assertEqual(binascii.hexlify(sig_s), b'691f73b145647623e2d115b208a7c3455a6a8a83e3b4db5b9c6d9bc75825038a') sig_v, sig_r, sig_s = self.client.ethereum_sign_tx( n=[0, 0], @@ -70,10 +70,10 @@ class TestMsgEthereumSigntx(common.TrezorTest): gas_limit=20000, to=binascii.unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'), value=12345678901234567890, - data='ABCDEFGHIJKLMNOP' * 256 + '!!!') + data=b'ABCDEFGHIJKLMNOP' * 256 + b'!!!') self.assertEqual(sig_v, 28) - self.assertEqual(binascii.hexlify(sig_r), '4e90b13c45c6a9bf4aaad0e5427c3e62d76692b36eb727c78d332441b7400404') - self.assertEqual(binascii.hexlify(sig_s), '3ff236e7d05f0f9b1ee3d70599bb4200638f28388a8faf6bb36db9e04dc544be') + self.assertEqual(binascii.hexlify(sig_r), b'4e90b13c45c6a9bf4aaad0e5427c3e62d76692b36eb727c78d332441b7400404') + self.assertEqual(binascii.hexlify(sig_s), b'3ff236e7d05f0f9b1ee3d70599bb4200638f28388a8faf6bb36db9e04dc544be') def test_ethereum_signtx_message(self): self.setup_mnemonic_nopin_nopassphrase() @@ -85,10 +85,10 @@ class TestMsgEthereumSigntx(common.TrezorTest): gas_limit=20000, to=binascii.unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'), value=0, - data='ABCDEFGHIJKLMNOP' * 256 + '!!!') + data=b'ABCDEFGHIJKLMNOP' * 256 + b'!!!') self.assertEqual(sig_v, 28) - self.assertEqual(binascii.hexlify(sig_r), '070e9dafda4d9e733fa7b6747a75f8a4916459560efb85e3e73cd39f31aa160d') - self.assertEqual(binascii.hexlify(sig_s), '7842db33ef15c27049ed52741db41fe3238a6fa3a6a0888fcfb74d6917600e41') + self.assertEqual(binascii.hexlify(sig_r), b'070e9dafda4d9e733fa7b6747a75f8a4916459560efb85e3e73cd39f31aa160d') + self.assertEqual(binascii.hexlify(sig_s), b'7842db33ef15c27049ed52741db41fe3238a6fa3a6a0888fcfb74d6917600e41') def test_ethereum_signtx_newcontract(self): self.setup_mnemonic_nopin_nopassphrase() @@ -112,10 +112,10 @@ class TestMsgEthereumSigntx(common.TrezorTest): gas_limit=20000, to='', value=12345678901234567890, - data='ABCDEFGHIJKLMNOP' * 256 + '!!!') + data=b'ABCDEFGHIJKLMNOP' * 256 + b'!!!') self.assertEqual(sig_v, 28) - self.assertEqual(binascii.hexlify(sig_r), 'b401884c10ae435a2e792303b5fc257a09f94403b2883ad8c0ac7a7282f5f1f9') - self.assertEqual(binascii.hexlify(sig_s), '4742fc9e6a5fa8db3db15c2d856914a7f3daab21603a6c1ce9e9927482f8352e') + self.assertEqual(binascii.hexlify(sig_r), b'b401884c10ae435a2e792303b5fc257a09f94403b2883ad8c0ac7a7282f5f1f9') + self.assertEqual(binascii.hexlify(sig_s), b'4742fc9e6a5fa8db3db15c2d856914a7f3daab21603a6c1ce9e9927482f8352e') def test_ethereum_sanity_checks(self): # gas overflow @@ -175,8 +175,8 @@ class TestMsgEthereumSigntx(common.TrezorTest): value=100000000000000000, chain_id=3) self.assertEqual(sig_v, 41) - self.assertEqual(binascii.hexlify(sig_r), 'a90d0bc4f8d63be69453dd62f2bb5fff53c610000abf956672564d8a654d401a') - self.assertEqual(binascii.hexlify(sig_s), '544a2e57bc8b4da18660a1e6036967ea581cc635f5137e3ba97a750867c27cf2') + self.assertEqual(binascii.hexlify(sig_r), b'a90d0bc4f8d63be69453dd62f2bb5fff53c610000abf956672564d8a654d401a') + self.assertEqual(binascii.hexlify(sig_s), b'544a2e57bc8b4da18660a1e6036967ea581cc635f5137e3ba97a750867c27cf2') sig_v, sig_r, sig_s = self.client.ethereum_sign_tx( n=[0x80000000 | 44, 0x80000000 | 1, 0x80000000, 0, 0], @@ -187,8 +187,8 @@ class TestMsgEthereumSigntx(common.TrezorTest): value=100000000000000000, chain_id=3) self.assertEqual(sig_v, 42) - self.assertEqual(binascii.hexlify(sig_r), '699428a6950e23c6843f1bf3754f847e64e047e829978df80d55187d19a401ce') - self.assertEqual(binascii.hexlify(sig_s), '087343d0a3a2f10842218ffccb146b59a8431b6245ab389fde22dc833f171e6e') + self.assertEqual(binascii.hexlify(sig_r), b'699428a6950e23c6843f1bf3754f847e64e047e829978df80d55187d19a401ce') + self.assertEqual(binascii.hexlify(sig_s), b'087343d0a3a2f10842218ffccb146b59a8431b6245ab389fde22dc833f171e6e') def test_ethereum_signtx_data_eip155(self): self.setup_mnemonic_allallall() @@ -200,11 +200,11 @@ class TestMsgEthereumSigntx(common.TrezorTest): gas_limit=21004, to=binascii.unhexlify('8ea7a3fccc211ed48b763b4164884ddbcf3b0a98'), value=100000000000000000, - data='\0', + data=b'\0', chain_id=3) self.assertEqual(sig_v, 42) - self.assertEqual(binascii.hexlify(sig_r), 'ba85b622a8bb82606ba96c132e81fa8058172192d15bc41d7e57c031bca17df4') - self.assertEqual(binascii.hexlify(sig_s), '6473b75997634b6f692f8d672193591d299d5bf1c2d6e51f1a14ed0530b91c7d') + self.assertEqual(binascii.hexlify(sig_r), b'ba85b622a8bb82606ba96c132e81fa8058172192d15bc41d7e57c031bca17df4') + self.assertEqual(binascii.hexlify(sig_s), b'6473b75997634b6f692f8d672193591d299d5bf1c2d6e51f1a14ed0530b91c7d') sig_v, sig_r, sig_s = self.client.ethereum_sign_tx( n=[0x80000000 | 44, 0x80000000 | 1, 0x80000000, 0, 0], @@ -213,11 +213,11 @@ class TestMsgEthereumSigntx(common.TrezorTest): gas_limit=299732, to=binascii.unhexlify('8ea7a3fccc211ed48b763b4164884ddbcf3b0a98'), value=100000000000000000, - data='ABCDEFGHIJKLMNOP' * 256 + '!!!', + data=b'ABCDEFGHIJKLMNOP' * 256 + b'!!!', chain_id=3) self.assertEqual(sig_v, 42) - self.assertEqual(binascii.hexlify(sig_r), 'd021c98f92859c8db5e4de2f0e410a8deb0c977eb1a631e323ebf7484bd0d79a') - self.assertEqual(binascii.hexlify(sig_s), '2c0e9defc9b1e895dc9520ff25ba3c635b14ad70aa86a5ad6c0a3acb82b569b6') + self.assertEqual(binascii.hexlify(sig_r), b'd021c98f92859c8db5e4de2f0e410a8deb0c977eb1a631e323ebf7484bd0d79a') + self.assertEqual(binascii.hexlify(sig_s), b'2c0e9defc9b1e895dc9520ff25ba3c635b14ad70aa86a5ad6c0a3acb82b569b6') sig_v, sig_r, sig_s = self.client.ethereum_sign_tx( n=[0x80000000 | 44, 0x80000000 | 1, 0x80000000, 0, 0], @@ -226,11 +226,11 @@ class TestMsgEthereumSigntx(common.TrezorTest): gas_limit=21004, to=binascii.unhexlify('8ea7a3fccc211ed48b763b4164884ddbcf3b0a98'), value=0, - data='\0', + data=b'\0', chain_id=3) self.assertEqual(sig_v, 42) - self.assertEqual(binascii.hexlify(sig_r), 'dd52f026972a83c56b7dea356836fcfc70a68e3b879cdc8ef2bb5fea23e0a7aa') - self.assertEqual(binascii.hexlify(sig_s), '079285fe579c9a2da25c811b1c5c0a74cd19b6301ee42cf20ef7b3b1353f7242') + self.assertEqual(binascii.hexlify(sig_r), b'dd52f026972a83c56b7dea356836fcfc70a68e3b879cdc8ef2bb5fea23e0a7aa') + self.assertEqual(binascii.hexlify(sig_s), b'079285fe579c9a2da25c811b1c5c0a74cd19b6301ee42cf20ef7b3b1353f7242') sig_v, sig_r, sig_s = self.client.ethereum_sign_tx( n=[0x80000000 | 44, 0x80000000 | 1, 0x80000000, 0, 0], @@ -239,8 +239,8 @@ class TestMsgEthereumSigntx(common.TrezorTest): gas_limit=21004, to=binascii.unhexlify('8ea7a3fccc211ed48b763b4164884ddbcf3b0a98'), value=0, - data='\0', + data=b'\0', chain_id=3) self.assertEqual(sig_v, 42) - self.assertEqual(binascii.hexlify(sig_r), 'f7505f709d5999343aea3c384034c62d0514336ff6c6af65582006f708f81503') - self.assertEqual(binascii.hexlify(sig_s), '44e09e29a4b6247000b46ddc94fe391e94deb2b39ad6ac6398e6db5bec095ba9') + self.assertEqual(binascii.hexlify(sig_r), b'f7505f709d5999343aea3c384034c62d0514336ff6c6af65582006f708f81503') + self.assertEqual(binascii.hexlify(sig_s), b'44e09e29a4b6247000b46ddc94fe391e94deb2b39ad6ac6398e6db5bec095ba9')