Skip to content

Commit c9ffc55

Browse files
authored
Merge pull request #89 from raiden-network/waiting-period
Add waiting period before claiming tokens
2 parents 4336502 + 4ce00fa commit c9ffc55

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

contracts/auction.sol

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ contract DutchAuction {
1515
* token_multiplier set from token's number of decimals (i.e. 10 ** decimals)
1616
*/
1717

18+
// Wait 7 days after the end of the auction, before ayone can claim tokens
19+
uint constant public token_claim_waiting_period = 7 days;
20+
1821
/*
1922
* Storage
2023
*/
@@ -260,6 +263,10 @@ contract DutchAuction {
260263
isValidPayload
261264
atStage(Stages.AuctionEnded)
262265
{
266+
// Waiting period after the end of the auction, before anyone can claim tokens
267+
// Ensures enough time to check if auction was finalized correctly
268+
// before users start transacting tokens
269+
require(now > end_time + token_claim_waiting_period);
263270
require(receiver_address != 0x0);
264271
require(bids[receiver_address] > 0);
265272

tests/auction_fixtures.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ def get(token, auction, bidders, distributor=None):
176176
assert final_price > 0
177177

178178
for i, bidder in enumerate(bidders):
179-
print('auction_claim_tokens_tested bidder', bidder)
180179
values.append(auction.call().bids(bidder))
181180
tokens_expected = token_multiplier * values[i] // final_price
182181
expected_tokens.append(tokens_expected)
@@ -188,11 +187,9 @@ def get(token, auction, bidders, distributor=None):
188187
assert values[i] > 0
189188

190189
if len(bidders) == 1:
191-
print('auction_claim_tokens_tested claimTokens', bidders[0])
192190
auction.transact({'from': bidders[0]}).claimTokens()
193191
# auction.transact({'from': owner}).claimTokens(bidders[0])
194192
else:
195-
print('auction_claim_tokens_tested distribute', bidders)
196193
distributor.transact({'from': owner}).distribute(bidders)
197194

198195
for i, bidder in enumerate(bidders):

tests/test_auction.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,14 @@ def test_auction_bid(
293293
'value': 1
294294
})
295295

296+
# Claim tokens only after waiting period
297+
with pytest.raises(tester.TransactionFailed):
298+
auction_claim_tokens_tested(token, auction, A)
299+
300+
end_time = auction.call().end_time()
301+
elapsed = auction.call().token_claim_waiting_period()
302+
web3.testing.timeTravel(end_time + elapsed+1)
303+
296304
auction_claim_tokens_tested(token, auction, A)
297305

298306
assert auction.call().stage() == 4 # TokensDistributed
@@ -677,6 +685,14 @@ def test_auction_simulation(
677685

678686
rounding_error_tokens = 0
679687

688+
# Claim tokens only after waiting period
689+
with pytest.raises(tester.TransactionFailed):
690+
auction_claim_tokens_tested(token, auction, bidders[0])
691+
692+
end_time = auction.call().end_time()
693+
elapsed = auction.call().token_claim_waiting_period()
694+
web3.testing.timeTravel(end_time + elapsed+1)
695+
680696
for i in range(0, index):
681697
bidder = bidders[i]
682698

0 commit comments

Comments
 (0)