88from sovtoken .test .helpers .helper_request import SEC_PER_DAY
99
1010from indy_common .types import Request
11- from plenum .common .constants import DOMAIN_LEDGER_ID
12- from plenum .common .exceptions import UnknownIdentifier , InvalidSignatureFormat , InsufficientCorrectSignatures , \
13- CouldNotAuthenticate
14- from plenum .server .client_authn import CoreAuthNr
11+ from indy_node .server .client_authn import LedgerBasedAuthNr
12+ from plenum .common .exceptions import UnknownIdentifier , InvalidSignatureFormat , InsufficientCorrectSignatures
1513from sovtoken .test .wallet import TokenWallet
1614from sovtoken .client_authnr import TokenAuthNr , AddressSigVerifier
1715from sovtoken .constants import INPUTS , OUTPUTS , EXTRA , ACCEPTABLE_WRITE_TYPES , ACCEPTABLE_QUERY_TYPES , \
@@ -118,7 +116,7 @@ def test_authenticate_invalid_signatures_format(helpers, node, addresses):
118116 token_authnr = TokenAuthNr (ACCEPTABLE_WRITE_TYPES ,
119117 ACCEPTABLE_QUERY_TYPES ,
120118 ACCEPTABLE_ACTION_TYPES ,
121- node [0 ].states [ DOMAIN_LEDGER_ID ] )
119+ node [0 ].db_manager . idr_cache )
122120 outputs = [{"address" : SF_address , "amount" : 30 }, {"address" : user1_address , "amount" : 30 }]
123121 request = helpers .request .mint (outputs )
124122 req_data = request .as_dict
@@ -137,7 +135,7 @@ def test_authenticate_insufficient_valid_signatures_data(helpers, node, addresse
137135 token_authnr = TokenAuthNr (ACCEPTABLE_WRITE_TYPES ,
138136 ACCEPTABLE_QUERY_TYPES ,
139137 ACCEPTABLE_ACTION_TYPES ,
140- node [0 ].states [ DOMAIN_LEDGER_ID ] )
138+ node [0 ].db_manager . idr_cache )
141139 outputs = [{"address" : SF_address , "amount" : 30 }, {"address" : user1_address , "amount" : 30 }]
142140 request = helpers .request .mint (outputs )
143141 req_data = request .as_dict
@@ -153,7 +151,7 @@ def test_authenticate_success_3_sigs(helpers, node, addresses):
153151 token_authnr = TokenAuthNr (ACCEPTABLE_WRITE_TYPES ,
154152 ACCEPTABLE_QUERY_TYPES ,
155153 ACCEPTABLE_ACTION_TYPES ,
156- node [0 ].states [ DOMAIN_LEDGER_ID ] )
154+ node [0 ].db_manager . idr_cache )
157155 outputs = [{"address" : SF_address , "amount" : 30 }, {"address" : user1_address , "amount" : 30 }]
158156 request = helpers .request .mint (outputs )
159157 req_data = request .as_dict
@@ -167,7 +165,7 @@ def test_authenticate_calls_authenticate_xfer(helpers, node, addresses):
167165 token_authnr = TokenAuthNr (ACCEPTABLE_WRITE_TYPES ,
168166 ACCEPTABLE_QUERY_TYPES ,
169167 ACCEPTABLE_ACTION_TYPES ,
170- node [0 ].states [ DOMAIN_LEDGER_ID ] )
168+ node [0 ].db_manager . idr_cache )
171169 inputs = [{"source" : utxo_from_addr_and_seq_no (SF_address , 1 )}]
172170 outputs = [{"address" : user1_address , "amount" : 10 }, {"address" : SF_address , "amount" : 10 }]
173171 request = helpers .request .transfer (inputs , outputs )
@@ -185,7 +183,7 @@ def test_authenticate_xfer_success(node, user2_token_wallet, user2_address, user
185183 token_authnr = TokenAuthNr (ACCEPTABLE_WRITE_TYPES ,
186184 ACCEPTABLE_QUERY_TYPES ,
187185 ACCEPTABLE_ACTION_TYPES ,
188- node [0 ].states [ DOMAIN_LEDGER_ID ] )
186+ node [0 ].db_manager . idr_cache )
189187 inputs = [[user2_token_wallet , user2_address , 1 ]]
190188 outputs = [{"address" : user1_address , "amount" : 10 }, {"address" : user2_address , "amount" : 10 }]
191189 request = xfer_request (inputs , outputs )
@@ -199,7 +197,7 @@ def test_authenticate_xfer_invalid_signature_format(node, user2_token_wallet, us
199197 token_authnr = TokenAuthNr (ACCEPTABLE_WRITE_TYPES ,
200198 ACCEPTABLE_QUERY_TYPES ,
201199 ACCEPTABLE_ACTION_TYPES ,
202- node [0 ].states [ DOMAIN_LEDGER_ID ] )
200+ node [0 ].db_manager . idr_cache )
203201 inputs = [[user2_token_wallet , user2_address , 1 ]]
204202 outputs = [[user1_address , 10 ], [user2_address , 10 ]]
205203 request = xfer_request (inputs , outputs )
@@ -215,7 +213,7 @@ def test_authenticate_xfer_insufficient_correct_signatures(node, user2_token_wal
215213 token_authnr = TokenAuthNr (ACCEPTABLE_WRITE_TYPES ,
216214 ACCEPTABLE_QUERY_TYPES ,
217215 ACCEPTABLE_ACTION_TYPES ,
218- node [0 ].states [ DOMAIN_LEDGER_ID ] )
216+ node [0 ].db_manager . idr_cache )
219217 inputs = [[user2_token_wallet , user2_address , 1 ], [SF_token_wallet , SF_address , 2 ]]
220218 outputs = [[user1_address , 10 ], [user2_address , 10 ]]
221219 request = xfer_request (inputs , outputs )
@@ -232,7 +230,7 @@ def test_authenticate_xfer_with_extra(helpers, node, addresses):
232230 token_authnr = TokenAuthNr (ACCEPTABLE_WRITE_TYPES ,
233231 ACCEPTABLE_QUERY_TYPES ,
234232 ACCEPTABLE_ACTION_TYPES ,
235- node [0 ].states [ DOMAIN_LEDGER_ID ] )
233+ node [0 ].db_manager . idr_cache )
236234 inputs = [{"source" : utxo_from_addr_and_seq_no (SF_address , 1 )}]
237235 outputs = [{"address" : user1_address , "amount" : 10 }, {"address" : SF_address , "amount" : 10 }]
238236 request = helpers .request .transfer (inputs , outputs , extra = json .dumps ({"aaa" : "bbb" }))
@@ -246,7 +244,7 @@ def test_authenticate_xfer_with_extra_not_signed(helpers, node, addresses):
246244 token_authnr = TokenAuthNr (ACCEPTABLE_WRITE_TYPES ,
247245 ACCEPTABLE_QUERY_TYPES ,
248246 ACCEPTABLE_ACTION_TYPES ,
249- node [0 ].states [ DOMAIN_LEDGER_ID ] )
247+ node [0 ].db_manager . idr_cache )
250248 inputs = [{"source" : utxo_from_addr_and_seq_no (SF_address , 1 )}]
251249 outputs = [{"address" : user1_address , "amount" : 10 }, {"address" : SF_address , "amount" : 10 }]
252250 request = helpers .request .transfer (inputs , outputs )
@@ -262,7 +260,7 @@ def test_authenticate_xfer_with_taa(helpers, node, addresses):
262260 token_authnr = TokenAuthNr (ACCEPTABLE_WRITE_TYPES ,
263261 ACCEPTABLE_QUERY_TYPES ,
264262 ACCEPTABLE_ACTION_TYPES ,
265- node [0 ].states [ DOMAIN_LEDGER_ID ] )
263+ node [0 ].db_manager . idr_cache )
266264 inputs = [{"source" : utxo_from_addr_and_seq_no (SF_address , 1 )}]
267265 outputs = [{"address" : user1_address , "amount" : 10 }, {"address" : SF_address , "amount" : 10 }]
268266 extra = helpers .request .add_transaction_author_agreement_to_extra (None , "text" , "mechanism" , "version" )
@@ -276,7 +274,7 @@ def test_authenticate_xfer_with_taa_not_signed(helpers, node, addresses, looper)
276274 token_authnr = TokenAuthNr (ACCEPTABLE_WRITE_TYPES ,
277275 ACCEPTABLE_QUERY_TYPES ,
278276 ACCEPTABLE_ACTION_TYPES ,
279- node [0 ].states [ DOMAIN_LEDGER_ID ] )
277+ node [0 ].db_manager . idr_cache )
280278 inputs = [{"source" : utxo_from_addr_and_seq_no (SF_address , 1 )}]
281279 outputs = [{"address" : user1_address , "amount" : 10 }, {"address" : SF_address , "amount" : 10 }]
282280 request = helpers .request .transfer (inputs , outputs )
@@ -295,13 +293,13 @@ def test_authenticate_xfer_with_taa_not_signed(helpers, node, addresses, looper)
295293# -------------------------Test serializeForSig method------------------------------------------------------------------
296294
297295# This test that the serializeForSig method is being called when a XFER_PUBLIC request is submitted
298- @mock .patch .object (CoreAuthNr , 'serializeForSig' , return_value = True )
296+ @mock .patch .object (LedgerBasedAuthNr , 'serializeForSig' , return_value = True )
299297def test_serializeForSig_XFER_PUBLIC_path (node , user2_token_wallet , user2_address ,
300298 SF_token_wallet , SF_address , user1_address ):
301299 token_authnr = TokenAuthNr (ACCEPTABLE_WRITE_TYPES ,
302300 ACCEPTABLE_QUERY_TYPES ,
303301 ACCEPTABLE_ACTION_TYPES ,
304- node [0 ].states [ DOMAIN_LEDGER_ID ] )
302+ node [0 ].db_manager . idr_cache )
305303 inputs = [[user2_token_wallet , user2_address , 1 ], [SF_token_wallet , SF_address , 2 ]]
306304 outputs = [[user1_address , 10 ], [user1_address , 10 ]]
307305 request = xfer_request (inputs , outputs )
@@ -311,13 +309,13 @@ def test_serializeForSig_XFER_PUBLIC_path(node, user2_token_wallet, user2_addres
311309
312310
313311# This test that the serializeForSig method is being called when a MINT_PUBLIC request is submitted
314- @mock .patch .object (CoreAuthNr , 'serializeForSig' )
312+ @mock .patch .object (LedgerBasedAuthNr , 'serializeForSig' )
315313def test_serializeForSig_MINT_PUBLIC_path (helpers , node , addresses ):
316314 [SF_address , user1_address ] = addresses
317315 token_authnr = TokenAuthNr (ACCEPTABLE_WRITE_TYPES ,
318316 ACCEPTABLE_QUERY_TYPES ,
319317 ACCEPTABLE_ACTION_TYPES ,
320- node [0 ].states [ DOMAIN_LEDGER_ID ] )
318+ node [0 ].db_manager . idr_cache )
321319 outputs = [[SF_address , 30 ], [user1_address , 30 ]]
322320 request = helpers .request .mint (outputs )
323321 msg = request .as_dict
@@ -333,7 +331,7 @@ def test_getVerkey_success(node):
333331 token_authnr = TokenAuthNr (ACCEPTABLE_WRITE_TYPES ,
334332 ACCEPTABLE_QUERY_TYPES ,
335333 ACCEPTABLE_ACTION_TYPES ,
336- node [0 ].states [ DOMAIN_LEDGER_ID ] )
334+ node [0 ].db_manager . idr_cache )
337335 ver_key = token_authnr .getVerkey (VALID_IDENTIFIER , Request ())
338336 assert len (ver_key ) == 23
339337 assert ver_key [0 ] == '~'
@@ -344,7 +342,7 @@ def test_getVerkey_pay_address_success(node):
344342 token_authnr = TokenAuthNr (ACCEPTABLE_WRITE_TYPES ,
345343 ACCEPTABLE_QUERY_TYPES ,
346344 ACCEPTABLE_ACTION_TYPES ,
347- node [0 ].states [ DOMAIN_LEDGER_ID ] )
345+ node [0 ].db_manager . idr_cache )
348346 # TODO change these to indicate they are addresses
349347 identifier_43 = 'sjw1ceG7wtym3VcnyaYtf1xo37gCUQHDR5VWcKWNPLRZ1X8eC'
350348 ver_key = token_authnr .getVerkey (identifier_43 , Request ())
@@ -356,7 +354,7 @@ def test_getVerkey_invalid_identifier(node):
356354 token_authnr = TokenAuthNr (ACCEPTABLE_WRITE_TYPES ,
357355 ACCEPTABLE_QUERY_TYPES ,
358356 ACCEPTABLE_ACTION_TYPES ,
359- node [0 ].states [ DOMAIN_LEDGER_ID ] )
357+ node [0 ].db_manager . idr_cache )
360358 identifier_invalid = 'INVALID_IDENTIFIER'
361359 with pytest .raises (UnknownIdentifier ):
362360 token_authnr .getVerkey (identifier_invalid , Request ())
@@ -370,7 +368,7 @@ def test_get_xfer_ser_data_success(node, user2_token_wallet, user2_address,
370368 token_authnr = TokenAuthNr (ACCEPTABLE_WRITE_TYPES ,
371369 ACCEPTABLE_QUERY_TYPES ,
372370 ACCEPTABLE_ACTION_TYPES ,
373- node [0 ].states [ DOMAIN_LEDGER_ID ] )
371+ node [0 ].db_manager . idr_cache )
374372 inputs = [[user2_token_wallet , user2_address , 1 ], [SF_token_wallet , SF_address , 2 ]]
375373 outputs = [[user1_address , 10 ], [user1_address , 10 ]]
376374 request = xfer_request (inputs , outputs )
0 commit comments