-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
343 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule testnets
added at
4b8a2a
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package keeper_test | ||
|
||
import ( | ||
gamekeeper "github.com/cosmic-horizon/qwoyn/x/game/keeper" | ||
gametypes "github.com/cosmic-horizon/qwoyn/x/game/types" | ||
minttypes "github.com/cosmic-horizon/qwoyn/x/mint/types" | ||
"github.com/cosmic-horizon/qwoyn/x/stimulus/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/tendermint/tendermint/crypto/ed25519" | ||
) | ||
|
||
func (suite *KeeperTestSuite) TestBeginBlocker() { | ||
params := suite.app.GameKeeper.GetParamSet(suite.ctx) | ||
addr := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) | ||
params.Owner = addr.String() | ||
mintDenom := suite.app.MintKeeper.GetParams(suite.ctx).MintDenom | ||
|
||
for _, tc := range []struct { | ||
desc string | ||
liquidity sdk.Coins | ||
balance sdk.Coin | ||
expBalance sdk.Coins | ||
}{ | ||
{ | ||
desc: "no liquidity to swap", | ||
liquidity: sdk.Coins{}, | ||
balance: sdk.NewInt64Coin(mintDenom, 1000), | ||
expBalance: sdk.Coins{sdk.NewInt64Coin(mintDenom, 1000)}, | ||
}, | ||
{ | ||
desc: "no balance to swap", | ||
liquidity: sdk.Coins{sdk.NewInt64Coin(params.DepositDenom, 100000), sdk.NewInt64Coin(mintDenom, 100000)}, | ||
balance: sdk.NewInt64Coin(params.DepositDenom, 0), | ||
expBalance: sdk.Coins{}, | ||
}, | ||
{ | ||
desc: "successful swap", | ||
liquidity: sdk.Coins{sdk.NewInt64Coin(params.DepositDenom, 100000), sdk.NewInt64Coin(mintDenom, 100000)}, | ||
balance: sdk.NewInt64Coin(mintDenom, 1000), | ||
expBalance: sdk.Coins{sdk.NewInt64Coin(params.DepositDenom, 991)}, | ||
}, | ||
} { | ||
suite.Run(tc.desc, func() { | ||
suite.SetupTest() | ||
suite.app.GameKeeper.SetParamSet(suite.ctx, params) | ||
|
||
if !tc.liquidity.IsZero() { | ||
err := suite.app.BankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, tc.liquidity) | ||
suite.Require().NoError(err) | ||
err = suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, minttypes.ModuleName, addr, tc.liquidity) | ||
suite.Require().NoError(err) | ||
|
||
gameMsgServer := gamekeeper.NewMsgServerImpl(suite.app.GameKeeper) | ||
_, err = gameMsgServer.AddLiquidity(sdk.WrapSDKContext(suite.ctx), &gametypes.MsgAddLiquidity{ | ||
Sender: addr.String(), | ||
Amounts: tc.liquidity, | ||
}) | ||
} | ||
|
||
if tc.balance.IsPositive() { | ||
err := suite.app.BankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, sdk.Coins{tc.balance}) | ||
suite.Require().NoError(err) | ||
err = suite.app.BankKeeper.SendCoinsFromModuleToModule(suite.ctx, minttypes.ModuleName, types.OutpostFundingPoolName, sdk.Coins{tc.balance}) | ||
suite.Require().NoError(err) | ||
} | ||
|
||
suite.app.StimulusKeeper.BeginBlocker(suite.ctx) | ||
|
||
// check balance has increased | ||
moduleAddr := suite.app.AccountKeeper.GetModuleAddress(types.OutpostFundingPoolName) | ||
balance := suite.app.BankKeeper.GetAllBalances(suite.ctx, moduleAddr) | ||
suite.Require().Equal(balance.String(), tc.expBalance.String()) | ||
}) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package keeper_test | ||
|
||
import ( | ||
"testing" | ||
|
||
simapp "github.com/cosmic-horizon/qwoyn/app" | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/stretchr/testify/suite" | ||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types" | ||
) | ||
|
||
const ( | ||
isCheckTx = false | ||
) | ||
|
||
type KeeperTestSuite struct { | ||
suite.Suite | ||
|
||
legacyAmino *codec.LegacyAmino | ||
ctx sdk.Context | ||
app *simapp.App | ||
} | ||
|
||
func (suite *KeeperTestSuite) SetupTest() { | ||
app := simapp.Setup(isCheckTx) | ||
|
||
suite.legacyAmino = app.LegacyAmino() | ||
suite.ctx = app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) | ||
suite.app = app | ||
} | ||
|
||
func TestKeeperSuite(t *testing.T) { | ||
suite.Run(t, new(KeeperTestSuite)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.