Skip to content

test_not_enough_tokens_for_retry fails intermittently due to dict iteration order assumptions

Sometimes this test fails like this:

_zkapauthorizer.tests.test_storage_client                                                                                                                                                                          
  CallWithPassesTests                                                                                                                                                                                              
    test_not_enough_tokens_for_retry ... Traceback (most recent call last):                                                                                                                                        
Failure: testtools.testresult.real._StringException: Traceback (most recent call last):                                                                                                                            
  File "/nix/store/399a7nnjv1ffxcslywdgmhx3b0ggx5m7-python2.7-zero-knowledge-access-pass-authorizer-0.0/lib/python2.7/site-packages/_zkapauthorizer/tests/test_storage_client.py", line 290, in test_not_enough_tok
ens_for_retry                                                                                                                                                                                                      
    def test_not_enough_tokens_for_retry(self, num_passes, extras):                                                                                                                                                
  File "/nix/store/292g23l2sr0bjp68c2zz1v9qjkqfwl37-python2.7-hypothesis-4.7.3/lib/python2.7/site-packages/hypothesis/core.py", line 974, in wrapped_test                                                          
    state.run()                                                                                                                                                                                                    
  File "/nix/store/292g23l2sr0bjp68c2zz1v9qjkqfwl37-python2.7-hypothesis-4.7.3/lib/python2.7/site-packages/hypothesis/core.py", line 695, in run                                                                   
    info.__expected_traceback,                                                                                                                                                                                     
  File "/nix/store/292g23l2sr0bjp68c2zz1v9qjkqfwl37-python2.7-hypothesis-4.7.3/lib/python2.7/site-packages/hypothesis/core.py", line 568, in execute                                                               
    result = self.test_runner(data, run)                                                                                                                                                                  
  File "/nix/store/292g23l2sr0bjp68c2zz1v9qjkqfwl37-python2.7-hypothesis-4.7.3/lib/python2.7/site-packages/hypothesis/executors.py", line 56, in default_new_style_executor                                        
    return function(data)                                                                                                                                                                                          
  File "/nix/store/292g23l2sr0bjp68c2zz1v9qjkqfwl37-python2.7-hypothesis-4.7.3/lib/python2.7/site-packages/hypothesis/core.py", line 566, in run                                                                   
    return test(*args, **kwargs)                                                                                                                                                                                   
  File "/nix/store/399a7nnjv1ffxcslywdgmhx3b0ggx5m7-python2.7-zero-knowledge-access-pass-authorizer-0.0/lib/python2.7/site-packages/_zkapauthorizer/tests/test_storage_client.py", line 348, in test_not_enough_tok
ens_for_retry                                                                                                                                                                                                      
    issued=Equals(set(accepted + rejected)),                                                                                                                                                                       
  File "/nix/store/g75d1nbgrzm2fn2wpnqzr4nr5pd5pzf8-python2.7-testtools-2.3.0/lib/python2.7/site-packages/testtools/testcase.py", line 498, in assertThat                                                          
    raise mismatch_error                                                                                                                                                                                           
testtools.matchers._impl.MismatchError: Differences: [                                                                                                                                                             
[8, 4, 5, 6, 7] != [4, 5, 6, 7, 8]: after <function <lambda>> on {8: u'signature check failed', 4: u'signature check failed', 5: u'signature check failed', 6: u'signature check failed', 7: u'signature check fail
ed'}: invalid                                                                                                                                                                                                      
]                                                                                                                                                                                                                  

The test compares the result of adict.keys() to a list. It passes when it gets lucky and the order is what it expects. It fails other times.