forked from terra-money/classic-core
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_common.go
104 lines (84 loc) · 3.47 KB
/
test_common.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package oracle
// import (
// "terra/types/assets"
// "terra/x/pay"
// "terra/x/treasury"
// //"terra/x/treasury"
// "testing"
// "time"
// sdk "github.com/cosmos/cosmos-sdk/types"
// "github.com/cosmos/cosmos-sdk/x/auth"
// "github.com/cosmos/cosmos-sdk/x/mock"
// "github.com/cosmos/cosmos-sdk/x/params"
// "github.com/cosmos/cosmos-sdk/x/staking"
// "github.com/stretchr/testify/require"
// "github.com/tendermint/tendermint/crypto"
// abci "github.com/tendermint/tendermint/abci/types"
// )
// // initialize the mock application for this module
// func getMockApp(t *testing.T, numGenAccs int) (*mock.App, Keeper, staking.Keeper, []sdk.AccAddress, []crypto.PubKey, []crypto.PrivKey) {
// mapp := mock.NewApp()
// staking.RegisterCodec(mapp.Cdc)
// keyGlobalParams := sdk.NewKVStoreKey("params")
// tkeyGlobalParams := sdk.NewTransientStoreKey("transient_params")
// keystaking := sdk.NewKVStoreKey("staking")
// tkeystaking := sdk.NewTransientStoreKey("transient_staking")
// keyTreasury := sdk.NewKVStoreKey("treasury")
// keyOracle := sdk.NewKVStoreKey("oracle")
// keyBank := sdk.NewKVStoreKey("bank")
// keyFeeCollection := sdk.NewKVStoreKey("fee")
// pk := params.NewKeeper(mapp.Cdc, keyGlobalParams, tkeyGlobalParams)
// fck := auth.NewFeeCollectionKeeper(mapp.Cdc, keyFeeCollection)
// ck := pay.NewKeeper(keyBank, mapp.Cdc, mapp.AccountKeeper, fck)
// sk := staking.NewKeeper(mapp.Cdc, keystaking, tkeystaking, ck, pk.Subspace(staking.DefaultParamspace), staking.DefaultCodespace)
// tk := treasury.NewKeeper(keyTreasury, mapp.Cdc, ck, pk.Subspace(treasury.DefaultParamspace))
// keeper := NewKeeper(keyOracle, mapp.Cdc, tk, sk.GetValidatorSet(), pk.Subspace(DefaultParamspace))
// mapp.Router().AddRoute("oracle", NewHandler(keeper))
// mapp.SetEndBlocker(getEndBlocker(keeper))
// mapp.SetInitChainer(getInitChainer(mapp, keeper, sk))
// require.NoError(t, mapp.CompleteSetup(keystaking, tkeystaking,
// keyTreasury,
// keyOracle, keyBank, keyFeeCollection,
// keyGlobalParams, tkeyGlobalParams))
// genAccs, addrs, pubKeys, privKeys := mock.CreateGenAccounts(numGenAccs, sdk.Coins{sdk.NewInt64Coin(assets.LunaDenom, 42)})
// mock.SetGenesis(mapp, genAccs)
// return mapp, keeper, sk, addrs, pubKeys, privKeys
// }
// // oracle and staking endblocker
// func getEndBlocker(keeper Keeper) sdk.EndBlocker {
// return func(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
// _, _, tags := EndBlocker(ctx, keeper)
// return abci.ResponseEndBlock{
// Tags: tags,
// }
// }
// }
// // oracle and staking initchainer
// func getInitChainer(mapp *mock.App, keeper Keeper, stakingKeeper staking.Keeper) sdk.InitChainer {
// return func(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain {
// mapp.InitChainer(ctx, req)
// stakingGenesis := staking.GenesisState{
// Pool: staking.InitialPool(),
// Params: staking.Params{
// UnbondingTime: 60 * 60 * 24 * 3 * time.Second,
// MaxValidators: 100,
// BondDenom: assets.LunaDenom,
// },
// }
// stakingGenesis.Pool.NotBondedTokens = sdk.NewInt(100000)
// validators, err := staking.InitGenesis(ctx, stakingKeeper, stakingGenesis)
// if err != nil {
// panic(err)
// }
// InitGenesis(ctx, keeper, GenesisState{
// Params: NewParams(
// sdk.NewInt(1), // one block
// sdk.NewDecWithPrec(66, 2), // 66%
// sdk.NewInt(10),
// ),
// })
// return abci.ResponseInitChain{
// Validators: validators,
// }
// }
// }