Skip to content

Commit 6fbd9eb

Browse files
Prevent token&auction address to be used in bid()
Closes #91 Token and auction contract addresses should not be used as receivers of tokens.
1 parent c9ffc55 commit 6fbd9eb

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

contracts/auction.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ contract DutchAuction {
227227
atStage(Stages.AuctionStarted)
228228
{
229229
require(receiver_address != 0x0);
230+
require(receiver_address != address(this));
231+
require(receiver_address != address(token));
230232
require(msg.value > 0);
231233
assert(bids[receiver_address] + msg.value >= msg.value);
232234

tests/test_auction.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,13 @@ def test_auction_bid(
255255
token_multiplier = auction.call().token_multiplier()
256256

257257
auction.transact({'from': owner}).startAuction()
258+
# Bids with the token contract address as receiver should fail
259+
with pytest.raises(tester.TransactionFailed):
260+
auction.transact({'from': A, "value": 100}).bid(token.address)
261+
262+
# Bids with the auction contract address as receiver should fail
263+
with pytest.raises(tester.TransactionFailed):
264+
auction.transact({'from': A, "value": 100}).bid(auction.address)
258265

259266
# End auction by bidding the needed amount
260267
missing_funds = auction.call().missingFundsToEndAuction()

0 commit comments

Comments
 (0)