@ -73,23 +73,70 @@ def get_options():
return options
return options
@pytest . mark . parametrize (
@pytest . mark . parametrize (
" destaddrs, txcparams, mixdepthcount " ,
" destaddrs, txcparams, mixdepthcount, mixdepthbal " ,
[
[
# very simple case
( [ " mzzAYbtPpANxpNVGCVBAhZYzrxyZtoix7i " ,
( [ " mzzAYbtPpANxpNVGCVBAhZYzrxyZtoix7i " ,
" mifCWfmygxKhsP3qM3HZi3ZjBEJu7m39h8 " ,
" mifCWfmygxKhsP3qM3HZi3ZjBEJu7m39h8 " ,
" mnTn9KVQQT9zy9R4E2ZGzWPK4EfcEcV9Y5 " ] , ( 18 , 3 ) , 4 ) ,
" mnTn9KVQQT9zy9R4E2ZGzWPK4EfcEcV9Y5 " ] , ( 3 , 0 ) , 3 ,
{ 0 : 1 } ) ,
# with 2 non-empty mixdepths
( [ " mzzAYbtPpANxpNVGCVBAhZYzrxyZtoix7i " ,
" mifCWfmygxKhsP3qM3HZi3ZjBEJu7m39h8 " ,
" mnTn9KVQQT9zy9R4E2ZGzWPK4EfcEcV9Y5 " ] , ( 7 , 0 ) , 3 ,
{ 2 : 1 , 3 : 1 } ) ,
#intended to trigger txcount=1 bump to 2
#intended to trigger txcount=1 bump to 2
( [ " mzzAYbtPpANxpNVGCVBAhZYzrxyZtoix7i " ,
( [ " mzzAYbtPpANxpNVGCVBAhZYzrxyZtoix7i " ,
" mifCWfmygxKhsP3qM3HZi3ZjBEJu7m39h8 " ,
" mifCWfmygxKhsP3qM3HZi3ZjBEJu7m39h8 " ,
" mnTn9KVQQT9zy9R4E2ZGzWPK4EfcEcV9Y5 " ] , ( 3 , 2 ) , 80 ) ,
" mnTn9KVQQT9zy9R4E2ZGzWPK4EfcEcV9Y5 " ] , ( 3 , 2 ) , 8 ,
{ 2 : 1 , 3 : 1 } ) ,
] )
] )
def test_tumble_schedule ( destaddrs , txcparams , mixdepthcount ) :
def test_tumble_schedule ( destaddrs , txcparams , mixdepthcount , mixdepthbal ) :
# note that these tests are currently only leaving the default
# value for the final argument to get_tumble_schedule, i.e. 4,
# and will fail if this is changed:
wallet_total_mixdepths = 5
options = get_options ( )
options = get_options ( )
options [ ' mixdepthcount ' ] = mixdepthcount
options [ ' mixdepthcount ' ] = mixdepthcount
options [ ' txcountparams ' ] = txcparams
options [ ' txcountparams ' ] = txcparams
schedule = get_tumble_schedule ( options , destaddrs , { 0 : 1 } )
schedule = get_tumble_schedule ( options , destaddrs , mixdepthbal )
# first, examine the destination addresses; all the requested
# ones should be in the list, and all the others should be one
# of the two standard 'code' alternatives.
dests = [ x [ 3 ] for x in schedule ]
dests = [ x [ 3 ] for x in schedule ]
assert set ( destaddrs ) . issubset ( set ( dests ) )
assert set ( destaddrs ) . issubset ( set ( dests ) )
nondestaddrs = [ x [ 3 ] for x in schedule if x [ 3 ] not in destaddrs ]
assert all ( [ x in [ " INTERNAL " , " addrask " ] for x in nondestaddrs ] )
# second: check that the total number of transactions is larger
# than the minimum it could be and smaller than the max;
# the last term accounts for the Phase 1 sweeps
assert len ( schedule ) > = ( mixdepthcount - 1 ) * (
txcparams [ 0 ] - txcparams [ 1 ] ) + 1 + len ( mixdepthbal . items ( ) )
assert len ( schedule ) < = ( mixdepthcount - 1 ) * (
txcparams [ 0 ] + txcparams [ 1 ] ) + 1 + len ( mixdepthbal . items ( ) )
# check that the source mixdepths for the phase 1 transactions are the
# expected, and that they are all sweeps:
for i , s in enumerate ( schedule [ : len ( mixdepthbal ) ] ) :
assert s [ 1 ] == 0
assert s [ 0 ] in mixdepthbal . keys ( )
# check that the list of created transactions in Phase 2 only
# progresses forward, one mixdepth at a time:
for first , second in zip ( schedule [ len ( mixdepthbal ) : - 1 ] ,
schedule [ len ( mixdepthbal ) + 1 : ] ) :
assert ( second [ 0 ] - first [ 0 ] ) % wallet_total_mixdepths in [ 1 , 0 ]
# check that the amount fractions are always total < 1
last_s = [ ]
for s in schedule :
if last_s == [ ] :
last_s = s
total_amt = 0
continue
if s [ 0 ] == last_s [ 0 ] :
total_amt + = s [ 1 ]
else :
assert total_amt < 1
total_amt = 0
last_s = s
@pytest . mark . parametrize (
@pytest . mark . parametrize (
" destaddrs, txcparams, mixdepthcount, lastcompleted, makercountrange " ,
" destaddrs, txcparams, mixdepthcount, lastcompleted, makercountrange " ,