github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/docs/assets/how-to-guides/porting-solidity-to-gno/porting-6.gno (about)

     1  // Bid Function Test - Send Coin
     2  func TestBidCoins(t *testing.T) {
     3  	// Sending two types of coins
     4  	std.TestSetOrigCaller(bidder01)
     5  	std.TestSetOrigSend(std.Coins{{"ugnot", 0}, {"test", 1}}, nil)
     6  	shouldPanic(t, Bid)
     7  
     8  	// Sending lower amount than the current highest bid
     9  	std.TestSetOrigCaller(bidder01)
    10  	std.TestSetOrigSend(std.Coins{{"ugnot", 0}}, nil)
    11  	shouldPanic(t, Bid)
    12  
    13  	// Sending more amount than the current highest bid (exceeded)
    14  	std.TestSetOrigCaller(bidder01)
    15  	std.TestSetOrigSend(std.Coins{{"ugnot", 1}}, nil)
    16  	shouldNoPanic(t, Bid)
    17  }
    18  
    19  // Bid Function Test - Bid by two or more people
    20  func TestBidCoins(t *testing.T) {
    21  	// bidder01 bidding with 1 coin
    22  	std.TestSetOrigCaller(bidder01)
    23  	std.TestSetOrigSend(std.Coins{{"ugnot", 1}}, nil)
    24  	shouldNoPanic(t, Bid)
    25  	shouldEqual(t, highestBid, 1)
    26  	shouldEqual(t, highestBidder, bidder01)
    27  	shouldEqual(t, pendingReturns.Size(), 0)
    28  
    29  	// bidder02 bidding with 1 coin
    30  	std.TestSetOrigCaller(bidder02)
    31  	std.TestSetOrigSend(std.Coins{{"ugnot", 1}}, nil)
    32  	shouldPanic(t, Bid)
    33  
    34  	// bidder02 bidding with 2 coins
    35  	std.TestSetOrigCaller(bidder02)
    36  	std.TestSetOrigSend(std.Coins{{"ugnot", 2}}, nil)
    37  	shouldNoPanic(t, Bid)
    38  	shouldEqual(t, highestBid, 2)
    39  	shouldEqual(t, highestBidder, bidder02)
    40  	shouldEqual(t, pendingReturns.Size(), 1)
    41  }