mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-22 22:38:08 +00:00
tests: add test for Zcash Sapling
This commit is contained in:
parent
85c7b39e3f
commit
685f24b454
@ -26,14 +26,17 @@ TxApiZcashTestnet = coins.tx_api["Zcash Testnet"]
|
||||
TXHASH_aaf51e = bytes.fromhex(
|
||||
"aaf51e4606c264e47e5c42c958fe4cf1539c5172684721e38e69f4ef634d75dc"
|
||||
)
|
||||
TXHASH_e38206 = bytes.fromhex(
|
||||
"e3820602226974b1dd87b7113cc8aea8c63e5ae29293991e7bfa80c126930368"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.zcash
|
||||
class TestMsgSigntxZcash(TrezorTest):
|
||||
def test_one_one_fee(self):
|
||||
def test_one_one_fee_overwinter(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
|
||||
# tx: aaf51e4606c264e47e5c42c958fe4cf1539c5172684721e38e69f4ef634d75dc
|
||||
# prevout: aaf51e4606c264e47e5c42c958fe4cf1539c5172684721e38e69f4ef634d75dc:1
|
||||
# input 1: 3.0 TAZ
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
@ -92,3 +95,66 @@ class TestMsgSigntxZcash(TrezorTest):
|
||||
serialized_tx.hex()
|
||||
== "030000807082c40301dc754d63eff4698ee321476872519c53f14cfe58c9425c7ee464c206461ef5aa010000006a47304402207e45f303b4e42be824513855eb21653e1d2749cd94dcd0f0613d3f85d4efd1e20220699ffbdbcad889af7ede5ce9febf7a5ef8f5619b2464824529974c400cffaebc0121030e669acac1f280d1ddf441cd2ba5e97417bf2689e4bbec86df4f831bf9f7ffd0ffffffff016c9be111000000001976a9145b157a678a10021243307e4bb58f36375aa80e1088ac000000000000000000"
|
||||
)
|
||||
|
||||
def test_one_one_fee_sapling(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
|
||||
# prevout: e3820602226974b1dd87b7113cc8aea8c63e5ae29293991e7bfa80c126930368:0
|
||||
# input 1: 3.0 TAZ
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
address_n=parse_path(
|
||||
"m/Zcash Testnet/0h/0/0"
|
||||
), # tmQoJ3PTXgQLaRRZZYT6xk8XtjRbr2kCqwu
|
||||
amount=300000000,
|
||||
prev_hash=TXHASH_e38206,
|
||||
prev_index=0,
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
address="tmJ1xYxP8XNTtCoDgvdmQPSrxh5qZJgy65Z",
|
||||
amount=300000000 - 1940,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
with self.client:
|
||||
self.client.set_tx_api(TxApiZcashTestnet)
|
||||
self.client.set_expected_responses(
|
||||
[
|
||||
proto.TxRequest(
|
||||
request_type=proto.RequestType.TXINPUT,
|
||||
details=proto.TxRequestDetailsType(request_index=0),
|
||||
),
|
||||
proto.TxRequest(
|
||||
request_type=proto.RequestType.TXOUTPUT,
|
||||
details=proto.TxRequestDetailsType(request_index=0),
|
||||
),
|
||||
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
|
||||
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
|
||||
proto.TxRequest(
|
||||
request_type=proto.RequestType.TXINPUT,
|
||||
details=proto.TxRequestDetailsType(request_index=0),
|
||||
),
|
||||
proto.TxRequest(
|
||||
request_type=proto.RequestType.TXOUTPUT,
|
||||
details=proto.TxRequestDetailsType(request_index=0),
|
||||
),
|
||||
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||
]
|
||||
)
|
||||
|
||||
(signatures, serialized_tx) = btc.sign_tx(
|
||||
self.client,
|
||||
"Zcash Testnet",
|
||||
[inp1],
|
||||
[out1],
|
||||
version=4,
|
||||
overwintered=True,
|
||||
version_group_id=0x892F2085,
|
||||
)
|
||||
|
||||
# Accepted by network: tx TODO
|
||||
assert (
|
||||
serialized_tx.hex()
|
||||
== "0400008085202f890168039326c180fa7b1e999392e25a3ec6a8aec83c11b787ddb1746922020682e3000000006b483045022100f28298891f48706697a6f898ac18e39ce2c7cebe547b585d51cc22d80b1b21a602201a807b8a18544832d95d1e3ada82c0617bc6d97d3f24d1fb4801ac396647aa880121030e669acac1f280d1ddf441cd2ba5e97417bf2689e4bbec86df4f831bf9f7ffd0ffffffff016c9be111000000001976a9145b157a678a10021243307e4bb58f36375aa80e1088ac000000000000000000"
|
||||
)
|
||||
|
@ -0,0 +1 @@
|
||||
{"txid": "e3820602226974b1dd87b7113cc8aea8c63e5ae29293991e7bfa80c126930368", "version": 3, "locktime": 261287, "vin": [{"txid": "4e8e8c5a5524cb8b20d05aefd5b1fd004d6c8c584e3e314876f13edb5ba0eead", "vout": 0, "sequence": 4294967294, "n": 0, "scriptSig": {"hex": "473044022064e1e5f957308fcc91f7b174113c8e3cb8060b1404ae823ab3f77f313d5b557b02204b2afcde9ef8b61f5e85192c38fb82307d077ec91d2c8249aa69e19967df8c0c01210201d494a45f36f545443bafd1a9050b02f448dd236bb4ce2602f83978980b98f2", "asm": "3044022064e1e5f957308fcc91f7b174113c8e3cb8060b1404ae823ab3f77f313d5b557b02204b2afcde9ef8b61f5e85192c38fb82307d077ec91d2c8249aa69e19967df8c0c[ALL] 0201d494a45f36f545443bafd1a9050b02f448dd236bb4ce2602f83978980b98f2"}, "addr": "tmKBPqa8qqKA7vrGq1AaXHSAr9vqa3GczzK", "valueSat": 300000000, "value": 3, "doubleSpentTxID": null}, {"txid": "7afab9216fee6763ffbd6a412d46d68c480220af093c9becee6f79d41b954b13", "vout": 0, "sequence": 4294967294, "n": 1, "scriptSig": {"hex": "47304402207f63a484ee75900ce2b0e2a5f0d52f2cfb5d1475588576f645c20ecf5e04659a02205c9b614ca846b0cb9ff4a72ca8482c9aed542282b9ee8eaa70a5f472408f3f04012103e974b89ace172f24bb25f8137d19c4205c5cf6bb6505454230ea172f54152d08", "asm": "304402207f63a484ee75900ce2b0e2a5f0d52f2cfb5d1475588576f645c20ecf5e04659a02205c9b614ca846b0cb9ff4a72ca8482c9aed542282b9ee8eaa70a5f472408f3f04[ALL] 03e974b89ace172f24bb25f8137d19c4205c5cf6bb6505454230ea172f54152d08"}, "addr": "tmR2f5ZtUqC7GzECY7LTxZjNm1uf9Mu1YEJ", "valueSat": 1252029, "value": "0.01252029", "doubleSpentTxID": null}], "vout": [{"value": "3.00000000", "n": 0, "scriptPubKey": {"hex": "76a914a579388225827d9f2fe9014add644487808c695d88ac", "asm": "OP_DUP OP_HASH160 a579388225827d9f2fe9014add644487808c695d OP_EQUALVERIFY OP_CHECKSIG", "addresses": ["tmQoJ3PTXgQLaRRZZYT6xk8XtjRbr2kCqwu"], "type": "pubkeyhash"}, "spentTxId": null, "spentIndex": null, "spentHeight": null}, {"value": "0.01251648", "n": 1, "scriptPubKey": {"hex": "76a91474374446b18916decd3292384ea73006ebd268ba88ac", "asm": "OP_DUP OP_HASH160 74374446b18916decd3292384ea73006ebd268ba OP_EQUALVERIFY OP_CHECKSIG", "addresses": ["tmLJqvRRHXgQTCPww82mdi6oNXGuC5zj2dw"], "type": "pubkeyhash"}, "spentTxId": "180b10fc6db0538c1e89cabae4b847e62ae36bbaf6bfbfeaab102cb5a3041175", "spentIndex": 2, "spentHeight": 261881}], "vjoinsplit": [], "blockhash": "00007ccb4cab43e8c14f1e7591277778dd0f7232007f4d02cbcf918f0a8521bf", "blockheight": 261298, "confirmations": 46138, "time": 1531122666, "blocktime": 1531122666, "valueOut": "3.01251648", "size": 381, "valueIn": "3.01252029", "fees": "0.00000381", "fOverwintered": true, "nVersionGroupId": 63210096, "nExpiryHeight": 261318}
|
Loading…
Reference in New Issue
Block a user