diff --git a/tests/e2e/main_test.go b/tests/e2e/main_test.go index 78d7da1c..5010bdf0 100644 --- a/tests/e2e/main_test.go +++ b/tests/e2e/main_test.go @@ -9,6 +9,7 @@ import ( "github.com/babylonchain/babylon-sdk/demo/app" appparams "github.com/babylonchain/babylon-sdk/demo/app/params" "github.com/babylonchain/babylon-sdk/tests/e2e/types" + bbntypes "github.com/babylonchain/babylon-sdk/x/babylon/types" zctypes "github.com/babylonchain/babylon/x/zoneconcierge/types" sdk "github.com/cosmos/cosmos-sdk/types" ibctesting2 "github.com/cosmos/ibc-go/v8/testing" @@ -94,13 +95,16 @@ func (s *BabylonSDKTestSuite) Test1ContractDeployment() { s.NoError(err) s.Equal(adminResp["admin"], s.ConsumerCli.GetSender().String()) - // update the contract address in parameters (typically this has to be done via gov props) - ctx := s.ConsumerChain.GetContext() - params := s.ConsumerApp.BabylonKeeper.GetParams(ctx) - params.BabylonContractAddress = s.ConsumerContract.Babylon.String() - params.BtcStakingContractAddress = s.ConsumerContract.BTCStaking.String() - err = s.ConsumerApp.BabylonKeeper.SetParams(ctx, params) - s.NoError(err) + // update the contract address in parameters + msgUpdateParams := &bbntypes.MsgUpdateParams{ + Authority: s.ConsumerApp.BabylonKeeper.GetAuthority(), + Params: bbntypes.Params{ + MaxGasBeginBlocker: 500_000, + BabylonContractAddress: s.ConsumerContract.Babylon.String(), + BtcStakingContractAddress: s.ConsumerContract.BTCStaking.String(), + }, + } + s.ConsumerCli.MustExecGovProposal(msgUpdateParams) } // TestExample is an example test case diff --git a/tests/e2e/test_client.go b/tests/e2e/test_client.go index dd2d5677..9ff7180e 100644 --- a/tests/e2e/test_client.go +++ b/tests/e2e/test_client.go @@ -7,11 +7,12 @@ import ( "github.com/CosmWasm/wasmd/x/wasm/ibctesting" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + "github.com/babylonchain/babylon-sdk/demo/app" + bbntypes "github.com/babylonchain/babylon-sdk/x/babylon/types" abci "github.com/cometbft/cometbft/abci/types" - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/babylonchain/babylon-sdk/demo/app" + govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + "github.com/stretchr/testify/require" ) // Query is a query type used in tests only @@ -156,3 +157,52 @@ func (p *TestConsumerClient) Exec(contract sdk.AccAddress, payload []byte, funds func (p *TestConsumerClient) Query(contractAddr sdk.AccAddress, query Query) (QueryResponse, error) { return Querier(p.t, p.Chain)(contractAddr.String(), query) } + +// MustExecGovProposal submit and vote yes on proposal +func (p *TestConsumerClient) MustExecGovProposal(msg *bbntypes.MsgUpdateParams) { + proposalID := submitGovProposal(p.t, p.Chain, msg) + voteAndPassGovProposal(p.t, p.Chain, proposalID) +} + +func submitGovProposal(t *testing.T, chain *ibctesting.TestChain, msgs ...sdk.Msg) uint64 { + // get gov module parameters + chainApp := chain.App.(*app.ConsumerApp) + govParams, err := chainApp.GovKeeper.Params.Get(chain.GetContext()) + require.NoError(t, err) + + // construct proposal + govMsg, err := govv1.NewMsgSubmitProposal(msgs, govParams.MinDeposit, chain.SenderAccount.GetAddress().String(), "", "my title", "my summary", false) + require.NoError(t, err) + + // submit proposal + _, err = chain.SendMsgs(govMsg) + require.NoError(t, err) + + // get next proposal ID + proposalID, err := chainApp.GovKeeper.ProposalID.Peek(chain.GetContext()) + require.NoError(t, err) + + return proposalID - 1 +} + +func voteAndPassGovProposal(t *testing.T, chain *ibctesting.TestChain, proposalID uint64) { + // get gov module parameters + chainApp := chain.App.(*app.ConsumerApp) + govParams, err := chainApp.GovKeeper.Params.Get(chain.GetContext()) + require.NoError(t, err) + + // construct and submit vote + vote := govv1.NewMsgVote(chain.SenderAccount.GetAddress(), proposalID, govv1.OptionYes, "testing") + _, err = chain.SendMsgs(vote) + require.NoError(t, err) + + // pass voting period + coord := chain.Coordinator + coord.IncrementTimeBy(*govParams.VotingPeriod) + coord.CommitBlock(chain) + + // ensure proposal is passed + proposal, err := chainApp.GovKeeper.Proposals.Get(chain.GetContext(), proposalID) + require.NoError(t, err) + require.Equal(t, proposal.Status, govv1.ProposalStatus_PROPOSAL_STATUS_PASSED) +} diff --git a/x/babylon/messages.md b/x/babylon/messages.md deleted file mode 100644 index 2075d4f7..00000000 --- a/x/babylon/messages.md +++ /dev/null @@ -1,138 +0,0 @@ -# Active to tombstone -```json -{ - "valset_update": { - "additions": [], - "removals": [ - "cosmosvaloper1qpr9kv5wyatfuefj3f9xklm87es8yayd2qls7d" - ], - "updated": [ - { - "address": "cosmosvaloper1qpr9kv5wyatfuefj3f9xklm87es8yayd2qls7d", - "commission": "1.000000000000000000", - "max_commission": "1.000000000000000000", - "max_change_rate": "1.000000000000000000" - } - ], - "jailed": [ - "cosmosvaloper1qpr9kv5wyatfuefj3f9xklm87es8yayd2qls7d" - ], - "unjailed": [], - "tombstoned": [ - "cosmosvaloper1qpr9kv5wyatfuefj3f9xklm87es8yayd2qls7d" - ] - } -} -``` - -# Active to jailed -```json -{ - "valset_update": { - "additions": [], - "removals": [ - "cosmosvaloper1cdwwskxm5qjsgetkxlv95p5jshz05gn320z30t" - ], - "updated": [ - { - "address": "cosmosvaloper1cdwwskxm5qjsgetkxlv95p5jshz05gn320z30t", - "commission": "0.000000000000000000", - "max_commission": "1.000000000000000000", - "max_change_rate": "1.000000000000000000" - } - ], - "jailed": [ - "cosmosvaloper1cdwwskxm5qjsgetkxlv95p5jshz05gn320z30t" - ], - "unjailed": [], - "tombstoned": [] - } -} - -``` -# Jailed to active -```json -{ - "valset_update": { - "additions": [ - { - "address": "cosmosvaloper13kdr4felug9grnswvlrtegxrlvh8ks724sfugn", - "commission": "0.000000000000000000", - "max_commission": "1.000000000000000000", - "max_change_rate": "1.000000000000000000" - } - ], - "removals": [], - "updated": [], - "jailed": [], - "unjailed": [ - "cosmosvaloper13kdr4felug9grnswvlrtegxrlvh8ks724sfugn" - ], - "tombstoned": [] - } -} -``` - -## Jailed to removed -3 differet events, unlikely at the same height -* jailed: -```json -{ - "valset_update": { - "additions": [], - "removals": [ - "cosmosvaloper18l39958dn3ntwdyz87ex3xa5l3mp02ym5r03xe" - ], - "updated": [ - { - "address": "cosmosvaloper18l39958dn3ntwdyz87ex3xa5l3mp02ym5r03xe", - "commission": "0.000000000000000000", - "max_commission": "1.000000000000000000", - "max_change_rate": "1.000000000000000000" - } - ], - "jailed": [ - "cosmosvaloper18l39958dn3ntwdyz87ex3xa5l3mp02ym5r03xe" - ], - "unjailed": [], - "tombstoned": [] - } -} -``` -* new validator gets slot -```json -{ - "valset_update": { - "additions": [ - { - "address": "cosmosvaloper17w36un4m6s848secp045zlwztreeh40z0s6ffu", - "commission": "0.000000000000000000", - "max_commission": "1.000000000000000000", - "max_change_rate": "1.000000000000000000" - } - ], - "removals": [], - "updated": [], - "jailed": [], - "unjailed": [], - "tombstoned": [] - } -} - -``` -* unjailed but not back in active set -```json -{ - "valset_update": { - "additions": [], - "removals": [], - "updated": [], - "jailed": [], - "unjailed": [ - "cosmosvaloper18l39958dn3ntwdyz87ex3xa5l3mp02ym5r03xe" - ], - "tombstoned": [] - } -} -``` -