9
9
10
10
import asyncio
11
11
import json
12
+
12
13
from .utils import call_add_proposal
13
14
14
15
@@ -104,7 +105,6 @@ def test_senate(local_chain, wallet_setup):
104
105
"--verbose" ,
105
106
],
106
107
)
107
- print (">>>" , proposals .stdout , proposals .stderr )
108
108
proposals_output = proposals .stdout .splitlines ()[9 ].split ()
109
109
110
110
# Assert the hash is of correct format
@@ -114,7 +114,7 @@ def test_senate(local_chain, wallet_setup):
114
114
# 0 Ayes for the proposal
115
115
assert proposals_output [2 ] == "0"
116
116
117
- # 0 Nayes for the proposal
117
+ # 0 Nays for the proposal
118
118
assert proposals_output [4 ] == "0"
119
119
120
120
# Assert initial threshold is 3
@@ -123,15 +123,16 @@ def test_senate(local_chain, wallet_setup):
123
123
json_proposals = exec_command_bob (
124
124
command = "sudo" ,
125
125
sub_command = "proposals" ,
126
- extra_args = [
127
- "--chain" ,
128
- "ws://127.0.0.1:9945" ,
129
- "--json-output"
130
- ]
126
+ extra_args = ["--chain" , "ws://127.0.0.1:9945" , "--json-output" ],
131
127
)
132
- json_proposals_outout = json .loads (json_proposals .stdout )
128
+ json_proposals_output = json .loads (json_proposals .stdout )
133
129
134
- assert False , json_proposals_outout
130
+ assert len (json_proposals_output ) == 1
131
+ assert json_proposals_output [0 ]["threshold" ] == 3
132
+ assert json_proposals_output [0 ]["ayes" ] == 0
133
+ assert json_proposals_output [0 ]["nays" ] == 0
134
+ assert json_proposals_output [0 ]["votes" ] == {}
135
+ assert json_proposals_output [0 ]["call_data" ] == "System.remark(remark: (0,))"
135
136
136
137
# Vote on the proposal by Bob (vote aye)
137
138
vote_aye = exec_command_bob (
@@ -176,6 +177,26 @@ def test_senate(local_chain, wallet_setup):
176
177
# Nay votes remain 0
177
178
assert proposals_after_aye_output [4 ] == "0"
178
179
180
+ proposals_after_aye_json = exec_command_bob (
181
+ command = "sudo" ,
182
+ sub_command = "proposals" ,
183
+ extra_args = [
184
+ "--chain" ,
185
+ "ws://127.0.0.1:9945" ,
186
+ "--json-output" ,
187
+ ],
188
+ )
189
+ proposals_after_aye_json_output = json .loads (proposals_after_aye_json .stdout )
190
+ assert len (proposals_after_aye_json_output ) == 1
191
+ assert proposals_after_aye_json_output [0 ]["threshold" ] == 3
192
+ assert proposals_after_aye_json_output [0 ]["ayes" ] == 1
193
+ assert proposals_after_aye_json_output [0 ]["nays" ] == 0
194
+ assert len (proposals_after_aye_json_output [0 ]["votes" ]) == 1
195
+ assert proposals_after_aye_json_output [0 ]["votes" ][keypair_bob .ss58_address ] is True
196
+ assert (
197
+ proposals_after_aye_json_output [0 ]["call_data" ] == "System.remark(remark: (0,))"
198
+ )
199
+
179
200
# Register Alice to the root network (0)
180
201
# Registering to root automatically makes you a senator if eligible
181
202
root_register = exec_command_alice (
@@ -245,4 +266,20 @@ def test_senate(local_chain, wallet_setup):
245
266
# Assert vote casted as Nay
246
267
assert proposals_after_nay_output [10 ].split ()[1 ] == "Nay"
247
268
269
+ proposals_after_nay_json = exec_command_bob (
270
+ command = "sudo" ,
271
+ sub_command = "proposals" ,
272
+ extra_args = [
273
+ "--chain" ,
274
+ "ws://127.0.0.1:9945" ,
275
+ "--json-output" ,
276
+ ],
277
+ )
278
+ proposals_after_nay_json_output = json .loads (proposals_after_nay_json .stdout )
279
+ assert len (proposals_after_nay_json_output ) == 1
280
+ assert proposals_after_nay_json_output [0 ]["nays" ] == 1
281
+ assert (
282
+ proposals_after_nay_json_output [0 ]["votes" ][keypair_alice .ss58_address ] is False
283
+ )
284
+
248
285
print ("✅ Passed senate commands" )
0 commit comments