@@ -205,12 +205,15 @@ def test_update_contract_execution_order(self):
205205 # INVOCATION #
206206
207207 def wait_for_scheduler_invocation_1 (self ):
208- time .sleep (60 )
208+ time .sleep (55 )
209209
210210 def disable_schedule (self ):
211211 self .assertTrue (self .client .update_smart_contract (SMART_CONTRACT_SCHEDULER_ID , disable_schedule = True ).get ("ok" ))
212212 self .assertTrue (self .client .update_smart_contract (SMART_CONTRACT_CRON_ID , disable_schedule = True ).get ("ok" ))
213213
214+ def wait_for_scheduler_invocation_2 (self ):
215+ time .sleep (20 )
216+
214217 def test_successful_invocation_of_scheduler (self ):
215218 transaction_invocation = self .client .query_transactions (SMART_CONTRACT_SCHEDULER_NAME , "*" )
216219 global SCHEDULER_INVOCATION_COUNT
@@ -225,7 +228,7 @@ def test_successful_invocation_of_cron(self):
225228 self .assertGreater (CRON_INVOCATION_COUNT , 0 )
226229 self .assertGreater (transaction_invocation ["response" ]["results" ][0 ]["header" ]["timestamp" ], CREATION_TIMESTAMP )
227230
228- def wait_for_scheduler_invocation_2 (self ):
231+ def wait_for_scheduler_invocation_3 (self ):
229232 time .sleep (65 )
230233
231234 def test_disable_schedule_works_on_scheduler (self ):
@@ -239,17 +242,24 @@ def test_disable_schedule_works_on_cron(self):
239242 self .assertEqual (CRON_INVOCATION_COUNT , transaction_invocation ["response" ]["total" ])
240243
241244 def test_successful_invocation_with_transactions (self ):
242- args_transaction = self .client .create_transaction (SMART_CONTRACT_ARGS_NAME , "banana" , tag = "banana" )
243- env_transaction = self .client .create_transaction (SMART_CONTRACT_ENV_NAME , "banana" , tag = "banana" )
244- secrets_transaction = self .client .create_transaction (SMART_CONTRACT_SECRETS_NAME , "banana" , tag = "banana" )
245- time .sleep (15 )
246- args_query = self .client .query_transactions (SMART_CONTRACT_ARGS_NAME , "banana" )
247- env_query = self .client .query_transactions (SMART_CONTRACT_ENV_NAME , "banana" )
248- secrets_query = self .client .query_transactions (SMART_CONTRACT_SECRETS_NAME , "banana" )
245+ args_transaction = self .client .create_transaction (SMART_CONTRACT_ARGS_NAME , "banana" )
246+ env_transaction = self .client .create_transaction (SMART_CONTRACT_ENV_NAME , "banana" )
247+ secrets_transaction = self .client .create_transaction (SMART_CONTRACT_SECRETS_NAME , "banana" )
248+ time .sleep (30 )
249+ # Query for created transactions by invoker tag
250+ args_query = self .client .query_transactions (
251+ SMART_CONTRACT_ARGS_NAME , "@invoker:{{{}}}" .format (args_transaction .get ("response" ).get ("transaction_id" ).replace ("-" , "\\ -" ))
252+ )
253+ env_query = self .client .query_transactions (
254+ SMART_CONTRACT_ENV_NAME , "@invoker:{{{}}}" .format (env_transaction .get ("response" ).get ("transaction_id" ).replace ("-" , "\\ -" ))
255+ )
256+ secrets_query = self .client .query_transactions (
257+ SMART_CONTRACT_SECRETS_NAME , "@invoker:{{{}}}" .format (secrets_transaction .get ("response" ).get ("transaction_id" ).replace ("-" , "\\ -" ))
258+ )
259+ # Check that the queries were successful and had a result with the invoker
249260 self .assertEqual (args_query ["response" ]["results" ][0 ]["header" ]["invoker" ], args_transaction ["response" ]["transaction_id" ])
250261 self .assertEqual (env_query ["response" ]["results" ][0 ]["header" ]["invoker" ], env_transaction ["response" ]["transaction_id" ])
251262 self .assertEqual (secrets_query ["response" ]["results" ][0 ]["header" ]["invoker" ], secrets_transaction ["response" ]["transaction_id" ])
252- time .sleep (10 )
253263
254264 # SMART CONTRACT LOGS #
255265
@@ -381,9 +391,10 @@ def suite():
381391 suite .addTest (TestSmartContracts ("test_update_contract_execution_order" ))
382392 suite .addTest (TestSmartContracts ("wait_for_scheduler_invocation_1" ))
383393 suite .addTest (TestSmartContracts ("disable_schedule" ))
394+ suite .addTest (TestSmartContracts ("wait_for_scheduler_invocation_2" ))
384395 suite .addTest (TestSmartContracts ("test_successful_invocation_of_scheduler" ))
385396 suite .addTest (TestSmartContracts ("test_successful_invocation_of_cron" ))
386- suite .addTest (TestSmartContracts ("wait_for_scheduler_invocation_2 " ))
397+ suite .addTest (TestSmartContracts ("wait_for_scheduler_invocation_3 " ))
387398 suite .addTest (TestSmartContracts ("test_disable_schedule_works_on_scheduler" ))
388399 suite .addTest (TestSmartContracts ("test_disable_schedule_works_on_cron" ))
389400 suite .addTest (TestSmartContracts ("test_successful_invocation_with_transactions" ))
0 commit comments