gpu-compute-chain/x/cosmostest/memdb/biddb_test.go

31 lines
633 B
Go
Raw Normal View History

2022-08-28 17:42:43 -07:00
package memdb
import (
"cosmos-test/x/cosmostest/types"
"testing"
)
func TestBasicFlow(t *testing.T) {
// this should panic if there's a problem
BidDB.Mount()
// add a bid
2022-08-28 18:03:12 -07:00
if err := BidDB.AddBid("0", &types.Bid{Owner: "cosmos123", Amount: "100"}); err != nil {
2022-08-28 17:42:43 -07:00
panic(err)
}
2022-08-28 18:03:12 -07:00
// add a higher bid (won't check amount, though)
if err := BidDB.AddBid("0", &types.Bid{Owner: "cosmos456", Amount: "200"}); err != nil {
panic(err)
}
2022-08-28 17:42:43 -07:00
if bid, err := BidDB.GetHighestBid("0"); err != nil {
panic(err)
} else {
2022-08-28 18:03:12 -07:00
if bid.Owner != "cosmos456" || bid.Amount != "200" {
panic("Highest auction item not selected")
}
2022-08-28 17:42:43 -07:00
}
}