generated from dymensionxyz/rollapp
-
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.
Merge pull request #4 from AllInBetsCom/cron-fix
module fixes + testcases post review
- Loading branch information
Showing
39 changed files
with
575 additions
and
419 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
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,117 @@ | ||
package app | ||
|
||
import ( | ||
"encoding/json" | ||
"testing" | ||
"time" | ||
|
||
"github.com/CosmWasm/wasmd/x/wasm" | ||
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" | ||
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" | ||
"github.com/cosmos/cosmos-sdk/simapp" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
sequencerstypes "github.com/dymensionxyz/dymension-rdk/x/sequencers/types" | ||
cronTypes "github.com/dymensionxyz/rollapp-wasm/x/cron/types" | ||
"github.com/stretchr/testify/require" | ||
abci "github.com/tendermint/tendermint/abci/types" | ||
"github.com/tendermint/tendermint/libs/log" | ||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types" | ||
tmtypes "github.com/tendermint/tendermint/types" | ||
dbm "github.com/tendermint/tm-db" | ||
) | ||
|
||
// DefaultConsensusParams defines the default Tendermint consensus params used in | ||
// App testing. | ||
var DefaultConsensusParams = &abci.ConsensusParams{ | ||
Block: &abci.BlockParams{ | ||
MaxBytes: 200000, | ||
MaxGas: -1, | ||
}, | ||
Evidence: &tmproto.EvidenceParams{ | ||
MaxAgeNumBlocks: 302400, | ||
MaxAgeDuration: 504 * time.Hour, // 3 weeks is the max duration | ||
MaxBytes: 10000, | ||
}, | ||
Validator: &tmproto.ValidatorParams{ | ||
PubKeyTypes: []string{ | ||
tmtypes.ABCIPubKeyTypeEd25519, | ||
}, | ||
}, | ||
} | ||
|
||
var ( | ||
ProposerPK = simapp.CreateTestPubKeys(1)[0] | ||
ProposerConsAddr = sdk.ConsAddress(ProposerPK.Address()) | ||
|
||
OperatorPK = secp256k1.GenPrivKey().PubKey() | ||
) | ||
|
||
var TestChainID = "rollappwasm_1234-1" | ||
|
||
func setup(withGenesis bool, invCheckPeriod uint) (*App, map[string]json.RawMessage) { | ||
db := dbm.NewMemDB() | ||
|
||
encCdc := MakeEncodingConfig() | ||
var emptyWasmOpts []wasm.Option | ||
testApp := NewRollapp( | ||
log.NewNopLogger(), db, nil, true, map[int64]bool{}, "/tmp", invCheckPeriod, encCdc, GetEnabledProposals(), EmptyAppOptions{}, emptyWasmOpts, | ||
) | ||
if withGenesis { | ||
return testApp, NewDefaultGenesisState(encCdc.Codec) | ||
} | ||
return testApp, map[string]json.RawMessage{} | ||
} | ||
|
||
// Setup initializes a new Rollapp. A Nop logger is set in Rollapp. | ||
func Setup(t *testing.T, isCheckTx bool) *App { | ||
t.Helper() | ||
|
||
pk, err := cryptocodec.ToTmProtoPublicKey(ProposerPK) | ||
require.NoError(t, err) | ||
|
||
app, genesisState := setup(true, 5) | ||
|
||
// setup for sequencer | ||
seqGenesis := sequencerstypes.GenesisState{ | ||
Params: sequencerstypes.DefaultParams(), | ||
GenesisOperatorAddress: sdk.ValAddress(OperatorPK.Address()).String(), | ||
} | ||
genesisState[sequencerstypes.ModuleName] = app.AppCodec().MustMarshalJSON(&seqGenesis) | ||
|
||
// setup for cron | ||
DefaultSecurityAddress := []string{"cosmos1xkxed7rdzvmyvgdshpe445ddqwn47fru24fnlp"} | ||
params := cronTypes.Params{SecurityAddress: DefaultSecurityAddress} | ||
cronGenesis := cronTypes.GenesisState{ | ||
Params: params, | ||
WhitelistedContracts: []cronTypes.WhitelistedContract{}, | ||
} | ||
genesisState[cronTypes.ModuleName] = app.AppCodec().MustMarshalJSON(&cronGenesis) | ||
|
||
// for now bank genesis won't be set here, funding accounts should be called with fund utils.FundModuleAccount | ||
|
||
stateBytes, err := json.MarshalIndent(genesisState, "", " ") | ||
require.NoError(t, err) | ||
// init chain will set the validator set and initialize the genesis accounts | ||
app.InitChain( | ||
abci.RequestInitChain{ | ||
Time: time.Time{}, | ||
ChainId: TestChainID, | ||
ConsensusParams: DefaultConsensusParams, | ||
Validators: []abci.ValidatorUpdate{ | ||
{PubKey: pk, Power: 1}, | ||
}, | ||
AppStateBytes: stateBytes, | ||
InitialHeight: 0, | ||
}, | ||
) | ||
|
||
return app | ||
} | ||
|
||
// EmptyAppOptions is a stub implementing AppOptions | ||
type EmptyAppOptions struct{} | ||
|
||
// Get implements AppOptions | ||
func (ao EmptyAppOptions) Get(o string) interface{} { | ||
return nil | ||
} |
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
2 changes: 1 addition & 1 deletion
2
proto/aib/cron/v1beta1/cron.proto → proto/wasmrollapp/cron/v1beta1/cron.proto
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
syntax = "proto3"; | ||
package aib.cron.v1beta1; | ||
package wasmrollapp.cron.v1beta1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
|
||
|
6 changes: 3 additions & 3 deletions
6
proto/aib/cron/v1beta1/genesis.proto → proto/wasmrollapp/cron/v1beta1/genesis.proto
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
10 changes: 5 additions & 5 deletions
10
proto/aib/cron/v1beta1/query.proto → proto/wasmrollapp/cron/v1beta1/query.proto
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
4 changes: 2 additions & 2 deletions
4
proto/aib/cron/v1beta1/tx.proto → proto/wasmrollapp/cron/v1beta1/tx.proto
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
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,25 @@ | ||
package cron_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/dymensionxyz/rollapp-wasm/app" | ||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types" | ||
|
||
"github.com/dymensionxyz/rollapp-wasm/x/cron" | ||
"github.com/dymensionxyz/rollapp-wasm/x/cron/types" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestGenesis(t *testing.T) { | ||
appd := app.Setup(t, false) | ||
ctx := appd.BaseApp.NewContext(false, tmproto.Header{}) | ||
|
||
genesisState := types.GenesisState{ | ||
Params: types.DefaultParams(), | ||
} | ||
|
||
cron.InitGenesis(ctx, appd.CronKeeper, genesisState) | ||
got := cron.ExportGenesis(ctx, appd.CronKeeper) | ||
require.NotNil(t, got) | ||
} |
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 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
Oops, something went wrong.