@@ -79,7 +79,11 @@ def test_initial_report_and_participation_fee_collection(localFixture, universe,
79
79
with EtherDelta (expectedFees , tester .a0 , localFixture .chain , "Redeeming didn't increase ETH correctly" ):
80
80
assert categoricalInitialReport .redeem (tester .a0 )
81
81
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 ):
83
87
feeWindow = localFixture .applySignature ('FeeWindow' , market .getFeeWindow ())
84
88
85
89
# generate some fees
@@ -92,31 +96,35 @@ def test_failed_crowdsourcer_fees(localFixture, universe, market, cash, reputati
92
96
generateFees (localFixture , universe , market )
93
97
94
98
# We'll have testers contribute to a dispute but not reach the target
95
- amount = market .getTotalStake () - 1
99
+ amount = market .getTotalStake ()
96
100
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 ))
99
103
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 ))
102
106
103
107
assert market .getFeeWindow () == feeWindow .address
104
108
105
- payoutDistributionHash = market .derivePayoutDistributionHash ([0 , market .getNumTicks ()], False )
109
+ payoutDistributionHash = market .derivePayoutDistributionHash ([1 , market .getNumTicks ()- 1 ], False )
106
110
failedCrowdsourcer = localFixture .applySignature ("DisputeCrowdsourcer" , market .getCrowdsourcer (payoutDistributionHash ))
107
111
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" ):
116
124
with EtherDelta (expectedTotalFees / 2 , tester .a1 , localFixture .chain , "Redeeming didn't increase ETH correctly" ):
117
125
assert failedCrowdsourcer .redeem (tester .a1 )
118
126
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" ):
120
128
with EtherDelta (cash .balanceOf (failedCrowdsourcer .address ), tester .a2 , localFixture .chain , "Redeeming didn't increase ETH correctly" ):
121
129
assert failedCrowdsourcer .redeem (tester .a2 )
122
130
0 commit comments