make bids for lowest rather than highest

This commit is contained in:
2022-09-01 02:02:23 +00:00
parent 0d1513e35d
commit 8f4f5d270a
7 changed files with 30 additions and 30 deletions

View File

@@ -74,7 +74,7 @@ func (b *bidDB) AddBid(auctionId string, bid *types.Bid) error {
}
// Get the highest bid in the list under specified auction key.
func (b *bidDB) GetHighestBid(auctionId string) (*types.Bid, error) {
func (b *bidDB) GetLowestBid(auctionId string) (*types.Bid, error) {
k := []byte(auctionId)
var bid *types.Bid
@@ -108,7 +108,7 @@ func (b *bidDB) GetHighestBid(auctionId string) (*types.Bid, error) {
amt.SetString(rBid.Amount, 10)
} else {
rAmt.SetString(rBid.Amount, 10)
if rAmt.Cmp(amt) == 1 {
if rAmt.Cmp(amt) == -1 {
bid = rBid
}
}

View File

@@ -35,7 +35,7 @@ func TestBasicFlow(t *testing.T) {
}
// check highest bid
if bid, err := BidDB.GetHighestBid("0"); err != nil {
if bid, err := BidDB.GetLowestBid("0"); err != nil {
panic(err)
} else {
if bid.Owner != "cosmos456" || bid.Amount != "200" {