mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-23 23:05:18 +00:00
tidy test genesis states
This commit is contained in:
parent
11fd42685b
commit
d8347fd49c
@ -17,15 +17,13 @@ func d(str string) sdk.Dec { return sdk.MustNewDecFromStr(str)
|
||||
func c(denom string, amount int64) sdk.Coin { return sdk.NewInt64Coin(denom, amount) }
|
||||
func cs(coins ...sdk.Coin) sdk.Coins { return sdk.NewCoins(coins...) }
|
||||
|
||||
func NewPFGenState(asset string, price sdk.Dec) app.GenesisState {
|
||||
quote := "usd"
|
||||
ap := pricefeed.Params{
|
||||
Markets: []pricefeed.Market{
|
||||
pricefeed.Market{MarketID: asset, BaseAsset: asset, QuoteAsset: quote, Oracles: pricefeed.Oracles{}, Active: true},
|
||||
},
|
||||
}
|
||||
func NewPricefeedGenState(asset string, price sdk.Dec) app.GenesisState {
|
||||
pfGenesis := pricefeed.GenesisState{
|
||||
Params: ap,
|
||||
Params: pricefeed.Params{
|
||||
Markets: []pricefeed.Market{
|
||||
pricefeed.Market{MarketID: asset, BaseAsset: asset, QuoteAsset: "usd", Oracles: pricefeed.Oracles{}, Active: true},
|
||||
},
|
||||
},
|
||||
PostedPrices: []pricefeed.PostedPrice{
|
||||
pricefeed.PostedPrice{
|
||||
MarketID: asset,
|
||||
@ -56,16 +54,14 @@ func NewCDPGenState(asset string, liquidationRatio sdk.Dec) app.GenesisState {
|
||||
return app.GenesisState{cdp.ModuleName: cdp.ModuleCdc.MustMarshalJSON(cdpGenesis)}
|
||||
}
|
||||
|
||||
func NewPFGenStateMulti() app.GenesisState {
|
||||
quote := "usd"
|
||||
ap := pricefeed.Params{
|
||||
Markets: []pricefeed.Market{
|
||||
pricefeed.Market{MarketID: "btc", BaseAsset: "btc", QuoteAsset: quote, Oracles: pricefeed.Oracles{}, Active: true},
|
||||
pricefeed.Market{MarketID: "xrp", BaseAsset: "xrp", QuoteAsset: quote, Oracles: pricefeed.Oracles{}, Active: true},
|
||||
},
|
||||
}
|
||||
func NewPricefeedGenStateMulti() app.GenesisState {
|
||||
pfGenesis := pricefeed.GenesisState{
|
||||
Params: ap,
|
||||
Params: pricefeed.Params{
|
||||
Markets: []pricefeed.Market{
|
||||
pricefeed.Market{MarketID: "btc", BaseAsset: "btc", QuoteAsset: "usd", Oracles: pricefeed.Oracles{}, Active: true},
|
||||
pricefeed.Market{MarketID: "xrp", BaseAsset: "xrp", QuoteAsset: "usd", Oracles: pricefeed.Oracles{}, Active: true},
|
||||
},
|
||||
},
|
||||
PostedPrices: []pricefeed.PostedPrice{
|
||||
pricefeed.PostedPrice{
|
||||
MarketID: "btc",
|
||||
|
@ -98,7 +98,7 @@ func TestKeeper_ModifyCDP(t *testing.T) {
|
||||
// initialize cdp owner account with coins, and collateral with price and params
|
||||
tApp.InitializeFromGenesisStates(
|
||||
app.NewAuthGenState([]sdk.AccAddress{ownerAddr}, []sdk.Coins{tc.priorState.OwnerCoins}),
|
||||
NewPFGenState("xrp", d(tc.price)),
|
||||
NewPricefeedGenState("xrp", d(tc.price)),
|
||||
NewCDPGenState("xrp", d("2.0")),
|
||||
)
|
||||
// create a context for db access
|
||||
@ -151,7 +151,7 @@ func TestKeeper_PartialSeizeCDP(t *testing.T) {
|
||||
tApp := app.NewTestApp()
|
||||
tApp.InitializeFromGenesisStates(
|
||||
app.NewAuthGenState(addrs, []sdk.Coins{cs(c(collateral, 100))}),
|
||||
NewPFGenState(collateral, d("1.00")),
|
||||
NewPricefeedGenState(collateral, d("1.00")),
|
||||
NewCDPGenState(collateral, d("2.00")),
|
||||
)
|
||||
|
||||
@ -182,7 +182,7 @@ func TestKeeper_PartialSeizeCDP(t *testing.T) {
|
||||
func TestKeeper_GetCDPs(t *testing.T) {
|
||||
// setup test app
|
||||
tApp := app.NewTestApp().InitializeFromGenesisStates(
|
||||
NewPFGenStateMulti(), // collateral needs to be in pricefeed for cdp InitGenesis to validate
|
||||
NewPricefeedGenStateMulti(), // collateral needs to be in pricefeed for cdp InitGenesis to validate
|
||||
NewCDPGenStateMulti(),
|
||||
)
|
||||
ctx := tApp.NewContext(true, abci.Header{})
|
||||
|
@ -18,16 +18,14 @@ func d(str string) sdk.Dec { return sdk.MustNewDecFromStr(str)
|
||||
func c(denom string, amount int64) sdk.Coin { return sdk.NewInt64Coin(denom, amount) }
|
||||
func cs(coins ...sdk.Coin) sdk.Coins { return sdk.NewCoins(coins...) }
|
||||
|
||||
// Default genesis states to initialize test apps
|
||||
// Genesis states to initialize test apps
|
||||
|
||||
func NewPFGenState(asset string, price sdk.Dec) app.GenesisState {
|
||||
quote := "usd"
|
||||
ap := pricefeed.Params{
|
||||
Markets: []pricefeed.Market{
|
||||
pricefeed.Market{MarketID: asset, BaseAsset: asset, QuoteAsset: quote, Oracles: pricefeed.Oracles{}, Active: true}},
|
||||
}
|
||||
func NewPricefeedGenState(asset string, price sdk.Dec) app.GenesisState {
|
||||
pfGenesis := pricefeed.GenesisState{
|
||||
Params: ap,
|
||||
Params: pricefeed.Params{
|
||||
Markets: []pricefeed.Market{
|
||||
pricefeed.Market{MarketID: asset, BaseAsset: asset, QuoteAsset: "usd", Oracles: pricefeed.Oracles{}, Active: true}},
|
||||
},
|
||||
PostedPrices: []pricefeed.PostedPrice{
|
||||
pricefeed.PostedPrice{
|
||||
MarketID: asset,
|
||||
|
@ -20,7 +20,7 @@ func TestKeeper_SeizeAndStartCollateralAuction(t *testing.T) {
|
||||
tApp := app.NewTestApp()
|
||||
tApp.InitializeFromGenesisStates(
|
||||
app.NewAuthGenState(addrs, []sdk.Coins{cs(c("btc", 100))}),
|
||||
NewPFGenState("btc", d("8000.00")),
|
||||
NewPricefeedGenState("btc", d("8000.00")),
|
||||
NewCDPGenState(),
|
||||
NewLiquidatorGenState(),
|
||||
)
|
||||
@ -81,7 +81,7 @@ func TestKeeper_partialSeizeCDP(t *testing.T) {
|
||||
tApp := app.NewTestApp()
|
||||
tApp.InitializeFromGenesisStates(
|
||||
app.NewAuthGenState(addrs, []sdk.Coins{cs(c("btc", 100))}),
|
||||
NewPFGenState("btc", d("8000.00")),
|
||||
NewPricefeedGenState("btc", d("8000.00")),
|
||||
NewCDPGenState(),
|
||||
NewLiquidatorGenState(),
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user