chore(tests): improving consistency of ethereum fixtures

pull/1821/head
grdddj 3 years ago committed by matejcik
parent aace875fef
commit 1a291660e5

@ -0,0 +1,43 @@
{
"setup": {
"mnemonic": "alcohol woman abuse must during monitor noble actual mixed trade anger aisle",
"passphrase": ""
},
"tests": [
{
"parameters": {
"path": "m/44'/60'/0'"
},
"result": {
"fingerprint": 3238854618,
"child_num": 2147483648,
"chain_code": "813d9feda6421f97a6472ff36679aa9e211ff88f6bdee51093af313ce628087e",
"public_key": "0318c22dedce01caca32354f98428e3af06a452f3fa84e6af8f1b6aa362affa641",
"xpub": "xpub6D54vV8eUYHMVBZCnz4SLjuiQngXURVCGKKGoJrWUDRegdMByLTJKfRs64q3UKiQCsSHJPtCQehTvERczdghS7gb8oedWSyNDtBU1zYDJtb"
}
},
{
"parameters": {
"path": "m/44'/60'/0'/0"
},
"result": {
"fingerprint": 2566851101,
"child_num": 0,
"chain_code": "ebccb5cbd84caa898472fc50a511b8653e234c3f2dd7bd4a5ec53f7073cc8c4f",
"public_key": "02d50ff29b89327b2ebce52cb751a11d074ab01394cb9e49f99ddc51da2146d212",
"xpub": "xpub6Ef8Pj4PmrkTkobADTAMrh9pejCJ3uQUBbBmCemKACT84p8SvsnkcwXb6pgeuYEseAwGkk7xuPmZt6oYnSFLrxvaBpCxjY4Jsg3zU1nuS41"
}
},
{
"parameters": {
"path": "m/44'/60'/0'/0/0"
},
"result": {
"fingerprint": 1762312360,
"child_num": 0,
"chain_code": "37526224b33a226749bd78e8e907e54cc46f7937362d34df7ebbfd06bc40a55c",
"public_key": "0327ceefada0c89b5ed12d163d5e3dc3b8f326321503a9bdbf6414367f3780b192",
"xpub": "xpub6GBpXvAiKQnvjHgC5qSoM3mJs4BGaRHeq8AYUf3bTyEyNx1fwhrDaX17wSwTzyjrbz2N85RLeJZqVsEJtGhsXZNJT7yMZ4mEs5T41jhg8U7"
}
} ]
}

File diff suppressed because one or more lines are too long

@ -8,11 +8,11 @@
"name": "Ethereum",
"parameters": {
"chain_id": 1,
"path": "44'/60'/0'/0/0",
"nonce": 0,
"gas_price": 20000000000,
"gas_limit": 21000,
"value": 10000000000,
"path": "m/44'/60'/0'/0/0",
"nonce": "0x0",
"gas_price": "0x4a817c800",
"gas_limit": "0x5208",
"value": "0x2540be400",
"to_address": "0x8eA7a3fccC211ED48b763b4164884DDbcF3b0A98",
"tx_type": null,
"data": ""
@ -27,11 +27,11 @@
"name": "Ropsten",
"parameters": {
"chain_id": 3,
"path": "44'/1'/0'/0/0",
"nonce": 0,
"gas_price": 20000000000,
"gas_limit": 21000,
"value": 10000000000,
"path": "m/44'/1'/0'/0/0",
"nonce": "0x0",
"gas_price": "0x4a817c800",
"gas_limit": "0x5208",
"value": "0x2540be400",
"to_address": "0x8eA7a3fccC211ED48b763b4164884DDbcF3b0A98",
"tx_type": null,
"data": ""
@ -46,11 +46,11 @@
"name": "Rinkeby",
"parameters": {
"chain_id": 4,
"path": "44'/1'/0'/0/0",
"nonce": 0,
"gas_price": 20000000000,
"gas_limit": 21000,
"value": 10000000000,
"path": "m/44'/1'/0'/0/0",
"nonce": "0x0",
"gas_price": "0x4a817c800",
"gas_limit": "0x5208",
"value": "0x2540be400",
"to_address": "0x8eA7a3fccC211ED48b763b4164884DDbcF3b0A98",
"tx_type": null,
"data": ""
@ -65,11 +65,11 @@
"name": "ETC",
"parameters": {
"chain_id": 61,
"path": "44'/61'/0'/0/0",
"nonce": 0,
"gas_price": 20000000000,
"gas_limit": 21000,
"value": 10000000000,
"path": "m/44'/61'/0'/0/0",
"nonce": "0x0",
"gas_price": "0x4a817c800",
"gas_limit": "0x5208",
"value": "0x2540be400",
"to_address": "0x8eA7a3fccC211ED48b763b4164884DDbcF3b0A98",
"tx_type": null,
"data": ""
@ -84,11 +84,11 @@
"name": "Auxilium",
"parameters": {
"chain_id": 28945486,
"path": "44'/344'/0'/0/0",
"nonce": 0,
"gas_price": 20000000000,
"gas_limit": 21000,
"value": 10000000000,
"path": "m/44'/344'/0'/0/0",
"nonce": "0x0",
"gas_price": "0x4a817c800",
"gas_limit": "0x5208",
"value": "0x2540be400",
"to_address": "0x8eA7a3fccC211ED48b763b4164884DDbcF3b0A98",
"tx_type": null,
"data": ""
@ -103,11 +103,11 @@
"name": "Pirl",
"parameters": {
"chain_id": 3125659152,
"path": "44'/164'/0'/0/0",
"nonce": 0,
"gas_price": 20000000000,
"gas_limit": 21000,
"value": 10000000000,
"path": "m/44'/164'/0'/0/0",
"nonce": "0x0",
"gas_price": "0x4a817c800",
"gas_limit": "0x5208",
"value": "0x2540be400",
"to_address": "0x8eA7a3fccC211ED48b763b4164884DDbcF3b0A98",
"tx_type": null,
"data": ""
@ -122,11 +122,11 @@
"name": "Unknown_chain_id_eth_path",
"parameters": {
"chain_id": 609112567,
"path": "44'/60'/0'/0/0",
"nonce": 0,
"gas_price": 20000000000,
"gas_limit": 21000,
"value": 10000000000,
"path": "m/44'/60'/0'/0/0",
"nonce": "0x0",
"gas_price": "0x4a817c800",
"gas_limit": "0x5208",
"value": "0x2540be400",
"to_address": "0x8eA7a3fccC211ED48b763b4164884DDbcF3b0A98",
"tx_type": null,
"data": ""
@ -141,11 +141,11 @@
"name": "Unknown_chain_id_testnet_path",
"parameters": {
"chain_id": 609112567,
"path": "44'/1'/0'/0/0",
"nonce": 0,
"gas_price": 20000000000,
"gas_limit": 21000,
"value": 10000000000,
"path": "m/44'/1'/0'/0/0",
"nonce": "0x0",
"gas_price": "0x4a817c800",
"gas_limit": "0x5208",
"value": "0x2540be400",
"to_address": "0x8eA7a3fccC211ED48b763b4164884DDbcF3b0A98",
"tx_type": null,
"data": ""
@ -160,11 +160,11 @@
"name": "Palm",
"parameters": {
"chain_id": 11297108109,
"path": "44'/60'/0'/0/0",
"nonce": 0,
"gas_price": 20000000000,
"gas_limit": 21000,
"value": 10000000000,
"path": "m/44'/60'/0'/0/0",
"nonce": "0x0",
"gas_price": "0x4a817c800",
"gas_limit": "0x5208",
"value": "0x2540be400",
"to_address": "0x8eA7a3fccC211ED48b763b4164884DDbcF3b0A98",
"tx_type": null,
"data": ""
@ -179,11 +179,11 @@
"name": "max_chain_id",
"parameters": {
"chain_id": 2147483629,
"path": "44'/1'/0'/0/0",
"nonce": 0,
"gas_price": 20000000000,
"gas_limit": 21000,
"value": 10000000000,
"path": "m/44'/1'/0'/0/0",
"nonce": "0x0",
"gas_price": "0x4a817c800",
"gas_limit": "0x5208",
"value": "0x2540be400",
"to_address": "0x8eA7a3fccC211ED48b763b4164884DDbcF3b0A98",
"tx_type": null,
"data": ""
@ -198,11 +198,11 @@
"name": "max_chain_plus_one",
"parameters": {
"chain_id": 2147483630,
"path": "44'/1'/0'/0/0",
"nonce": 0,
"gas_price": 20000000000,
"gas_limit": 21000,
"value": 10000000000,
"path": "m/44'/1'/0'/0/0",
"nonce": "0x0",
"gas_price": "0x4a817c800",
"gas_limit": "0x5208",
"value": "0x2540be400",
"to_address": "0x8eA7a3fccC211ED48b763b4164884DDbcF3b0A98",
"tx_type": null,
"data": ""
@ -217,11 +217,11 @@
"name": "max_uint64",
"parameters": {
"chain_id": 18446744073709551615,
"path": "44'/1'/0'/0/0",
"nonce": 0,
"gas_price": 20000000000,
"gas_limit": 21000,
"value": 10000000000,
"path": "m/44'/1'/0'/0/0",
"nonce": "0x0",
"gas_price": "0x4a817c800",
"gas_limit": "0x5208",
"value": "0x2540be400",
"to_address": "0x8eA7a3fccC211ED48b763b4164884DDbcF3b0A98",
"tx_type": null,
"data": ""

File diff suppressed because one or more lines are too long

@ -7,7 +7,7 @@
{
"parameters": {
"msg": "This is an example of a signed message.",
"path": "44'/60'/0'/0/0"
"path": "m/44'/60'/0'/0/0"
},
"result": {
"address": "0x73d0385F4d8E00C5e6504C6030F47BF6212736A8",
@ -17,7 +17,7 @@
{
"parameters": {
"msg": "VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!VeryLongMessage!",
"path": "44'/60'/0'/0/0"
"path": "m/44'/60'/0'/0/0"
},
"result": {
"address": "0x73d0385F4d8E00C5e6504C6030F47BF6212736A8",
@ -27,7 +27,7 @@
{
"parameters": {
"msg": "MsgLenIs9",
"path": "44'/60'/0'/0/0"
"path": "m/44'/60'/0'/0/0"
},
"result": {
"address": "0x73d0385F4d8E00C5e6504C6030F47BF6212736A8",
@ -37,7 +37,7 @@
{
"parameters": {
"msg": "MsgLenIs10",
"path": "44'/60'/0'/0/0"
"path": "m/44'/60'/0'/0/0"
},
"result": {
"address": "0x73d0385F4d8E00C5e6504C6030F47BF6212736A8",
@ -47,7 +47,7 @@
{
"parameters": {
"msg": "MsgLenIs11!",
"path": "44'/60'/0'/0/0"
"path": "m/44'/60'/0'/0/0"
},
"result": {
"address": "0x73d0385F4d8E00C5e6504C6030F47BF6212736A8",
@ -57,7 +57,7 @@
{
"parameters": {
"msg": "This message has length 99!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
"path": "44'/60'/0'/0/0"
"path": "m/44'/60'/0'/0/0"
},
"result": {
"address": "0x73d0385F4d8E00C5e6504C6030F47BF6212736A8",
@ -67,7 +67,7 @@
{
"parameters": {
"msg": "This message has length 100!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
"path": "44'/60'/0'/0/0"
"path": "m/44'/60'/0'/0/0"
},
"result": {
"address": "0x73d0385F4d8E00C5e6504C6030F47BF6212736A8",
@ -77,7 +77,7 @@
{
"parameters": {
"msg": "This message has length 101!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
"path": "44'/60'/0'/0/0"
"path": "m/44'/60'/0'/0/0"
},
"result": {
"address": "0x73d0385F4d8E00C5e6504C6030F47BF6212736A8",

@ -24,9 +24,7 @@ from ...common import parametrize_using_common_fixtures
pytestmark = [pytest.mark.altcoin, pytest.mark.ethereum]
@parametrize_using_common_fixtures(
"ethereum/getaddress.json",
)
@parametrize_using_common_fixtures("ethereum/getaddress.json")
def test_getaddress(client, parameters, result):
address_n = parse_path(parameters["path"])
assert ethereum.get_address(client, address_n) == result["address"]

@ -17,29 +17,20 @@
import pytest
from trezorlib import ethereum
from trezorlib.tools import H_
from trezorlib.tools import parse_path
from ...common import MNEMONIC12
from ...common import parametrize_using_common_fixtures
pytestmark = [pytest.mark.altcoin, pytest.mark.ethereum]
@pytest.mark.altcoin
@pytest.mark.ethereum
class TestMsgEthereumGetPublicKey:
@pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_ethereum_getpublickey(self, client):
res = ethereum.get_public_node(client, [H_(44), H_(60), H_(0)])
assert res.node.depth == 3
assert res.node.fingerprint == 0xC10CFFDA
assert res.node.child_num == 0x80000000
assert (
res.node.chain_code.hex()
== "813d9feda6421f97a6472ff36679aa9e211ff88f6bdee51093af313ce628087e"
)
assert (
res.node.public_key.hex()
== "0318c22dedce01caca32354f98428e3af06a452f3fa84e6af8f1b6aa362affa641"
)
assert (
res.xpub
== "xpub6D54vV8eUYHMVBZCnz4SLjuiQngXURVCGKKGoJrWUDRegdMByLTJKfRs64q3UKiQCsSHJPtCQehTvERczdghS7gb8oedWSyNDtBU1zYDJtb"
)
@parametrize_using_common_fixtures("ethereum/getpublickey.json")
def test_ethereum_getpublickey(client, parameters, result):
path = parse_path(parameters["path"])
res = ethereum.get_public_node(client, path)
assert res.node.depth == len(path)
assert res.node.fingerprint == result["fingerprint"]
assert res.node.child_num == result["child_num"]
assert res.node.chain_code.hex() == result["chain_code"]
assert res.node.public_key.hex() == result["public_key"]
assert res.xpub == result["xpub"]

@ -24,9 +24,7 @@ from ...common import parametrize_using_common_fixtures
pytestmark = [pytest.mark.altcoin, pytest.mark.ethereum]
@parametrize_using_common_fixtures(
"ethereum/signmessage.json",
)
@parametrize_using_common_fixtures("ethereum/signmessage.json")
def test_signmessage(client, parameters, result):
res = ethereum.sign_message(
client, parse_path(parameters["path"]), parameters["msg"]
@ -35,9 +33,7 @@ def test_signmessage(client, parameters, result):
assert res.signature.hex() == result["sig"]
@parametrize_using_common_fixtures(
"ethereum/verifymessage.json",
)
@parametrize_using_common_fixtures("ethereum/verifymessage.json")
def test_verify(client, parameters, result):
res = ethereum.verify_message(
client,

@ -37,12 +37,12 @@ def test_signtx(client, parameters, result):
sig_v, sig_r, sig_s = ethereum.sign_tx(
client,
n=parse_path(parameters["path"]),
nonce=parameters["nonce"],
gas_price=parameters["gas_price"],
gas_limit=parameters["gas_limit"],
nonce=int(parameters["nonce"], 16),
gas_price=int(parameters["gas_price"], 16),
gas_limit=int(parameters["gas_limit"], 16),
to=parameters["to_address"],
chain_id=parameters["chain_id"],
value=parameters["value"],
value=int(parameters["value"], 16),
tx_type=parameters["tx_type"],
data=bytes.fromhex(parameters["data"]),
)
@ -54,27 +54,25 @@ def test_signtx(client, parameters, result):
assert sig_v == result["sig_v"]
@parametrize_using_common_fixtures(
"ethereum/sign_tx_eip1559.json",
)
@parametrize_using_common_fixtures("ethereum/sign_tx_eip1559.json")
@pytest.mark.skip_t1
def test_signtx_eip1559(client, parameters, result):
with client:
sig_v, sig_r, sig_s = ethereum.sign_tx_eip1559(
client,
n=parse_path(parameters["path"]),
nonce=parameters["nonce"],
gas_limit=parameters["gas_limit"],
max_gas_fee=parameters["max_gas_fee"],
max_priority_fee=parameters["max_priority_fee"],
nonce=int(parameters["nonce"], 16),
gas_limit=int(parameters["gas_limit"], 16),
max_gas_fee=int(parameters["max_gas_fee"], 16),
max_priority_fee=int(parameters["max_priority_fee"], 16),
to=parameters["to_address"],
chain_id=parameters["chain_id"],
value=parameters["value"],
value=int(parameters["value"], 16),
data=bytes.fromhex(parameters["data"]),
)
assert sig_r.hex() == result["sig_r_hex"]
assert sig_s.hex() == result["sig_s_hex"]
assert sig_r.hex() == result["sig_r"]
assert sig_s.hex() == result["sig_s"]
assert sig_v == result["sig_v"]

@ -123,7 +123,9 @@
"ethereum-test_getaddress.py::test_getaddress[parameters1-result1]": "095af81ec79e9b510c90d9fa34fed343f3840807190c67bc237af885695ae687",
"ethereum-test_getaddress.py::test_getaddress[parameters2-result2]": "095af81ec79e9b510c90d9fa34fed343f3840807190c67bc237af885695ae687",
"ethereum-test_getaddress.py::test_getaddress[parameters3-result3]": "095af81ec79e9b510c90d9fa34fed343f3840807190c67bc237af885695ae687",
"ethereum-test_getpublickey.py-test_ethereum_getpublickey": "c09de07fbbf1e047442180e2facb5482d06a1a428891b875b7dd93c9e4704ae1",
"ethereum-test_getpublickey.py::test_ethereum_getpublickey[parameters0-result0]": "095af81ec79e9b510c90d9fa34fed343f3840807190c67bc237af885695ae687",
"ethereum-test_getpublickey.py::test_ethereum_getpublickey[parameters1-result1]": "095af81ec79e9b510c90d9fa34fed343f3840807190c67bc237af885695ae687",
"ethereum-test_getpublickey.py::test_ethereum_getpublickey[parameters2-result2]": "095af81ec79e9b510c90d9fa34fed343f3840807190c67bc237af885695ae687",
"ethereum-test_sign_verify_message.py::test_signmessage[parameters0-result0]": "9e2383084cfa23440e7ff9cf95029c73b851f5732de0cb4fb5e89a0ee024fbed",
"ethereum-test_sign_verify_message.py::test_signmessage[parameters1-result1]": "bd669f3ddc72582d3af7aa2e9757e68008690b78533f40eafacf0d071734c108",
"ethereum-test_sign_verify_message.py::test_signmessage[parameters2-result2]": "6ccc6102d1289bce13e28ec2207c96abe4aa1ac0810a13181a874070e7bcf8f3",

Loading…
Cancel
Save