mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-24 23:35:19 +00:00
fix tests
This commit is contained in:
parent
3ee16963aa
commit
1a46b3fa2b
@ -68,19 +68,18 @@ func (a BaseAuction) GetType() string { return "base" }
|
|||||||
|
|
||||||
// Validate verifies that the auction end time is before max end time
|
// Validate verifies that the auction end time is before max end time
|
||||||
func (a BaseAuction) Validate() error {
|
func (a BaseAuction) Validate() error {
|
||||||
if a.ID == 0 {
|
// ID can be 0 for surplus, Debt and collateral auctions
|
||||||
return errors.New("auction id cannot be zero")
|
|
||||||
}
|
|
||||||
if strings.TrimSpace(a.Initiator) == "" {
|
if strings.TrimSpace(a.Initiator) == "" {
|
||||||
return errors.New("auction initiator cannot be blank")
|
return errors.New("auction initiator cannot be blank")
|
||||||
}
|
}
|
||||||
if !a.Lot.IsValid() {
|
if !a.Lot.IsValid() {
|
||||||
return fmt.Errorf("invalid lot: %s", a.Lot)
|
return fmt.Errorf("invalid lot: %s", a.Lot)
|
||||||
}
|
}
|
||||||
if a.Bidder.Empty() {
|
// NOTE: bidder can be nil for Surplus and Collateral auctions
|
||||||
|
if a.Bidder != nil && a.Bidder.Empty() {
|
||||||
return errors.New("auction bidder cannot be empty")
|
return errors.New("auction bidder cannot be empty")
|
||||||
}
|
}
|
||||||
if len(a.Bidder) != sdk.AddrLen {
|
if a.Bidder != nil && len(a.Bidder) != sdk.AddrLen {
|
||||||
return fmt.Errorf("the expected bidder address length is %d, actual length is %d", sdk.AddrLen, len(a.Bidder))
|
return fmt.Errorf("the expected bidder address length is %d, actual length is %d", sdk.AddrLen, len(a.Bidder))
|
||||||
}
|
}
|
||||||
if !a.Bid.IsValid() {
|
if !a.Bid.IsValid() {
|
||||||
|
@ -107,11 +107,6 @@ func TestBaseAuctionValidate(t *testing.T) {
|
|||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"0 id",
|
|
||||||
BaseAuction{ID: 0},
|
|
||||||
false,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"blank initiator",
|
"blank initiator",
|
||||||
BaseAuction{
|
BaseAuction{
|
||||||
@ -135,7 +130,7 @@ func TestBaseAuctionValidate(t *testing.T) {
|
|||||||
ID: 1,
|
ID: 1,
|
||||||
Initiator: testAccAddress1,
|
Initiator: testAccAddress1,
|
||||||
Lot: c("kava", 1),
|
Lot: c("kava", 1),
|
||||||
Bidder: nil,
|
Bidder: sdk.AccAddress{},
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user