mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-26 16:25:21 +00:00
resolve minor TODOs
This commit is contained in:
parent
d03509a17a
commit
65ef8a9ba3
@ -121,7 +121,7 @@ func (k Keeper) PlaceBidSurplus(ctx sdk.Context, a types.SurplusAuction, bidder
|
|||||||
if bid.Denom != a.Bid.Denom {
|
if bid.Denom != a.Bid.Denom {
|
||||||
return a, sdk.ErrInternal("bid denom doesn't match auction")
|
return a, sdk.ErrInternal("bid denom doesn't match auction")
|
||||||
}
|
}
|
||||||
if !a.Bid.IsLT(bid) { // TODO add minimum bid size
|
if !a.Bid.IsLT(bid) {
|
||||||
return a, sdk.ErrInternal("bid not greater than last bid")
|
return a, sdk.ErrInternal("bid not greater than last bid")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,7 +255,7 @@ func (k Keeper) PlaceBidDebt(ctx sdk.Context, a types.DebtAuction, bidder sdk.Ac
|
|||||||
if lot.IsNegative() {
|
if lot.IsNegative() {
|
||||||
return a, sdk.ErrInternal("lot less than 0")
|
return a, sdk.ErrInternal("lot less than 0")
|
||||||
}
|
}
|
||||||
if !lot.IsLT(a.Lot) { // TODO add min bid decrements
|
if !lot.IsLT(a.Lot) {
|
||||||
return a, sdk.ErrInternal("lot not smaller than last lot")
|
return a, sdk.ErrInternal("lot not smaller than last lot")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ func TestStartSurplusAuction(t *testing.T) {
|
|||||||
initialLiquidatorCoins := cs(c("stable", 100))
|
initialLiquidatorCoins := cs(c("stable", 100))
|
||||||
tApp := app.NewTestApp()
|
tApp := app.NewTestApp()
|
||||||
|
|
||||||
liqAcc := supply.NewEmptyModuleAccount(liquidator.ModuleName, supply.Burner) // TODO could add test to check for burner permissions
|
liqAcc := supply.NewEmptyModuleAccount(liquidator.ModuleName, supply.Burner)
|
||||||
require.NoError(t, liqAcc.SetCoins(initialLiquidatorCoins))
|
require.NoError(t, liqAcc.SetCoins(initialLiquidatorCoins))
|
||||||
tApp.InitializeFromGenesisStates(
|
tApp.InitializeFromGenesisStates(
|
||||||
NewAuthGenStateFromAccs(authexported.GenesisAccounts{liqAcc}),
|
NewAuthGenStateFromAccs(authexported.GenesisAccounts{liqAcc}),
|
||||||
|
@ -18,7 +18,6 @@ type Keeper struct {
|
|||||||
storeKey sdk.StoreKey
|
storeKey sdk.StoreKey
|
||||||
cdc *codec.Codec
|
cdc *codec.Codec
|
||||||
paramSubspace subspace.Subspace
|
paramSubspace subspace.Subspace
|
||||||
// TODO codespace
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewKeeper returns a new auction keeper.
|
// NewKeeper returns a new auction keeper.
|
||||||
@ -43,12 +42,10 @@ func (k Keeper) SetNextAuctionID(ctx sdk.Context, id uint64) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetNextAuctionID reads the next available global ID from store
|
// GetNextAuctionID reads the next available global ID from store
|
||||||
// TODO might be nicer to convert not found error to a panic, it's not an error that can be recovered from
|
|
||||||
func (k Keeper) GetNextAuctionID(ctx sdk.Context) (uint64, sdk.Error) {
|
func (k Keeper) GetNextAuctionID(ctx sdk.Context) (uint64, sdk.Error) {
|
||||||
store := ctx.KVStore(k.storeKey)
|
store := ctx.KVStore(k.storeKey)
|
||||||
bz := store.Get(types.NextAuctionIDKey)
|
bz := store.Get(types.NextAuctionIDKey)
|
||||||
if bz == nil {
|
if bz == nil {
|
||||||
//return 0, types.ErrInvalidGenesis(k.codespace, "initial auction ID hasn't been set") // TODO create error
|
|
||||||
return 0, sdk.ErrInternal("initial auction ID hasn't been set")
|
return 0, sdk.ErrInternal("initial auction ID hasn't been set")
|
||||||
}
|
}
|
||||||
return types.Uint64FromBytes(bz), nil
|
return types.Uint64FromBytes(bz), nil
|
||||||
@ -135,7 +132,6 @@ func (k Keeper) removeFromByTimeIndex(ctx sdk.Context, endTime time.Time, auctio
|
|||||||
|
|
||||||
// IterateAuctionByTime provides an iterator over auctions ordered by auction.EndTime.
|
// IterateAuctionByTime provides an iterator over auctions ordered by auction.EndTime.
|
||||||
// For each auction cb will be callled. If cb returns true the iterator will close and stop.
|
// For each auction cb will be callled. If cb returns true the iterator will close and stop.
|
||||||
// TODO can the cutoff time be removed in favour of caller specifying cutoffs in the callback?
|
|
||||||
func (k Keeper) IterateAuctionsByTime(ctx sdk.Context, inclusiveCutoffTime time.Time, cb func(auctionID uint64) (stop bool)) {
|
func (k Keeper) IterateAuctionsByTime(ctx sdk.Context, inclusiveCutoffTime time.Time, cb func(auctionID uint64) (stop bool)) {
|
||||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AuctionByTimeKeyPrefix)
|
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AuctionByTimeKeyPrefix)
|
||||||
iterator := store.Iterator(
|
iterator := store.Iterator(
|
||||||
|
@ -18,7 +18,6 @@ func TestSplitIntIntoWeightedBuckets(t *testing.T) {
|
|||||||
{"100split1,9", i(100), is(1, 9), is(10, 90)},
|
{"100split1,9", i(100), is(1, 9), is(10, 90)},
|
||||||
{"7split1,2", i(7), is(1, 2), is(2, 5)},
|
{"7split1,2", i(7), is(1, 2), is(2, 5)},
|
||||||
{"17split1,1,1", i(17), is(1, 1, 1), is(6, 6, 5)},
|
{"17split1,1,1", i(17), is(1, 1, 1), is(6, 6, 5)},
|
||||||
// TODO more tests
|
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user