From 11fd42685b6944488ffe8f474076fb7a00b4667c Mon Sep 17 00:00:00 2001 From: rhuairahrighairigh Date: Sat, 7 Dec 2019 01:25:45 +0000 Subject: [PATCH] minor tidying --- x/auction/abci_test.go | 5 +++-- x/auction/keeper/keeper_test.go | 15 +++++++++------ x/liquidator/keeper/integration_test.go | 1 + x/liquidator/keeper/keeper_test.go | 8 ++++---- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/x/auction/abci_test.go b/x/auction/abci_test.go index 73040006..38941aeb 100644 --- a/x/auction/abci_test.go +++ b/x/auction/abci_test.go @@ -17,8 +17,9 @@ func TestKeeper_EndBlocker(t *testing.T) { seller := addrs[0] tApp := app.NewTestApp() - authGenState := app.NewAuthGenState(addrs, []sdk.Coins{cs(c("token1", 100), c("token2", 100))}) - tApp.InitializeFromGenesisStates(authGenState) + tApp.InitializeFromGenesisStates( + app.NewAuthGenState(addrs, []sdk.Coins{cs(c("token1", 100), c("token2", 100))}), + ) ctx := tApp.NewContext(true, abci.Header{}) keeper := tApp.GetAuctionKeeper() diff --git a/x/auction/keeper/keeper_test.go b/x/auction/keeper/keeper_test.go index f6b8b613..873dcb81 100644 --- a/x/auction/keeper/keeper_test.go +++ b/x/auction/keeper/keeper_test.go @@ -19,8 +19,9 @@ func TestKeeper_ForwardAuction(t *testing.T) { buyer := addrs[1] tApp := app.NewTestApp() - authGenState := app.NewAuthGenState(addrs, []sdk.Coins{cs(c("token1", 100), c("token2", 100)), cs(c("token1", 100), c("token2", 100))}) - tApp.InitializeFromGenesisStates(authGenState) + tApp.InitializeFromGenesisStates( + app.NewAuthGenState(addrs, []sdk.Coins{cs(c("token1", 100), c("token2", 100)), cs(c("token1", 100), c("token2", 100))}), + ) ctx := tApp.NewContext(false, abci.Header{}) keeper := tApp.GetAuctionKeeper() @@ -52,8 +53,9 @@ func TestKeeper_ReverseAuction(t *testing.T) { buyer := addrs[1] tApp := app.NewTestApp() - authGenState := app.NewAuthGenState(addrs, []sdk.Coins{cs(c("token1", 100), c("token2", 100)), cs(c("token1", 100), c("token2", 100))}) - tApp.InitializeFromGenesisStates(authGenState) + tApp.InitializeFromGenesisStates( + app.NewAuthGenState(addrs, []sdk.Coins{cs(c("token1", 100), c("token2", 100)), cs(c("token1", 100), c("token2", 100))}), + ) ctx := tApp.NewContext(false, abci.Header{}) keeper := tApp.GetAuctionKeeper() @@ -86,8 +88,9 @@ func TestKeeper_ForwardReverseAuction(t *testing.T) { recipient := addrs[2] tApp := app.NewTestApp() - authGenState := app.NewAuthGenState(addrs, []sdk.Coins{cs(c("token1", 100), c("token2", 100)), cs(c("token1", 100), c("token2", 100)), cs(c("token1", 100), c("token2", 100))}) - tApp.InitializeFromGenesisStates(authGenState) + tApp.InitializeFromGenesisStates( + app.NewAuthGenState(addrs, []sdk.Coins{cs(c("token1", 100), c("token2", 100)), cs(c("token1", 100), c("token2", 100)), cs(c("token1", 100), c("token2", 100))}), + ) ctx := tApp.NewContext(false, abci.Header{}) keeper := tApp.GetAuctionKeeper() diff --git a/x/liquidator/keeper/integration_test.go b/x/liquidator/keeper/integration_test.go index 53151269..01c825f8 100644 --- a/x/liquidator/keeper/integration_test.go +++ b/x/liquidator/keeper/integration_test.go @@ -14,6 +14,7 @@ import ( // Avoid cluttering test cases with long function name func i(in int64) sdk.Int { return sdk.NewInt(in) } +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...) } diff --git a/x/liquidator/keeper/keeper_test.go b/x/liquidator/keeper/keeper_test.go index 813ac6aa..3dae54fe 100644 --- a/x/liquidator/keeper/keeper_test.go +++ b/x/liquidator/keeper/keeper_test.go @@ -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", sdk.MustNewDecFromStr("8000.00")), + NewPFGenState("btc", d("8000.00")), NewCDPGenState(), NewLiquidatorGenState(), ) @@ -28,7 +28,7 @@ func TestKeeper_SeizeAndStartCollateralAuction(t *testing.T) { require.NoError(t, tApp.GetCDPKeeper().ModifyCDP(ctx, addrs[0], "btc", i(3), i(16000))) - _, err := tApp.GetPriceFeedKeeper().SetPrice(ctx, addrs[0], "btc", sdk.MustNewDecFromStr("7999.99"), time.Unix(9999999999, 0)) + _, err := tApp.GetPriceFeedKeeper().SetPrice(ctx, addrs[0], "btc", d("7999.99"), time.Unix(9999999999, 0)) require.NoError(t, err) require.NoError(t, tApp.GetPriceFeedKeeper().SetCurrentPrices(ctx, "btc")) @@ -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", sdk.MustNewDecFromStr("8000.00")), + NewPFGenState("btc", d("8000.00")), NewCDPGenState(), NewLiquidatorGenState(), ) @@ -89,7 +89,7 @@ func TestKeeper_partialSeizeCDP(t *testing.T) { tApp.GetCDPKeeper().ModifyCDP(ctx, addrs[0], "btc", i(3), i(16000)) - tApp.GetPriceFeedKeeper().SetPrice(ctx, addrs[0], "btc", sdk.MustNewDecFromStr("7999.99"), tmtime.Now().Add(time.Hour*1)) + tApp.GetPriceFeedKeeper().SetPrice(ctx, addrs[0], "btc", d("7999.99"), tmtime.Now().Add(time.Hour*1)) tApp.GetPriceFeedKeeper().SetCurrentPrices(ctx, "btc") // Run test function