mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-03-28 22:15:42 +00:00
Added basic testnet tests
This commit is contained in:
parent
22dd34baa1
commit
0d25c8974e
@ -14,10 +14,10 @@ TODO:
|
|||||||
* PassphraseRequest/PassphraseAck workflow (vyvolat napr. pomocou GetAddress)
|
* PassphraseRequest/PassphraseAck workflow (vyvolat napr. pomocou GetAddress)
|
||||||
|
|
||||||
* rozsirit test_sign.tx o viac transakcii (zlozitejsich)
|
* rozsirit test_sign.tx o viac transakcii (zlozitejsich)
|
||||||
* fee over threshold
|
x fee over threshold
|
||||||
* not enough funds
|
x not enough funds
|
||||||
* viac ako jeden vstup a jeden vystup
|
x viac ako jeden vstup a jeden vystup
|
||||||
* iny cointype ako 0
|
x iny cointype ako 0
|
||||||
|
|
||||||
- chceme v tomto release(?)
|
- chceme v tomto release(?)
|
||||||
* SignMessage workflow
|
* SignMessage workflow
|
||||||
|
File diff suppressed because one or more lines are too long
84
tests/test_zerosig.py
Normal file
84
tests/test_zerosig.py
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
import unittest
|
||||||
|
import common
|
||||||
|
import binascii
|
||||||
|
|
||||||
|
import trezorlib.messages_pb2 as proto
|
||||||
|
import trezorlib.types_pb2 as proto_types
|
||||||
|
|
||||||
|
# address_n = [177] < 68
|
||||||
|
# address_n = [16518] < 66
|
||||||
|
class TestZeroSig(common.TrezorTest):
|
||||||
|
|
||||||
|
'''
|
||||||
|
def test_mine_zero_signature(self):
|
||||||
|
# tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882
|
||||||
|
# input 0: 0.0039 BTC
|
||||||
|
|
||||||
|
inp1 = proto_types.TxInputType(address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
|
||||||
|
# amount=390000,
|
||||||
|
prev_hash=binascii.unhexlify('d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882'),
|
||||||
|
prev_index=0,
|
||||||
|
)
|
||||||
|
|
||||||
|
msg = self.client._prepare_simple_sign_tx('Bitcoin', [inp1, ], [])
|
||||||
|
|
||||||
|
for n in range(3500, 200000):
|
||||||
|
out1 = proto_types.TxOutputType(address_n=[n],
|
||||||
|
amount=390000 - 10000,
|
||||||
|
script_type=proto_types.PAYTOADDRESS,
|
||||||
|
)
|
||||||
|
msg.ClearField('outputs')
|
||||||
|
msg.outputs.extend([out1, ])
|
||||||
|
|
||||||
|
tx = self.client.call(msg)
|
||||||
|
|
||||||
|
siglen = ord(tx.serialized_tx[44])
|
||||||
|
print siglen
|
||||||
|
if siglen < 67:
|
||||||
|
print "!!!!", n
|
||||||
|
print binascii.hexlify(tx.serialized_tx)
|
||||||
|
return
|
||||||
|
'''
|
||||||
|
|
||||||
|
def test_one_zero_signature(self):
|
||||||
|
inp1 = proto_types.TxInputType(address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
|
||||||
|
# amount=390000,
|
||||||
|
prev_hash=binascii.unhexlify('d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882'),
|
||||||
|
prev_index=0,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Following address_n has been mined by 'test_mine_zero_signature'
|
||||||
|
out1 = proto_types.TxOutputType(address_n=[177],
|
||||||
|
amount=390000 - 10000,
|
||||||
|
script_type=proto_types.PAYTOADDRESS,
|
||||||
|
)
|
||||||
|
|
||||||
|
msg = self.client._prepare_simple_sign_tx('Bitcoin', [inp1], [out1])
|
||||||
|
tx = self.client.call(msg)
|
||||||
|
siglen = ord(tx.serialized_tx[44])
|
||||||
|
|
||||||
|
# Trezor must strip leading zero from signature
|
||||||
|
self.assertEqual(siglen, 67)
|
||||||
|
|
||||||
|
def test_two_zero_signature(self):
|
||||||
|
inp1 = proto_types.TxInputType(address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
|
||||||
|
# amount=390000,
|
||||||
|
prev_hash=binascii.unhexlify('d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882'),
|
||||||
|
prev_index=0,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Following address_n has been mined by 'test_mine_zero_signature'
|
||||||
|
out1 = proto_types.TxOutputType(address_n=[16518],
|
||||||
|
amount=390000 - 10000,
|
||||||
|
script_type=proto_types.PAYTOADDRESS,
|
||||||
|
)
|
||||||
|
|
||||||
|
msg = self.client._prepare_simple_sign_tx('Bitcoin', [inp1], [out1])
|
||||||
|
tx = self.client.call(msg)
|
||||||
|
siglen = ord(tx.serialized_tx[44])
|
||||||
|
|
||||||
|
# Trezor must strip leading zero from signature
|
||||||
|
self.assertEqual(siglen, 66)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
Loading…
Reference in New Issue
Block a user