Skip to content

Commit

Permalink
fixed more unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnguyen22 committed May 10, 2021
1 parent bfb1a16 commit a06fe74
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
12 changes: 11 additions & 1 deletion x/apps/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ func makeTestCodec() *codec.Codec {
return cdc
}

type MockPocketKeeper struct {

}

func (m MockPocketKeeper) ClearSessionCache() {
return
}

var _ types.PocketKeeper = MockPocketKeeper{}

func createTestInput(t *testing.T, isCheckTx bool) (sdk.Ctx, keeper.Keeper, types.AuthKeeper, types.PosKeeper) {
initPower := int64(100000000000)
nAccs := int64(4)
Expand Down Expand Up @@ -98,7 +108,7 @@ func createTestInput(t *testing.T, isCheckTx bool) (sdk.Ctx, keeper.Keeper, type

initialCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultStakeDenom, valTokens))
_ = createTestAccs(ctx, int(nAccs), initialCoins, &ak)
keeper := keeper.NewKeeper(cdc, appsKey, nk, ak, appSubspace, "apps")
keeper := keeper.NewKeeper(cdc, appsKey, nk, ak, MockPocketKeeper{}, appSubspace, "apps")
p := types.DefaultParams()
keeper.SetParams(ctx, p)
return ctx, keeper, ak, nk
Expand Down
9 changes: 9 additions & 0 deletions x/nodes/keeper/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ func makeTestCodec() *codec.Codec {
return cdc
}

type MockPocketKeeper struct{}

func (m MockPocketKeeper) ClearSessionCache() {
return
}

var _ types.PocketKeeper = MockPocketKeeper{}

// : deadcode unused
func createTestInput(t *testing.T, isCheckTx bool) (sdk.Context, []auth.Account, Keeper) {
initPower := int64(100000000000)
Expand Down Expand Up @@ -90,6 +98,7 @@ func createTestInput(t *testing.T, isCheckTx bool) (sdk.Context, []auth.Account,
initialCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultStakeDenom, valTokens))
accs := createTestAccs(ctx, int(nAccs), initialCoins, &ak)
keeper := NewKeeper(cdc, keyPOS, ak, posSubspace, "pos")
keeper.PocketKeeper = MockPocketKeeper{}
params := types.DefaultParams()
keeper.SetParams(ctx, params)
return ctx, accs, keeper
Expand Down
3 changes: 2 additions & 1 deletion x/pocketcore/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,10 @@ func createTestInput(t *testing.T, isCheckTx bool) (sdk.Ctx, nodesKeeper.Keeper,
pocketSubspace := sdk.NewSubspace(types.DefaultParamspace)
ak := auth.NewKeeper(cdc, keyAcc, accSubspace, maccPerms)
nk := nodesKeeper.NewKeeper(cdc, nodesKey, ak, nodesSubspace, "pos")
appk := appsKeeper.NewKeeper(cdc, appsKey, nk, ak, appSubspace, appsTypes.ModuleName)
appk := appsKeeper.NewKeeper(cdc, appsKey, nk, ak, nil, appSubspace, appsTypes.ModuleName)
keeper := keep.NewKeeper(pocketKey, cdc, ak, nk, appk, &hb, pocketSubspace)
kb := NewTestKeybase()
appk.PocketKeeper = keeper
_, err = kb.Create("test")
assert.Nil(t, err)
_, err = kb.GetCoinbase()
Expand Down
3 changes: 2 additions & 1 deletion x/pocketcore/keeper/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,10 @@ func createTestInput(t *testing.T, isCheckTx bool) (sdk.Ctx, []nodesTypes.Valida
pocketSubspace := sdk.NewSubspace(types.DefaultParamspace)
ak := auth.NewKeeper(cdc, keyAcc, authSubspace, maccPerms)
nk := nodesKeeper.NewKeeper(cdc, nodesKey, ak, nodesSubspace, nodesTypes.ModuleName)
appk := appsKeeper.NewKeeper(cdc, appsKey, nk, ak, appSubspace, appsTypes.ModuleName)
appk := appsKeeper.NewKeeper(cdc, appsKey, nk, ak, nil, appSubspace, appsTypes.ModuleName)
appk.SetApplication(ctx, getTestApplication())
keeper := NewKeeper(pocketKey, cdc, ak, nk, appk, &hb, pocketSubspace)
appk.PocketKeeper = keeper
assert.Nil(t, err)
moduleManager := module.NewManager(
auth.NewAppModule(ak),
Expand Down

0 comments on commit a06fe74

Please sign in to comment.