mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-10 18:15:19 +00:00
d849d690e5
* wip: tpyes and keeper methods * wip: iterators * wip: types and keeper methods * wip: add msgs * wip: client methods * wip: rebase develop * wip: types tests * wip: keeper tests, small fixes * wip: add cdp tests * wip: deposit tests * wip: keeper tests * wip: tests and module methods * feat: error when fetching expired price * feat: conversion factor for external assets * feat: debt floor for new cdps * feat: save deposits on export genesis * feat: ensure messages implement msg * feat: index deposits by status * fix: stray comment * wip: address review comments * address review comments
62 lines
1.2 KiB
Go
62 lines
1.2 KiB
Go
package cdp_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/kava-labs/kava/app"
|
|
"github.com/kava-labs/kava/x/cdp"
|
|
|
|
"github.com/stretchr/testify/suite"
|
|
)
|
|
|
|
type GenesisTestSuite struct {
|
|
suite.Suite
|
|
|
|
ctx sdk.Context
|
|
keeper cdp.Keeper
|
|
}
|
|
|
|
func (suite *GenesisTestSuite) TestInvalidGenState() {
|
|
tApp := app.NewTestApp()
|
|
for _, gs := range badGenStates() {
|
|
|
|
appGS := app.GenesisState{"cdp": cdp.ModuleCdc.MustMarshalJSON(gs.Genesis)}
|
|
suite.Panics(func() {
|
|
tApp.InitializeFromGenesisStates(
|
|
NewPricefeedGenStateMulti(),
|
|
appGS,
|
|
)
|
|
}, gs.Reason)
|
|
}
|
|
}
|
|
|
|
func (suite *GenesisTestSuite) TestValidGenState() {
|
|
tApp := app.NewTestApp()
|
|
|
|
suite.NotPanics(func() {
|
|
tApp.InitializeFromGenesisStates(
|
|
NewPricefeedGenStateMulti(),
|
|
NewCDPGenStateMulti(),
|
|
)
|
|
})
|
|
|
|
cdpGS := NewCDPGenStateMulti()
|
|
gs := cdp.GenesisState{}
|
|
cdp.ModuleCdc.UnmarshalJSON(cdpGS["cdp"], &gs)
|
|
gs.CDPs = cdps()
|
|
gs.StartingCdpID = uint64(5)
|
|
appGS := app.GenesisState{"cdp": cdp.ModuleCdc.MustMarshalJSON(gs)}
|
|
suite.NotPanics(func() {
|
|
tApp.InitializeFromGenesisStates(
|
|
NewPricefeedGenStateMulti(),
|
|
appGS,
|
|
)
|
|
})
|
|
|
|
}
|
|
|
|
func TestGenesisTestSuite(t *testing.T) {
|
|
suite.Run(t, new(GenesisTestSuite))
|
|
}
|