mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-22 14:28:07 +00:00
tests: use simplified API for MultisigRedeemScriptType where possible
This is possible when address_n is the same for all involved nodes
This commit is contained in:
parent
f7aa6ae22e
commit
333af87ce2
@ -25,10 +25,8 @@ from .common import TrezorTest
|
||||
|
||||
def getmultisig(chain, nr, xpubs, signatures=[b"", b"", b""]):
|
||||
return proto.MultisigRedeemScriptType(
|
||||
pubkeys=[
|
||||
proto.HDNodePathType(node=bip32.deserialize(xpub), address_n=[chain, nr])
|
||||
for xpub in xpubs
|
||||
],
|
||||
nodes=[bip32.deserialize(xpub) for xpub in xpubs],
|
||||
address_n=[chain, nr],
|
||||
signatures=signatures,
|
||||
m=2,
|
||||
)
|
||||
|
@ -78,14 +78,8 @@ class TestMsgGetaddressSegwit(TrezorTest):
|
||||
range(1, 4),
|
||||
)
|
||||
multisig1 = proto.MultisigRedeemScriptType(
|
||||
pubkeys=list(
|
||||
map(
|
||||
lambda n: proto.HDNodePathType(
|
||||
node=bip32.deserialize(n.xpub), address_n=[2, 0]
|
||||
),
|
||||
nodes,
|
||||
)
|
||||
),
|
||||
nodes=[bip32.deserialize(n.xpub) for n in nodes],
|
||||
address_n=[2, 0],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
|
@ -76,26 +76,14 @@ class TestMsgGetaddressSegwitNative(TrezorTest):
|
||||
for index in range(1, 4)
|
||||
]
|
||||
multisig1 = proto.MultisigRedeemScriptType(
|
||||
pubkeys=list(
|
||||
map(
|
||||
lambda n: proto.HDNodePathType(
|
||||
node=bip32.deserialize(n.xpub), address_n=[2, 0]
|
||||
),
|
||||
nodes,
|
||||
)
|
||||
),
|
||||
nodes=[bip32.deserialize(n.xpub) for n in nodes],
|
||||
address_n=[2, 0],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
multisig2 = proto.MultisigRedeemScriptType(
|
||||
pubkeys=list(
|
||||
map(
|
||||
lambda n: proto.HDNodePathType(
|
||||
node=bip32.deserialize(n.xpub), address_n=[2, 1]
|
||||
),
|
||||
nodes,
|
||||
)
|
||||
),
|
||||
nodes=[bip32.deserialize(n.xpub) for n in nodes],
|
||||
address_n=[2, 1],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
|
@ -424,14 +424,8 @@ class TestMsgSigntxBch(TrezorTest):
|
||||
|
||||
def getmultisig(chain, nr, signatures=[b"", b"", b""], xpubs=xpubs):
|
||||
return proto.MultisigRedeemScriptType(
|
||||
pubkeys=list(
|
||||
map(
|
||||
lambda xpub: proto.HDNodePathType(
|
||||
node=deserialize(xpub), address_n=[chain, nr]
|
||||
),
|
||||
xpubs,
|
||||
)
|
||||
),
|
||||
nodes=[deserialize(xpub) for xpub in xpubs],
|
||||
address_n=[chain, nr],
|
||||
signatures=signatures,
|
||||
m=2,
|
||||
)
|
||||
@ -524,14 +518,8 @@ class TestMsgSigntxBch(TrezorTest):
|
||||
|
||||
def getmultisig(chain, nr, signatures=[b"", b"", b""], xpubs=xpubs):
|
||||
return proto.MultisigRedeemScriptType(
|
||||
pubkeys=list(
|
||||
map(
|
||||
lambda xpub: proto.HDNodePathType(
|
||||
node=deserialize(xpub), address_n=[chain, nr]
|
||||
),
|
||||
xpubs,
|
||||
)
|
||||
),
|
||||
nodes=[deserialize(xpub) for xpub in xpubs],
|
||||
address_n=[chain, nr],
|
||||
signatures=signatures,
|
||||
m=2,
|
||||
)
|
||||
|
@ -235,14 +235,8 @@ class TestMsgSigntxBitcoinGold(TrezorTest):
|
||||
|
||||
def getmultisig(chain, nr, signatures=[b"", b"", b""], xpubs=xpubs):
|
||||
return proto.MultisigRedeemScriptType(
|
||||
pubkeys=list(
|
||||
map(
|
||||
lambda xpub: proto.HDNodePathType(
|
||||
node=deserialize(xpub), address_n=[chain, nr]
|
||||
),
|
||||
xpubs,
|
||||
)
|
||||
),
|
||||
nodes=[deserialize(xpub) for xpub in xpubs],
|
||||
address_n=[chain, nr],
|
||||
signatures=signatures,
|
||||
m=2,
|
||||
)
|
||||
@ -509,14 +503,8 @@ class TestMsgSigntxBitcoinGold(TrezorTest):
|
||||
range(1, 4),
|
||||
)
|
||||
multisig = proto.MultisigRedeemScriptType(
|
||||
pubkeys=list(
|
||||
map(
|
||||
lambda n: proto.HDNodePathType(
|
||||
node=deserialize(n.xpub), address_n=[1, 0]
|
||||
),
|
||||
nodes,
|
||||
)
|
||||
),
|
||||
nodes=[deserialize(n.xpub) for n in nodes],
|
||||
address_n=[1, 0],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
|
@ -290,10 +290,8 @@ class TestMsgSigntxDecred(TrezorTest):
|
||||
def create_multisig(index, address, signatures=None):
|
||||
address_n = parse_path(address)
|
||||
multisig = proto.MultisigRedeemScriptType(
|
||||
pubkeys=[
|
||||
proto.HDNodePathType(node=node, address_n=address_n)
|
||||
for node in nodes
|
||||
],
|
||||
nodes=nodes,
|
||||
address_n=address_n,
|
||||
signatures=signatures,
|
||||
m=2,
|
||||
)
|
||||
|
@ -223,14 +223,8 @@ class TestMsgSigntxSegwit(TrezorTest):
|
||||
range(1, 4),
|
||||
)
|
||||
multisig = proto.MultisigRedeemScriptType(
|
||||
pubkeys=list(
|
||||
map(
|
||||
lambda n: proto.HDNodePathType(
|
||||
node=deserialize(n.xpub), address_n=[1, 0]
|
||||
),
|
||||
nodes,
|
||||
)
|
||||
),
|
||||
nodes=[deserialize(n.xpub) for n in nodes],
|
||||
address_n=[1, 0],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
|
@ -410,14 +410,8 @@ class TestMsgSigntxSegwitNative(TrezorTest):
|
||||
for index in range(1, 4)
|
||||
]
|
||||
multisig = proto.MultisigRedeemScriptType(
|
||||
pubkeys=list(
|
||||
map(
|
||||
lambda n: proto.HDNodePathType(
|
||||
node=deserialize(n.xpub), address_n=[0, 0]
|
||||
),
|
||||
nodes,
|
||||
)
|
||||
),
|
||||
nodes=[deserialize(n.xpub) for n in nodes],
|
||||
address_n=[0, 0],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
@ -517,14 +511,8 @@ class TestMsgSigntxSegwitNative(TrezorTest):
|
||||
for index in range(1, 4)
|
||||
]
|
||||
multisig = proto.MultisigRedeemScriptType(
|
||||
pubkeys=list(
|
||||
map(
|
||||
lambda n: proto.HDNodePathType(
|
||||
node=deserialize(n.xpub), address_n=[0, 1]
|
||||
),
|
||||
nodes,
|
||||
)
|
||||
),
|
||||
nodes=[deserialize(n.xpub) for n in nodes],
|
||||
address_n=[0, 1],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
@ -624,26 +612,14 @@ class TestMsgSigntxSegwitNative(TrezorTest):
|
||||
for index in range(1, 4)
|
||||
]
|
||||
multisig = proto.MultisigRedeemScriptType(
|
||||
pubkeys=list(
|
||||
map(
|
||||
lambda n: proto.HDNodePathType(
|
||||
node=deserialize(n.xpub), address_n=[1, 0]
|
||||
),
|
||||
nodes,
|
||||
)
|
||||
),
|
||||
nodes=[deserialize(n.xpub) for n in nodes],
|
||||
address_n=[1, 0],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
multisig2 = proto.MultisigRedeemScriptType(
|
||||
pubkeys=list(
|
||||
map(
|
||||
lambda n: proto.HDNodePathType(
|
||||
node=deserialize(n.xpub), address_n=[1, 1]
|
||||
),
|
||||
nodes,
|
||||
)
|
||||
),
|
||||
nodes=[deserialize(n.xpub) for n in nodes],
|
||||
address_n=[1, 1],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
@ -743,26 +719,14 @@ class TestMsgSigntxSegwitNative(TrezorTest):
|
||||
for index in range(1, 4)
|
||||
]
|
||||
multisig = proto.MultisigRedeemScriptType(
|
||||
pubkeys=list(
|
||||
map(
|
||||
lambda n: proto.HDNodePathType(
|
||||
node=deserialize(n.xpub), address_n=[1, 1]
|
||||
),
|
||||
nodes,
|
||||
)
|
||||
),
|
||||
nodes=[deserialize(n.xpub) for n in nodes],
|
||||
address_n=[1, 1],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
multisig2 = proto.MultisigRedeemScriptType(
|
||||
pubkeys=list(
|
||||
map(
|
||||
lambda n: proto.HDNodePathType(
|
||||
node=deserialize(n.xpub), address_n=[1, 2]
|
||||
),
|
||||
nodes,
|
||||
)
|
||||
),
|
||||
nodes=[deserialize(n.xpub) for n in nodes],
|
||||
address_n=[1, 2],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
|
@ -40,14 +40,8 @@ class TestMultisig(TrezorTest):
|
||||
]
|
||||
|
||||
multisig = proto.MultisigRedeemScriptType(
|
||||
pubkeys=list(
|
||||
map(
|
||||
lambda n: proto.HDNodePathType(
|
||||
node=deserialize(n.xpub), address_n=[0, 0]
|
||||
),
|
||||
nodes,
|
||||
)
|
||||
),
|
||||
nodes=[deserialize(n.xpub) for n in nodes],
|
||||
address_n=[0, 0],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
@ -131,14 +125,8 @@ class TestMultisig(TrezorTest):
|
||||
# Let's do second signature using 3rd key
|
||||
|
||||
multisig = proto.MultisigRedeemScriptType(
|
||||
pubkeys=list(
|
||||
map(
|
||||
lambda n: proto.HDNodePathType(
|
||||
node=deserialize(n.xpub), address_n=[0, 0]
|
||||
),
|
||||
nodes,
|
||||
)
|
||||
),
|
||||
nodes=[deserialize(n.xpub) for n in nodes],
|
||||
address_n=[0, 0],
|
||||
signatures=[
|
||||
signatures1[0],
|
||||
b"",
|
||||
|
@ -69,31 +69,22 @@ class TestMultisigChange(TrezorTest):
|
||||
# input 1: 0.001 BTC
|
||||
|
||||
multisig_in1 = proto.MultisigRedeemScriptType(
|
||||
pubkeys=[
|
||||
proto.HDNodePathType(node=node_ext2, address_n=[0, 0]),
|
||||
proto.HDNodePathType(node=node_ext1, address_n=[0, 0]),
|
||||
proto.HDNodePathType(node=node_int, address_n=[0, 0]),
|
||||
],
|
||||
nodes=[node_ext2, node_ext1, node_int],
|
||||
address_n=[0, 0],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
|
||||
multisig_in2 = proto.MultisigRedeemScriptType(
|
||||
pubkeys=[
|
||||
proto.HDNodePathType(node=node_ext1, address_n=[0, 1]),
|
||||
proto.HDNodePathType(node=node_ext2, address_n=[0, 1]),
|
||||
proto.HDNodePathType(node=node_int, address_n=[0, 1]),
|
||||
],
|
||||
nodes=[node_ext1, node_ext2, node_int],
|
||||
address_n=[0, 1],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
|
||||
multisig_in3 = proto.MultisigRedeemScriptType(
|
||||
pubkeys=[
|
||||
proto.HDNodePathType(node=node_ext1, address_n=[0, 1]),
|
||||
proto.HDNodePathType(node=node_ext3, address_n=[0, 1]),
|
||||
proto.HDNodePathType(node=node_int, address_n=[0, 1]),
|
||||
],
|
||||
nodes=[node_ext1, node_ext3, node_int],
|
||||
address_n=[0, 1],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
@ -395,11 +386,8 @@ class TestMultisigChange(TrezorTest):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
|
||||
multisig_out1 = proto.MultisigRedeemScriptType(
|
||||
pubkeys=[
|
||||
proto.HDNodePathType(node=self.node_ext2, address_n=[1, 0]),
|
||||
proto.HDNodePathType(node=self.node_ext1, address_n=[1, 0]),
|
||||
proto.HDNodePathType(node=self.node_int, address_n=[1, 0]),
|
||||
],
|
||||
nodes=[self.node_ext2, self.node_ext1, self.node_int],
|
||||
address_n=[1, 0],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
@ -439,11 +427,8 @@ class TestMultisigChange(TrezorTest):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
|
||||
multisig_out2 = proto.MultisigRedeemScriptType(
|
||||
pubkeys=[
|
||||
proto.HDNodePathType(node=self.node_ext1, address_n=[1, 1]),
|
||||
proto.HDNodePathType(node=self.node_ext2, address_n=[1, 1]),
|
||||
proto.HDNodePathType(node=self.node_int, address_n=[1, 1]),
|
||||
],
|
||||
nodes=[self.node_ext1, self.node_ext2, self.node_int],
|
||||
address_n=[1, 1],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
@ -483,11 +468,8 @@ class TestMultisigChange(TrezorTest):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
|
||||
multisig_out2 = proto.MultisigRedeemScriptType(
|
||||
pubkeys=[
|
||||
proto.HDNodePathType(node=self.node_ext1, address_n=[1, 0]),
|
||||
proto.HDNodePathType(node=self.node_int, address_n=[1, 0]),
|
||||
proto.HDNodePathType(node=self.node_ext3, address_n=[1, 0]),
|
||||
],
|
||||
nodes=[self.node_ext1, self.node_int, self.node_ext3],
|
||||
address_n=[1, 0],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
@ -525,11 +507,8 @@ class TestMultisigChange(TrezorTest):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
|
||||
multisig_out1 = proto.MultisigRedeemScriptType(
|
||||
pubkeys=[
|
||||
proto.HDNodePathType(node=self.node_ext2, address_n=[1, 0]),
|
||||
proto.HDNodePathType(node=self.node_ext1, address_n=[1, 0]),
|
||||
proto.HDNodePathType(node=self.node_int, address_n=[1, 0]),
|
||||
],
|
||||
nodes=[self.node_ext2, self.node_ext1, self.node_int],
|
||||
address_n=[1, 0],
|
||||
signatures=[b"", b"", b""],
|
||||
m=2,
|
||||
)
|
||||
|
2
vendor/trezor-common
vendored
2
vendor/trezor-common
vendored
@ -1 +1 @@
|
||||
Subproject commit 4b41d2e63841517bf701618434c018acf4f1bca2
|
||||
Subproject commit 0735c7d6f524b4c5108d201c789612aad7ce7920
|
Loading…
Reference in New Issue
Block a user