mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-30 19:38:15 +00:00
refactor(tests): use same path in per-node specification
This commit is contained in:
parent
a67c7cdf5a
commit
e8c64a539c
@ -300,27 +300,22 @@ def test_multisig(client: Client):
|
||||
@pytest.mark.multisig
|
||||
@pytest.mark.parametrize("show_display", (True, False))
|
||||
def test_multisig_missing(client: Client, show_display):
|
||||
# Multisig with global suffix specification.
|
||||
# Use account numbers 1, 2 and 3 to create a valid multisig,
|
||||
# but not containing the keys from account 0 used below.
|
||||
nodes = [
|
||||
btc.get_public_node(client, parse_path(f"m/44h/0h/{i}h")).node
|
||||
for i in range(1, 4)
|
||||
]
|
||||
|
||||
# Multisig with global suffix specification.
|
||||
multisig1 = messages.MultisigRedeemScriptType(
|
||||
nodes=nodes, address_n=[0, 0], signatures=[b"", b"", b""], m=2
|
||||
)
|
||||
|
||||
# Multisig with per-node suffix specification.
|
||||
node = btc.get_public_node(
|
||||
client, parse_path("m/44h/0h/0h/0"), coin_name="Bitcoin"
|
||||
).node
|
||||
|
||||
multisig2 = messages.MultisigRedeemScriptType(
|
||||
pubkeys=[
|
||||
messages.HDNodePathType(node=node, address_n=[1]),
|
||||
messages.HDNodePathType(node=node, address_n=[2]),
|
||||
messages.HDNodePathType(node=node, address_n=[3]),
|
||||
messages.HDNodePathType(node=node, address_n=[0, 0]) for node in nodes
|
||||
],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
|
@ -169,26 +169,22 @@ def test_show_multisig_3(client: Client):
|
||||
@pytest.mark.multisig
|
||||
@pytest.mark.parametrize("show_display", (True, False))
|
||||
def test_multisig_missing(client: Client, show_display):
|
||||
# Multisig with global suffix specification.
|
||||
# Use account numbers 1, 2 and 3 to create a valid multisig,
|
||||
# but not containing the keys from account 0 used below.
|
||||
nodes = [
|
||||
btc.get_public_node(client, parse_path(f"m/49h/0h/{i}h")).node
|
||||
for i in range(1, 4)
|
||||
]
|
||||
|
||||
# Multisig with global suffix specification.
|
||||
multisig1 = messages.MultisigRedeemScriptType(
|
||||
nodes=nodes, address_n=[0, 0], signatures=[b"", b"", b""], m=2
|
||||
)
|
||||
|
||||
# Multisig with per-node suffix specification.
|
||||
node = btc.get_public_node(
|
||||
client, parse_path("m/49h/0h/0h/0"), coin_name="Bitcoin"
|
||||
).node
|
||||
multisig2 = messages.MultisigRedeemScriptType(
|
||||
pubkeys=[
|
||||
messages.HDNodePathType(node=node, address_n=[1]),
|
||||
messages.HDNodePathType(node=node, address_n=[2]),
|
||||
messages.HDNodePathType(node=node, address_n=[3]),
|
||||
messages.HDNodePathType(node=node, address_n=[0, 0]) for node in nodes
|
||||
],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
|
@ -222,26 +222,22 @@ def test_show_multisig_3(client: Client):
|
||||
@pytest.mark.multisig
|
||||
@pytest.mark.parametrize("show_display", (True, False))
|
||||
def test_multisig_missing(client: Client, show_display: bool):
|
||||
# Multisig with global suffix specification.
|
||||
# Use account numbers 1, 2 and 3 to create a valid multisig,
|
||||
# but not containing the keys from account 0 used below.
|
||||
nodes = [
|
||||
btc.get_public_node(client, parse_path(f"m/84h/0h/{i}h")).node
|
||||
for i in range(1, 4)
|
||||
]
|
||||
|
||||
# Multisig with global suffix specification.
|
||||
multisig1 = messages.MultisigRedeemScriptType(
|
||||
nodes=nodes, address_n=[0, 0], signatures=[b"", b"", b""], m=2
|
||||
)
|
||||
|
||||
# Multisig with per-node suffix specification.
|
||||
node = btc.get_public_node(
|
||||
client, parse_path("m/84h/0h/0h/0"), coin_name="Bitcoin"
|
||||
).node
|
||||
multisig2 = messages.MultisigRedeemScriptType(
|
||||
pubkeys=[
|
||||
messages.HDNodePathType(node=node, address_n=[1]),
|
||||
messages.HDNodePathType(node=node, address_n=[2]),
|
||||
messages.HDNodePathType(node=node, address_n=[3]),
|
||||
messages.HDNodePathType(node=node, address_n=[0, 0]) for node in nodes
|
||||
],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
|
@ -134,19 +134,28 @@ def test_show_unrecognized_path(client: Client):
|
||||
|
||||
@pytest.mark.multisig
|
||||
def test_show_multisig_3(client: Client):
|
||||
node = btc.get_public_node(
|
||||
client, tools.parse_path("m/45h/0/0"), coin_name="Bitcoin"
|
||||
nodes = [
|
||||
btc.get_public_node(
|
||||
client, tools.parse_path(f"m/45h/{i}"), coin_name="Bitcoin"
|
||||
).node
|
||||
multisig = messages.MultisigRedeemScriptType(
|
||||
for i in [1, 2, 3]
|
||||
]
|
||||
|
||||
# Multisig with global suffix specification.
|
||||
multisig1 = messages.MultisigRedeemScriptType(
|
||||
nodes=nodes, signatures=[b"", b"", b""], m=2, address_n=[0, 0]
|
||||
)
|
||||
|
||||
# Multisig with per-node suffix specification.
|
||||
multisig2 = messages.MultisigRedeemScriptType(
|
||||
pubkeys=[
|
||||
messages.HDNodePathType(node=node, address_n=[1]),
|
||||
messages.HDNodePathType(node=node, address_n=[2]),
|
||||
messages.HDNodePathType(node=node, address_n=[3]),
|
||||
messages.HDNodePathType(node=node, address_n=[0, 0]) for node in nodes
|
||||
],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
|
||||
for multisig in (multisig1, multisig2):
|
||||
for i in [1, 2, 3]:
|
||||
with client:
|
||||
if is_core(client):
|
||||
@ -156,12 +165,12 @@ def test_show_multisig_3(client: Client):
|
||||
btc.get_address(
|
||||
client,
|
||||
"Bitcoin",
|
||||
tools.parse_path(f"m/45h/0/0/{i}"),
|
||||
tools.parse_path(f"m/45h/{i}/0/0"),
|
||||
show_display=True,
|
||||
multisig=multisig,
|
||||
script_type=messages.InputScriptType.SPENDMULTISIG,
|
||||
)
|
||||
== "35Q3tgZZfr9GhVpaqz7fbDK8WXV1V1KxfD"
|
||||
== "3FQJAFhGpgryDeYh5trpFJTCvN3H5aX2Cg"
|
||||
)
|
||||
|
||||
|
||||
@ -282,16 +291,28 @@ def test_show_multisig_xpubs(
|
||||
|
||||
@pytest.mark.multisig
|
||||
def test_show_multisig_15(client: Client):
|
||||
node = btc.get_public_node(
|
||||
client, tools.parse_path("m/45h/0/0"), coin_name="Bitcoin"
|
||||
nodes = [
|
||||
btc.get_public_node(
|
||||
client, tools.parse_path(f"m/45h/{i}"), coin_name="Bitcoin"
|
||||
).node
|
||||
for i in range(15)
|
||||
]
|
||||
|
||||
pubs = [messages.HDNodePathType(node=node, address_n=[x]) for x in range(15)]
|
||||
|
||||
multisig = messages.MultisigRedeemScriptType(
|
||||
pubkeys=pubs, signatures=[b""] * 15, m=15
|
||||
# Multisig with global suffix specification.
|
||||
multisig1 = messages.MultisigRedeemScriptType(
|
||||
nodes=nodes, signatures=[b"", b"", b""], m=2, address_n=[0, 0]
|
||||
)
|
||||
|
||||
# Multisig with per-node suffix specification.
|
||||
multisig2 = messages.MultisigRedeemScriptType(
|
||||
pubkeys=[
|
||||
messages.HDNodePathType(node=node, address_n=[0, 0]) for node in nodes
|
||||
],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
|
||||
for multisig in [multisig1, multisig2]:
|
||||
for i in range(15):
|
||||
with client:
|
||||
if is_core(client):
|
||||
@ -301,10 +322,10 @@ def test_show_multisig_15(client: Client):
|
||||
btc.get_address(
|
||||
client,
|
||||
"Bitcoin",
|
||||
tools.parse_path(f"m/45h/0/0/{i}"),
|
||||
tools.parse_path(f"m/45h/{i}/0/0"),
|
||||
show_display=True,
|
||||
multisig=multisig,
|
||||
script_type=messages.InputScriptType.SPENDMULTISIG,
|
||||
)
|
||||
== "3GG78bp1hA3mu9xv1vZLXiENmeabmi7WKQ"
|
||||
== "3A8zs8W98A7n1zCWSvVzodiBsaHBYzAhzb"
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user