/
test_transaction.py
70 lines (56 loc) · 1.86 KB
/
test_transaction.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import unittest
from iroha.helper import logger,crypto
from iroha.transaction.transaction import Transaction
from schema.commands_pb2 import Command
class TransactionTest(unittest.TestCase):
def setUp(self):
logger.setDebug()
logger.debug("TransactionTest")
def test_transaction(self):
logger.debug("test_transaction")
tx = Transaction()
keypairs = []
keypairs.append(crypto.create_key_pair())
keypairs.append(crypto.create_key_pair())
keypairs.append(crypto.create_key_pair())
tx.add_key_pairs(keypairs)
tx.set_creator_account_id("test@test")
logger.info("add command")
tx.add_command(
Command.AddSignatory(
account_id = "test@test",
pubkey = keypairs[0].public_key
)
)
tx.add_command(
Command.SetAccountQuorum(
account_id = "test@test",
quorum = 2
)
)
logger.info("check signatures")
self.assertEqual(tx.count_signatures(),0)
tx.sign()
self.assertEqual(tx.count_signatures(),3)
self.assertTrue(tx.verify())
tx.add_key_pair(crypto.create_key_pair())
tx.sign()
self.assertEqual(tx.count_signatures(),4)
self.assertTrue(tx.verify())
tx.time_stamp()
tx.add_key_pair(crypto.create_key_pair())
tx.sign()
self.assertFalse(tx.verify())
tx.signatures_clean()
self.assertEqual(tx.count_signatures(),0)
self.assertEqual(tx.signatories.size(),0)
self.assertTrue(tx.verify())
tx.add_command(
Command.AddSignatory(
account_id = "test@test",
pubkey = b"00"
)
)
tx.add_key_pairs(keypairs)
tx.sign()
self.assertFalse(tx.verify())