@@ -79,7 +79,11 @@ def test_initial_report_and_participation_fee_collection(localFixture, universe,
7979 with EtherDelta (expectedFees , tester .a0 , localFixture .chain , "Redeeming didn't increase ETH correctly" ):
8080 assert categoricalInitialReport .redeem (tester .a0 )
8181
82- def test_failed_crowdsourcer_fees (localFixture , universe , market , cash , reputationToken ):
82+ @mark .parametrize ('finalize' , [
83+ True ,
84+ False ,
85+ ])
86+ def test_failed_crowdsourcer_fees (finalize , localFixture , universe , market , cash , reputationToken ):
8387 feeWindow = localFixture .applySignature ('FeeWindow' , market .getFeeWindow ())
8488
8589 # generate some fees
@@ -92,31 +96,35 @@ def test_failed_crowdsourcer_fees(localFixture, universe, market, cash, reputati
9296 generateFees (localFixture , universe , market )
9397
9498 # We'll have testers contribute to a dispute but not reach the target
95- amount = market .getTotalStake () - 1
99+ amount = market .getTotalStake ()
96100
97- with TokenDelta (reputationToken , - amount , tester .a1 , "Disputing did not reduce REP balance correctly" ):
98- assert market .contribute ([0 , market .getNumTicks ()], False , amount , sender = tester .k1 , startgas = long (6.7 * 10 ** 6 ))
101+ with TokenDelta (reputationToken , - amount + 1 , tester .a1 , "Disputing did not reduce REP balance correctly" ):
102+ assert market .contribute ([1 , market .getNumTicks ()- 1 ], False , amount - 1 , sender = tester .k1 , startgas = long (6.7 * 10 ** 6 ))
99103
100- with TokenDelta (reputationToken , - amount , tester .a2 , "Disputing did not reduce REP balance correctly" ):
101- assert market .contribute ([0 , market .getNumTicks ()], False , amount , sender = tester .k2 , startgas = long (6.7 * 10 ** 6 ))
104+ with TokenDelta (reputationToken , - amount + 1 , tester .a2 , "Disputing did not reduce REP balance correctly" ):
105+ assert market .contribute ([1 , market .getNumTicks ()- 1 ], False , amount - 1 , sender = tester .k2 , startgas = long (6.7 * 10 ** 6 ))
102106
103107 assert market .getFeeWindow () == feeWindow .address
104108
105- payoutDistributionHash = market .derivePayoutDistributionHash ([0 , market .getNumTicks ()], False )
109+ payoutDistributionHash = market .derivePayoutDistributionHash ([1 , market .getNumTicks ()- 1 ], False )
106110 failedCrowdsourcer = localFixture .applySignature ("DisputeCrowdsourcer" , market .getCrowdsourcer (payoutDistributionHash ))
107111
108- # Fast forward time until the fee window is over and we can redeem to recieve the REP back and fees
109- localFixture .contracts ["Time" ].setTimestamp (feeWindow .getEndTime () + 1 )
110- assert market .finalize ()
111-
112- # The dispute crowdsourcer contributor locked in REP for 2 rounds, as did the Initial Reporter
113- expectedTotalFees = getExpectedFees (localFixture , cash , failedCrowdsourcer , 1 )
114-
115- with TokenDelta (reputationToken , amount , tester .a1 , "Redeeming did not refund REP" ):
112+ if finalize :
113+ # Fast forward time until the fee window is over and we can redeem to recieve the REP back and fees
114+ localFixture .contracts ["Time" ].setTimestamp (feeWindow .getEndTime () + 1 )
115+ expectedTotalFees = getExpectedFees (localFixture , cash , failedCrowdsourcer , 1 )
116+ else :
117+ # Continue to the next round which will disavow failed crowdsourcers and let us redeem once the window is over
118+ market .contribute ([0 , market .getNumTicks ()], False , amount * 2 , startgas = long (6.7 * 10 ** 6 ))
119+ assert market .getFeeWindow () != feeWindow .address
120+ localFixture .contracts ["Time" ].setTimestamp (feeWindow .getEndTime () + 1 )
121+ expectedTotalFees = getExpectedFees (localFixture , cash , failedCrowdsourcer , 1 )
122+
123+ with TokenDelta (reputationToken , amount - 1 , tester .a1 , "Redeeming did not refund REP" ):
116124 with EtherDelta (expectedTotalFees / 2 , tester .a1 , localFixture .chain , "Redeeming didn't increase ETH correctly" ):
117125 assert failedCrowdsourcer .redeem (tester .a1 )
118126
119- with TokenDelta (reputationToken , amount , tester .a2 , "Redeeming did not refund REP" ):
127+ with TokenDelta (reputationToken , amount - 1 , tester .a2 , "Redeeming did not refund REP" ):
120128 with EtherDelta (cash .balanceOf (failedCrowdsourcer .address ), tester .a2 , localFixture .chain , "Redeeming didn't increase ETH correctly" ):
121129 assert failedCrowdsourcer .redeem (tester .a2 )
122130
0 commit comments