16
16
import rscoin
17
17
from rscoin .rscservice import RSCFactory , load_setup , get_authorities
18
18
from rscoin .rscservice import package_query , unpackage_query_response , \
19
- package_commit , unpackage_commit_response
19
+ package_commit , package_issue , unpackage_commit_response
20
20
21
21
22
22
@@ -131,12 +131,13 @@ def test_TxCommit(sometx):
131
131
for ik in tx3 .get_utxo_in_keys ():
132
132
assert ik in factory .db
133
133
134
- data1 = map (b64encode , [tx3 .serialize (), tx1 .serialize (), tx2 .serialize (),
135
- k1 .export ()[0 ], k2 .export ()[0 ], k1 .sign (tx3 .id ()), k2 .sign (tx3 .id ())])
134
+ # data1 = map(b64encode, [tx3.serialize(), tx1.serialize(), tx2.serialize(),
135
+ # k1.export()[0], k2.export()[0], k1.sign(tx3.id()), k2.sign(tx3.id())])
136
136
137
- H = sha256 (" " .join (data1 )).digest ()
137
+ # H = sha256(" ".join(data1)).digest()
138
138
139
- data = " " .join (["Query" , str (len (data1 ))] + data1 )
139
+ #data = " ".join(["Query", str(len(data1))] + data1)
140
+ H , data , dataCore = package_query (tx3 , [tx1 , tx2 ], [k1 , k2 ])
140
141
141
142
instance .lineReceived (data )
142
143
response = tr .value ()
@@ -148,7 +149,9 @@ def test_TxCommit(sometx):
148
149
149
150
## Now we test the Commit
150
151
tr .clear ()
151
- data = " " .join (["Commit" , str (len (data1 ))] + data1 + map (b64encode , [k , s ]))
152
+ # data = " ".join(["Commit", str(len(dataCore))] + dataCore + map(b64encode, [k, s]))
153
+
154
+ data = package_commit (dataCore , [(k , s )])
152
155
instance .lineReceived (data )
153
156
154
157
flag , pub , sig = tr .value ().split (" " )
@@ -161,29 +164,27 @@ def test_TxCommit_Issued(sometx):
161
164
(factory , instance , tr ), (k1 , k2 , tx1 , tx2 , tx3 ) = sometx
162
165
163
166
kIssue = rscoin .Key (urandom (32 ), public = False )
164
- pubIssue = kIssue .pub .export ()
165
- factory .special_key = kIssue .id () # Asssign this as the special key
167
+ pubIssue = kIssue .export ()[0 ]
166
168
167
- k1 = rscoin .Key (urandom (32 ), public = False )
168
- k1pub = k1 .pub .export ()
169
+ factory .special_key = kIssue .id () # Asssign this as the special key
169
170
170
171
tx3 = rscoin .Tx ([], [rscoin .OutputTx (k1 .id (), 250 )])
171
172
172
173
sig1 = kIssue .sign (tx3 .id ())
173
174
assert tx3 .check_transaction_utxo ([], [pubIssue ], [sig1 ], kIssue .id ())
174
-
175
175
assert tx3 .check_transaction ([], [pubIssue ], [sig1 ], kIssue .id ())
176
176
177
177
## Now we test the Commit
178
- data1 = map (b64encode , [tx3 .serialize (), pubIssue , sig1 ])
179
178
180
179
# Ensure the entries are not in before sending message
181
180
for k , v in tx3 .get_utxo_out_entries ():
182
181
assert k not in factory .db
183
182
184
183
# Send message
185
184
tr .clear ()
186
- data = " " .join (["Commit" , str (len (data1 ))] + data1 )
185
+
186
+ data = package_issue (tx3 , [kIssue , sig1 ])
187
+
187
188
instance .lineReceived (data )
188
189
189
190
# Ensure the returned signatures check
@@ -463,7 +464,7 @@ def test_full_client(msg_mass):
463
464
def test_commit_error (sometx ):
464
465
(factory , instance , tr ), (k1 , k2 , tx1 , tx2 , tx3 ) = sometx
465
466
466
- instance .lineReceived ("Commit X Y Z" )
467
+ instance .lineReceived ("xCommit X Y Z" )
467
468
assert tr .value ().strip () == "Error ParsingError"
468
469
469
470
@pytest .mark .online
@@ -503,8 +504,10 @@ def test_online_issue(sometx):
503
504
sig1 = kIssue .sign (tx3 .id ())
504
505
505
506
## Now we test the Commit
506
- data1 = map (b64encode , [tx3 .serialize (), pubIssue , sig1 ])
507
- data = " " .join (["Commit" , str (len (data1 ))] + data1 )
507
+ #data1 = map(b64encode, [tx3.serialize(), pubIssue, sig1])
508
+ #data = " ".join(["Commit", str(len(data1))] + data1)
509
+
510
+ data = package_issue (tx3 , [kIssue , sig1 ])
508
511
509
512
# test on fake
510
513
tr .clear ()
0 commit comments