mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-05 13:01:12 +00:00
tests/device: ethereum sign tx with expected checks
This commit is contained in:
parent
e618402429
commit
4bbf5880ce
@ -17,6 +17,7 @@
|
|||||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from .common import *
|
from .common import *
|
||||||
|
from trezorlib import messages as proto
|
||||||
|
|
||||||
|
|
||||||
class TestMsgEthereumSigntx(TrezorTest):
|
class TestMsgEthereumSigntx(TrezorTest):
|
||||||
@ -24,6 +25,13 @@ class TestMsgEthereumSigntx(TrezorTest):
|
|||||||
def test_ethereum_signtx_nodata(self):
|
def test_ethereum_signtx_nodata(self):
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
self.setup_mnemonic_nopin_nopassphrase()
|
||||||
|
|
||||||
|
with self.client:
|
||||||
|
self.client.set_expected_responses([
|
||||||
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
|
proto.EthereumTxRequest(data_length=None), # v,r,s checked with assert
|
||||||
|
])
|
||||||
|
|
||||||
sig_v, sig_r, sig_s = self.client.ethereum_sign_tx(
|
sig_v, sig_r, sig_s = self.client.ethereum_sign_tx(
|
||||||
n=[0, 0],
|
n=[0, 0],
|
||||||
nonce=0,
|
nonce=0,
|
||||||
@ -31,10 +39,18 @@ class TestMsgEthereumSigntx(TrezorTest):
|
|||||||
gas_limit=20,
|
gas_limit=20,
|
||||||
to=unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'),
|
to=unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'),
|
||||||
value=10)
|
value=10)
|
||||||
|
|
||||||
assert sig_v == 27
|
assert sig_v == 27
|
||||||
assert hexlify(sig_r) == b'9b61192a161d056c66cfbbd331edb2d783a0193bd4f65f49ee965f791d898f72'
|
assert hexlify(sig_r) == b'9b61192a161d056c66cfbbd331edb2d783a0193bd4f65f49ee965f791d898f72'
|
||||||
assert hexlify(sig_s) == b'49c0bbe35131592c6ed5c871ac457feeb16a1493f64237387fab9b83c1a202f7'
|
assert hexlify(sig_s) == b'49c0bbe35131592c6ed5c871ac457feeb16a1493f64237387fab9b83c1a202f7'
|
||||||
|
|
||||||
|
with self.client:
|
||||||
|
self.client.set_expected_responses([
|
||||||
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
|
proto.EthereumTxRequest(data_length=None),
|
||||||
|
])
|
||||||
|
|
||||||
sig_v, sig_r, sig_s = self.client.ethereum_sign_tx(
|
sig_v, sig_r, sig_s = self.client.ethereum_sign_tx(
|
||||||
n=[0, 0],
|
n=[0, 0],
|
||||||
nonce=123456,
|
nonce=123456,
|
||||||
@ -49,6 +65,14 @@ class TestMsgEthereumSigntx(TrezorTest):
|
|||||||
def test_ethereum_signtx_data(self):
|
def test_ethereum_signtx_data(self):
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
self.setup_mnemonic_nopin_nopassphrase()
|
||||||
|
|
||||||
|
with self.client:
|
||||||
|
self.client.set_expected_responses([
|
||||||
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
|
proto.EthereumTxRequest(data_length=None),
|
||||||
|
])
|
||||||
|
|
||||||
sig_v, sig_r, sig_s = self.client.ethereum_sign_tx(
|
sig_v, sig_r, sig_s = self.client.ethereum_sign_tx(
|
||||||
n=[0, 0],
|
n=[0, 0],
|
||||||
nonce=0,
|
nonce=0,
|
||||||
@ -61,6 +85,19 @@ class TestMsgEthereumSigntx(TrezorTest):
|
|||||||
assert hexlify(sig_r) == b'6da89ed8627a491bedc9e0382f37707ac4e5102e25e7a1234cb697cedb7cd2c0'
|
assert hexlify(sig_r) == b'6da89ed8627a491bedc9e0382f37707ac4e5102e25e7a1234cb697cedb7cd2c0'
|
||||||
assert hexlify(sig_s) == b'691f73b145647623e2d115b208a7c3455a6a8a83e3b4db5b9c6d9bc75825038a'
|
assert hexlify(sig_s) == b'691f73b145647623e2d115b208a7c3455a6a8a83e3b4db5b9c6d9bc75825038a'
|
||||||
|
|
||||||
|
|
||||||
|
with self.client:
|
||||||
|
self.client.set_expected_responses([
|
||||||
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
|
proto.EthereumTxRequest(data_length=1024, signature_r=None, signature_s=None, signature_v=None),
|
||||||
|
proto.EthereumTxRequest(data_length=1024),
|
||||||
|
proto.EthereumTxRequest(data_length=1024),
|
||||||
|
proto.EthereumTxRequest(data_length=3),
|
||||||
|
proto.EthereumTxRequest(),
|
||||||
|
])
|
||||||
|
|
||||||
sig_v, sig_r, sig_s = self.client.ethereum_sign_tx(
|
sig_v, sig_r, sig_s = self.client.ethereum_sign_tx(
|
||||||
n=[0, 0],
|
n=[0, 0],
|
||||||
nonce=123456,
|
nonce=123456,
|
||||||
@ -76,6 +113,18 @@ class TestMsgEthereumSigntx(TrezorTest):
|
|||||||
def test_ethereum_signtx_message(self):
|
def test_ethereum_signtx_message(self):
|
||||||
self.setup_mnemonic_nopin_nopassphrase()
|
self.setup_mnemonic_nopin_nopassphrase()
|
||||||
|
|
||||||
|
with self.client:
|
||||||
|
self.client.set_expected_responses([
|
||||||
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
|
proto.EthereumTxRequest(data_length=1024, signature_r=None, signature_s=None, signature_v=None),
|
||||||
|
proto.EthereumTxRequest(data_length=1024),
|
||||||
|
proto.EthereumTxRequest(data_length=1024),
|
||||||
|
proto.EthereumTxRequest(data_length=3),
|
||||||
|
proto.EthereumTxRequest(),
|
||||||
|
])
|
||||||
|
|
||||||
sig_v, sig_r, sig_s = self.client.ethereum_sign_tx(
|
sig_v, sig_r, sig_s = self.client.ethereum_sign_tx(
|
||||||
n=[0, 0],
|
n=[0, 0],
|
||||||
nonce=0,
|
nonce=0,
|
||||||
@ -102,6 +151,18 @@ class TestMsgEthereumSigntx(TrezorTest):
|
|||||||
value=12345678901234567890
|
value=12345678901234567890
|
||||||
)
|
)
|
||||||
|
|
||||||
|
with self.client:
|
||||||
|
self.client.set_expected_responses([
|
||||||
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
|
proto.EthereumTxRequest(data_length=1024, signature_r=None, signature_s=None, signature_v=None),
|
||||||
|
proto.EthereumTxRequest(data_length=1024),
|
||||||
|
proto.EthereumTxRequest(data_length=1024),
|
||||||
|
proto.EthereumTxRequest(data_length=3),
|
||||||
|
proto.EthereumTxRequest(),
|
||||||
|
])
|
||||||
|
|
||||||
sig_v, sig_r, sig_s = self.client.ethereum_sign_tx(
|
sig_v, sig_r, sig_s = self.client.ethereum_sign_tx(
|
||||||
n=[0, 0],
|
n=[0, 0],
|
||||||
nonce=0,
|
nonce=0,
|
||||||
@ -159,6 +220,14 @@ class TestMsgEthereumSigntx(TrezorTest):
|
|||||||
def test_ethereum_signtx_nodata_eip155(self):
|
def test_ethereum_signtx_nodata_eip155(self):
|
||||||
self.setup_mnemonic_allallall()
|
self.setup_mnemonic_allallall()
|
||||||
|
|
||||||
|
|
||||||
|
with self.client:
|
||||||
|
self.client.set_expected_responses([
|
||||||
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
|
proto.EthereumTxRequest(),
|
||||||
|
])
|
||||||
|
|
||||||
sig_v, sig_r, sig_s = self.client.ethereum_sign_tx(
|
sig_v, sig_r, sig_s = self.client.ethereum_sign_tx(
|
||||||
n=[0x80000000 | 44, 0x80000000 | 1, 0x80000000, 0, 0],
|
n=[0x80000000 | 44, 0x80000000 | 1, 0x80000000, 0, 0],
|
||||||
nonce=0,
|
nonce=0,
|
||||||
@ -171,6 +240,7 @@ class TestMsgEthereumSigntx(TrezorTest):
|
|||||||
assert hexlify(sig_r) == b'a90d0bc4f8d63be69453dd62f2bb5fff53c610000abf956672564d8a654d401a'
|
assert hexlify(sig_r) == b'a90d0bc4f8d63be69453dd62f2bb5fff53c610000abf956672564d8a654d401a'
|
||||||
assert hexlify(sig_s) == b'544a2e57bc8b4da18660a1e6036967ea581cc635f5137e3ba97a750867c27cf2'
|
assert hexlify(sig_s) == b'544a2e57bc8b4da18660a1e6036967ea581cc635f5137e3ba97a750867c27cf2'
|
||||||
|
|
||||||
|
|
||||||
sig_v, sig_r, sig_s = self.client.ethereum_sign_tx(
|
sig_v, sig_r, sig_s = self.client.ethereum_sign_tx(
|
||||||
n=[0x80000000 | 44, 0x80000000 | 1, 0x80000000, 0, 0],
|
n=[0x80000000 | 44, 0x80000000 | 1, 0x80000000, 0, 0],
|
||||||
nonce=1,
|
nonce=1,
|
||||||
@ -186,6 +256,14 @@ class TestMsgEthereumSigntx(TrezorTest):
|
|||||||
def test_ethereum_signtx_data_eip155(self):
|
def test_ethereum_signtx_data_eip155(self):
|
||||||
self.setup_mnemonic_allallall()
|
self.setup_mnemonic_allallall()
|
||||||
|
|
||||||
|
with self.client:
|
||||||
|
self.client.set_expected_responses([
|
||||||
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
|
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||||
|
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||||
|
proto.EthereumTxRequest(),
|
||||||
|
])
|
||||||
|
|
||||||
sig_v, sig_r, sig_s = self.client.ethereum_sign_tx(
|
sig_v, sig_r, sig_s = self.client.ethereum_sign_tx(
|
||||||
n=[0x80000000 | 44, 0x80000000 | 1, 0x80000000, 0, 0],
|
n=[0x80000000 | 44, 0x80000000 | 1, 0x80000000, 0, 0],
|
||||||
nonce=2,
|
nonce=2,
|
||||||
|
Loading…
Reference in New Issue
Block a user