mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 23:48:12 +00:00
tests/device/nem: mosaic supply change test; const fixes
This commit is contained in:
parent
48cb8d0216
commit
326056b968
@ -2,13 +2,13 @@ import binascii
|
||||
import json
|
||||
from . import messages as proto
|
||||
|
||||
TYPE_MOSAIC_TRANSFER = 0x0101
|
||||
TYPE_TRANSACTION_TRANSFER = 0x0101
|
||||
TYPE_IMPORTANCE_TRANSFER = 0x0801
|
||||
TYPE_MULTISIG_CHANGE = 0x1001
|
||||
TYPE_MULTISIG_SIGN = 0x1002
|
||||
TYPE_MULTISIG_TX = 0x1004
|
||||
TYPE_AGGREGATE_MODIFICATION = 0x1001
|
||||
TYPE_MULTISIG_SIGNATURE = 0x1002
|
||||
TYPE_MULTISIG = 0x1004
|
||||
TYPE_PROVISION_NAMESPACE = 0x2001
|
||||
TYPE_MOSAIC_DEFINITION_CREATION = 0x4001
|
||||
TYPE_MOSAIC_CREATION = 0x4001
|
||||
TYPE_MOSAIC_SUPPLY_CHANGE = 0x4002
|
||||
|
||||
|
||||
@ -117,24 +117,24 @@ def create_supply_change(transaction):
|
||||
def create_sign_tx(transaction):
|
||||
msg = proto.NEMSignTx()
|
||||
msg.transaction = create_transaction_common(transaction)
|
||||
msg.cosigning = (transaction["type"] == TYPE_MULTISIG_SIGN)
|
||||
msg.cosigning = (transaction["type"] == TYPE_MULTISIG_SIGNATURE)
|
||||
|
||||
if transaction["type"] in (TYPE_MULTISIG_SIGN, TYPE_MULTISIG_TX):
|
||||
if transaction["type"] in (TYPE_MULTISIG_SIGNATURE, TYPE_MULTISIG):
|
||||
transaction = transaction["otherTrans"]
|
||||
msg.multisig = create_transaction_common(transaction)
|
||||
elif "otherTrans" in transaction:
|
||||
raise ValueError("Transaction does not support inner transaction")
|
||||
|
||||
if transaction["type"] == TYPE_MOSAIC_TRANSFER:
|
||||
if transaction["type"] == TYPE_TRANSACTION_TRANSFER:
|
||||
msg.transfer = create_transfer(transaction)
|
||||
elif transaction["type"] == TYPE_MULTISIG_CHANGE:
|
||||
elif transaction["type"] == TYPE_AGGREGATE_MODIFICATION:
|
||||
msg.aggregate_modification = create_aggregate_modification(transaction)
|
||||
elif transaction["type"] == TYPE_PROVISION_NAMESPACE:
|
||||
msg.provision_namespace = create_provision_namespace(transaction)
|
||||
elif transaction["type"] == TYPE_MOSAIC_DEFINITION_CREATION:
|
||||
elif transaction["type"] == TYPE_MOSAIC_CREATION:
|
||||
msg.mosaic_creation = create_mosaic_creation(transaction)
|
||||
elif transaction["type"] == TYPE_MOSAIC_SUPPLY_CHANGE:
|
||||
msg.mosaic_supply_change = create_supply_change(transaction)
|
||||
msg.supply_change = create_supply_change(transaction)
|
||||
else:
|
||||
raise ValueError("Unknown transaction type")
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
from .common import *
|
||||
|
||||
from trezorlib import messages as proto
|
||||
from trezorlib import nem
|
||||
|
||||
NEM_TRANSACTION_TYPE_TRANSFER = 0x0101
|
||||
NEM_TRANSACTION_TYPE_PROVISION_NAMESPACE = 0x2001
|
||||
@ -53,7 +54,7 @@ class TestMsgNEMSigntx(TrezorTest):
|
||||
"amount": 2000000,
|
||||
"fee": 2000000,
|
||||
"recipient": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
|
||||
"type": NEM_TRANSACTION_TYPE_TRANSFER,
|
||||
"type": nem.TYPE_TRANSACTION_TRANSFER,
|
||||
"deadline": 74735615,
|
||||
"message": {
|
||||
"payload": hexlify(b"test_nem_transaction_transfer"),
|
||||
@ -84,7 +85,7 @@ class TestMsgNEMSigntx(TrezorTest):
|
||||
"amount": 2000000,
|
||||
"fee": 2000000,
|
||||
"recipient": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
|
||||
"type": NEM_TRANSACTION_TYPE_TRANSFER,
|
||||
"type": nem.TYPE_TRANSACTION_TRANSFER,
|
||||
"deadline": 74735615,
|
||||
"message": {
|
||||
# plain text is 32B long => cipher text is 48B
|
||||
@ -124,7 +125,7 @@ class TestMsgNEMSigntx(TrezorTest):
|
||||
"amount": 1000000,
|
||||
"fee": 1000000,
|
||||
"recipient": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
|
||||
"type": NEM_TRANSACTION_TYPE_TRANSFER,
|
||||
"type": nem.TYPE_TRANSACTION_TRANSFER,
|
||||
"deadline": 76895615,
|
||||
"version": (0x98 << 24),
|
||||
"message": {
|
||||
@ -159,7 +160,7 @@ class TestMsgNEMSigntx(TrezorTest):
|
||||
tx = self.client.nem_sign_tx(self.client.expand_path("m/44'/1'/0'/0'/0'"), {
|
||||
"timeStamp": 74649215,
|
||||
"fee": 2000000,
|
||||
"type": NEM_TRANSACTION_TYPE_PROVISION_NAMESPACE,
|
||||
"type": nem.TYPE_PROVISION_NAMESPACE,
|
||||
"deadline": 74735615,
|
||||
"message": {
|
||||
},
|
||||
@ -183,7 +184,7 @@ class TestMsgNEMSigntx(TrezorTest):
|
||||
tx = self.client.nem_sign_tx(self.client.expand_path("m/44'/1'/0'/0'/0'"), {
|
||||
"timeStamp": 74649215,
|
||||
"fee": 2000000,
|
||||
"type": NEM_TRANSACTION_TYPE_MOSAIC_CREATION,
|
||||
"type": nem.TYPE_MOSAIC_CREATION,
|
||||
"deadline": 74735615,
|
||||
"message": {
|
||||
},
|
||||
@ -212,7 +213,7 @@ class TestMsgNEMSigntx(TrezorTest):
|
||||
tx = self.client.nem_sign_tx(self.client.expand_path("m/44'/1'/0'/0'/0'"), {
|
||||
"timeStamp": 74649215,
|
||||
"fee": 2000000,
|
||||
"type": NEM_TRANSACTION_TYPE_MOSAIC_CREATION,
|
||||
"type": nem.TYPE_MOSAIC_CREATION,
|
||||
"deadline": 74735615,
|
||||
"message": {
|
||||
},
|
||||
@ -258,7 +259,7 @@ class TestMsgNEMSigntx(TrezorTest):
|
||||
tx = self.client.nem_sign_tx(self.client.expand_path("m/44'/1'/0'/0'/0'"), {
|
||||
"timeStamp": 74649215,
|
||||
"fee": 2000000,
|
||||
"type": NEM_TRANSACTION_TYPE_MOSAIC_CREATION,
|
||||
"type": nem.TYPE_MOSAIC_CREATION,
|
||||
"deadline": 74735615,
|
||||
"message": {
|
||||
},
|
||||
@ -303,3 +304,28 @@ class TestMsgNEMSigntx(TrezorTest):
|
||||
|
||||
assert hexlify(tx.data) == b'01400000010000987f0e730420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b406208480841e0000000000ff5f74041801000020000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b40620841a0000000600000068656c6c6f6d0c00000048656c6c6f206d6f73616963050000006c6f72656d04000000150000000c00000064697669736962696c6974790100000034180000000d000000696e697469616c537570706c79030000003230301a0000000d000000737570706c794d757461626c650500000066616c7365180000000c0000007472616e7366657261626c65040000007472756556000000010000002800000054414c49434532474d4133344358484437584c4a513533364e4d35554e4b5148544f524e4e54324a1a0000000600000068656c6c6f6d0c00000048656c6c6f206d6f7361696302000000000000002800000054414c49434532474d4133344358484437584c4a513533364e4d35554e4b5148544f524e4e54324adc05000000000000'
|
||||
assert hexlify(tx.signature) == b'b87aac1ddf146d35e6a7f3451f57e2fe504ac559031e010a51261257c37bd50fcfa7b2939dd7a3203b54c4807d458475182f5d3dc135ec0d1d4a9cd42159fd0a'
|
||||
|
||||
def test_nem_signtx_mosaic_supply_change(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
|
||||
with self.client:
|
||||
tx = self.client.nem_sign_tx(self.client.expand_path("m/44'/1'/0'/0'/0'"), {
|
||||
"timeStamp": 74649215,
|
||||
"fee": 2000000,
|
||||
"type": nem.TYPE_MOSAIC_SUPPLY_CHANGE,
|
||||
"deadline": 74735615,
|
||||
"message": {
|
||||
},
|
||||
"mosaicId": {
|
||||
"namespaceId": "hellom",
|
||||
"name": "Hello mosaic"
|
||||
},
|
||||
"supplyType": 1,
|
||||
"delta": 1,
|
||||
"version": (0x98 << 24),
|
||||
"creationFeeSink": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
|
||||
"creationFee": 1500,
|
||||
})
|
||||
|
||||
assert hexlify(tx.data) == b'02400000010000987f0e730420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b406208480841e0000000000ff5f74041a0000000600000068656c6c6f6d0c00000048656c6c6f206d6f73616963010000000100000000000000'
|
||||
assert hexlify(tx.signature) == b'928b03c4a69fff35ecf0912066ea705895b3028fad141197d7ea2b56f1eef2a2516455e6f35d318f6fa39e2bb40492ac4ae603260790f7ebc7ea69feb4ca4c0a'
|
||||
|
@ -8,7 +8,7 @@ def test_nem_basic():
|
||||
"amount": 1000000,
|
||||
"fee": 1000000,
|
||||
"recipient": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
|
||||
"type": nem.TYPE_MOSAIC_TRANSFER,
|
||||
"type": nem.TYPE_TRANSACTION_TRANSFER,
|
||||
"deadline": 76895615,
|
||||
"version": (0x98 << 24),
|
||||
"message": {
|
||||
|
Loading…
Reference in New Issue
Block a user