-
Notifications
You must be signed in to change notification settings - Fork 3
/
test_app.go
109 lines (90 loc) · 3.04 KB
/
test_app.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
105
106
107
108
109
package testutil
// TODO: refactor test simapp
// import (
// "encoding/json"
// "testing"
// "time"
// abci "github.com/cometbft/cometbft/abci/types"
// tmtypes "github.com/cometbft/cometbft/proto/tendermint/types"
// cmttypes "github.com/cometbft/cometbft/types"
// "github.com/stretchr/testify/require"
// "cosmossdk.io/log"
// dbm "github.com/cosmos/cosmos-db"
// "github.com/cosmos/cosmos-sdk/baseapp"
// codectypes "github.com/cosmos/cosmos-sdk/codec/types"
// cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
// "github.com/cosmos/cosmos-sdk/testutil/testdata"
// "github.com/decentrio/rollkit-sdk/simapp"
// simappparams "github.com/decentrio/rollkit-sdk/simapp/params"
// seqtypes "github.com/decentrio/rollkit-sdk/x/sequencer/types"
// )
// const TestChainID = "testchain-1"
// var DefaultConsensusParams = &tmtypes.ConsensusParams{
// Block: &tmtypes.BlockParams{
// MaxBytes: 200000,
// MaxGas: -1,
// },
// Evidence: &tmtypes.EvidenceParams{
// MaxAgeNumBlocks: 302400,
// MaxAgeDuration: 504 * time.Hour, // 3 weeks is the max duration
// MaxBytes: 10000,
// },
// Validator: &tmtypes.ValidatorParams{
// PubKeyTypes: []string{
// cmttypes.ABCIPubKeyTypeEd25519,
// },
// },
// }
// // EmptyAppOptions is a stub implementing AppOptions
// type EmptyAppOptions struct{}
// // Get implements AppOptions
// func (ao EmptyAppOptions) Get(o string) interface{} {
// return nil
// }
// func setup(chainId string) (*simapp.SimApp, map[string]json.RawMessage) {
// db := dbm.NewMemDB()
// encCdc := simappparams.MakeTestEncodingConfig()
// testApp := simapp.NewSimApp(
// log.NewNopLogger(), db, nil, true, EmptyAppOptions{}, baseapp.SetChainID(chainId),
// )
// genState := testApp.DefaultGenesisState(encCdc.Codec)
// return testApp, genState
// }
// // Setup initializes a new Rollapp. A Nop logger is set in Rollapp.
// func SetupWithChainId(t *testing.T, chainId string) *simapp.SimApp {
// t.Helper()
// _, pubKey, _ := testdata.KeyTestPubAddr()
// pk, err := cryptocodec.ToCmtProtoPublicKey(pubKey)
// require.NoError(t, err)
// pkAny, err := codectypes.NewAnyWithValue(pubKey)
// require.NoError(t, err)
// app, genesisState := setup(chainId)
// // setup for sequencer
// seqGenesis := seqtypes.GenesisState{
// Params: seqtypes.Params{},
// Sequencers: []seqtypes.Sequencer{
// {
// Name: "sequencer",
// ConsensusPubkey: pkAny,
// },
// },
// }
// genesisState[seqtypes.ModuleName] = app.AppCodec().MustMarshalJSON(&seqGenesis)
// stateBytes, err := json.MarshalIndent(genesisState, "", " ")
// require.NoError(t, err)
// // init chain will set the validator set and initialize the genesis accounts
// _, err = app.InitChain(
// &abci.RequestInitChain{
// Time: time.Time{},
// ChainId: chainId,
// ConsensusParams: DefaultConsensusParams,
// Validators: []abci.ValidatorUpdate{
// {PubKey: pk, Power: 1},
// },
// AppStateBytes: stateBytes,
// InitialHeight: 0,
// },
// )
// require.NoError(t, err)
// return app
// }