forked from bitshares/python-bitshares
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_txbuffers.py
More file actions
93 lines (82 loc) · 3.1 KB
/
test_txbuffers.py
File metadata and controls
93 lines (82 loc) · 3.1 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import unittest
from bitsharesbase import operations
from .fixtures import fixture_data, bitshares
class Testcases(unittest.TestCase):
def setUp(self):
fixture_data()
def test_add_one_proposal_one_op(self):
tx1 = bitshares.new_tx()
proposal1 = bitshares.new_proposal(tx1, proposer="init0")
op = operations.Transfer(**{
"fee": {"amount": 0, "asset_id": "1.3.0"},
"from": "1.2.0",
"to": "1.2.0",
"amount": {"amount": 0, "asset_id": "1.3.0"},
"prefix": "TEST"
})
proposal1.appendOps(op)
tx = tx1.json()
self.assertEqual(tx["operations"][0][0], 22)
self.assertEqual(len(tx["operations"]), 1)
ps = tx["operations"][0][1]
self.assertEqual(len(ps["proposed_ops"]), 1)
self.assertEqual(ps["proposed_ops"][0]["op"][0], 0)
def test_add_one_proposal_two_ops(self):
tx1 = bitshares.new_tx()
proposal1 = bitshares.new_proposal(tx1, proposer="init0")
op = operations.Transfer(**{
"fee": {"amount": 0, "asset_id": "1.3.0"},
"from": "1.2.0",
"to": "1.2.0",
"amount": {"amount": 0, "asset_id": "1.3.0"},
"prefix": "TEST"
})
proposal1.appendOps(op)
proposal1.appendOps(op)
tx = tx1.json()
self.assertEqual(tx["operations"][0][0], 22)
self.assertEqual(len(tx["operations"]), 1)
ps = tx["operations"][0][1]
self.assertEqual(len(ps["proposed_ops"]), 2)
self.assertEqual(ps["proposed_ops"][0]["op"][0], 0)
self.assertEqual(ps["proposed_ops"][1]["op"][0], 0)
def test_have_two_proposals(self):
tx1 = bitshares.new_tx()
# Proposal 1
proposal1 = bitshares.new_proposal(tx1, proposer="init0")
op = operations.Transfer(**{
"fee": {"amount": 0, "asset_id": "1.3.0"},
"from": "1.2.0",
"to": "1.2.0",
"amount": {"amount": 0, "asset_id": "1.3.0"},
"prefix": "TEST"
})
for i in range(0, 3):
proposal1.appendOps(op)
# Proposal 1
proposal2 = bitshares.new_proposal(tx1, proposer="init0")
op = operations.Transfer(**{
"fee": {"amount": 0, "asset_id": "1.3.0"},
"from": "1.2.0",
"to": "1.2.0",
"amount": {"amount": 5555555, "asset_id": "1.3.0"},
"prefix": "TEST"
})
for i in range(0, 2):
proposal2.appendOps(op)
tx = tx1.json()
self.assertEqual(len(tx["operations"]), 2) # 2 proposals
# Test proposal 1
prop = tx["operations"][0]
self.assertEqual(prop[0], 22)
ps = prop[1]
self.assertEqual(len(ps["proposed_ops"]), 3)
for i in range(0, 3):
self.assertEqual(ps["proposed_ops"][i]["op"][0], 0)
# Test proposal 2
prop = tx["operations"][1]
self.assertEqual(prop[0], 22)
ps = prop[1]
self.assertEqual(len(ps["proposed_ops"]), 2)
for i in range(0, 2):
self.assertEqual(ps["proposed_ops"][i]["op"][0], 0)