From 71cd17e1c5e28b376dbf8b6bf2b938f7732c0145 Mon Sep 17 00:00:00 2001 From: rain Date: Sat, 8 Oct 2016 12:03:52 +0800 Subject: [PATCH] split up auction manager tests --- contracts/tests/auction_manager.sol | 69 ++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 20 deletions(-) diff --git a/contracts/tests/auction_manager.sol b/contracts/tests/auction_manager.sol index a7729e9..8566865 100644 --- a/contracts/tests/auction_manager.sol +++ b/contracts/tests/auction_manager.sol @@ -2,11 +2,14 @@ pragma solidity ^0.4.0; import 'tests/base.sol'; -contract AuctionManagerTest is AuctionTest { +contract SetUpTest is AuctionTest { function testSetUp() { assertEq(t2.balanceOf(bidder1), 1000 * T2); assertEq(t2.allowance(bidder1, manager), 1000 * T2); } +} + +contract NewAuctionTest is AuctionTest { function newAuction() returns (uint, uint) { return manager.newAuction( seller // beneficiary , t1 // selling @@ -23,16 +26,6 @@ contract AuctionManagerTest is AuctionTest { expectEventsExact(manager); LogNewAuction(id, base); } - function testBidEvent() { - var (id, base) = newAuction(); - bidder1.doBid(base, 11 * T2); - bidder2.doBid(base, 12 * T2); - - expectEventsExact(manager); - LogNewAuction(id, base); - LogBid(base); - LogBid(base); - } function testNewAuction() { var (id, base) = newAuction(); assertEq(id, 1); @@ -76,6 +69,29 @@ contract AuctionManagerTest is AuctionTest { assertEq(buy_amount, 10 * T2); assertEq(sell_amount, 100 * T1); } +} + +contract BidTest is AuctionTest { + function newAuction() returns (uint, uint) { + return manager.newAuction( seller // beneficiary + , t1 // selling + , t2 // buying + , 100 * T1 // sell_amount + , 10 * T2 // start_bid + , 1 // min_increase (%) + , 1 years // ttl + ); + } + function testBidEvent() { + var (id, base) = newAuction(); + bidder1.doBid(base, 11 * T2); + bidder2.doBid(base, 12 * T2); + + expectEventsExact(manager); + LogNewAuction(id, base); + LogBid(base); + LogBid(base); + } function testFailBidUnderMinBid() { var (id, base) = newAuction(); bidder1.doBid(base, 9 * T2); @@ -144,6 +160,28 @@ contract AuctionManagerTest is AuctionTest { assertEq(balance_after - balance_before, 40 * T2); } + function testBidTransfersToDistinctBeneficiary() { + var (id, base) = manager.newAuction(bidder2, t1, t2, 100 * T1, 0 * T2, 1, 1 years); + + var balance_before = t2.balanceOf(bidder2); + bidder1.doBid(base, 10 * T2); + var balance_after = t2.balanceOf(bidder2); + + assertEq(balance_after - balance_before, 10 * T2); + } +} + +contract MultipleAuctionTest is AuctionTest { + function newAuction() returns (uint, uint) { + return manager.newAuction( seller // beneficiary + , t1 // selling + , t2 // buying + , 100 * T1 // sell_amount + , 10 * T2 // start_bid + , 1 // min_increase (%) + , 1 years // ttl + ); + } function testMultipleNewAuctions() { // auction manager should be able to manage multiple auctions t2.transfer(seller, 200 * T2); @@ -198,15 +236,6 @@ contract AuctionManagerTest is AuctionTest { assertEq(balance_before - balance_after, 200 * T1); } - function testBidTransfersToDistinctBeneficiary() { - var (id, base) = manager.newAuction(bidder2, t1, t2, 100 * T1, 0 * T2, 1, 1 years); - - var balance_before = t2.balanceOf(bidder2); - bidder1.doBid(base, 10 * T2); - var balance_after = t2.balanceOf(bidder2); - - assertEq(balance_after - balance_before, 10 * T2); - } } contract MinBidIncreaseTest is AuctionTest {