Skip to content

Commit

Permalink
Passing happy path
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrit committed Apr 30, 2024
1 parent 34319ab commit 224b19f
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fail:
@false

e2e_happy_path: e2e_clean_slate
integration_tests/integration_tests.test -test.failfast -test.v -test.run IntegrationTestSuite -testify.m TestHappyPath || make -s fail
E2E_SKIP_CLEANUP=true integration_tests/integration_tests.test -test.failfast -test.v -test.run IntegrationTestSuite -testify.m TestHappyPath || make -s fail

e2e_valset_update: e2e_clean_slate
integration_tests/integration_tests.test -test.failfast -test.v -test.run IntegrationTestSuite -testify.m TestValsetUpdate || make -s fail
Expand Down
69 changes: 50 additions & 19 deletions integration_tests/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,38 @@ import (
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/codec"
sdkTypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
sdkTx "github.com/cosmos/cosmos-sdk/x/auth/tx"
"github.com/cosmos/cosmos-sdk/x/auth"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
"github.com/cosmos/cosmos-sdk/x/bank"
"github.com/cosmos/cosmos-sdk/x/capability"
"github.com/cosmos/cosmos-sdk/x/consensus"
"github.com/cosmos/cosmos-sdk/x/crisis"
"github.com/cosmos/cosmos-sdk/x/distribution"
"github.com/cosmos/cosmos-sdk/x/evidence"
"github.com/cosmos/cosmos-sdk/x/genutil"
"github.com/cosmos/cosmos-sdk/x/gov"
govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
"github.com/cosmos/cosmos-sdk/x/mint"
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client"
"github.com/cosmos/cosmos-sdk/x/slashing"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/cosmos/cosmos-sdk/x/upgrade"
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
ibctransfer "github.com/cosmos/ibc-go/v7/modules/apps/transfer"
ibc "github.com/cosmos/ibc-go/v7/modules/core"
"github.com/peggyjv/gravity-bridge/module/v4/app"
"github.com/peggyjv/gravity-bridge/module/v4/app/params"
gravityclient "github.com/peggyjv/gravity-bridge/module/v4/x/gravity/client"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
)

Expand Down Expand Up @@ -190,25 +209,37 @@ func (c *chain) createOrchestrator(index int) *orchestrator {
}

func (c *chain) clientContext(nodeURI string, kb *keyring.Keyring, fromName string, fromAddr sdk.AccAddress) (*client.Context, error) {
amino := codec.NewLegacyAmino()
interfaceRegistry := sdkTypes.NewInterfaceRegistry()
interfaceRegistry.RegisterImplementations((*sdk.Msg)(nil),
encodingConfig := moduletestutil.MakeTestEncodingConfig(
auth.AppModuleBasic{},
genutil.AppModuleBasic{},
bank.AppModuleBasic{},
capability.AppModuleBasic{},
consensus.AppModuleBasic{},
staking.AppModuleBasic{},
mint.AppModuleBasic{},
distribution.AppModuleBasic{},
gov.NewAppModuleBasic(
[]govclient.ProposalHandler{
paramsclient.ProposalHandler,
upgradeclient.LegacyProposalHandler,
upgradeclient.LegacyCancelProposalHandler,
gravityclient.ProposalHandler,
},
),
//params.AppModuleBasic{},
crisis.AppModuleBasic{},
slashing.AppModuleBasic{},
ibc.AppModuleBasic{},
upgrade.AppModuleBasic{},
evidence.AppModuleBasic{},
ibctransfer.AppModuleBasic{},
vesting.AppModuleBasic{},
)
encodingConfig.InterfaceRegistry.RegisterImplementations((*sdk.Msg)(nil),
&stakingtypes.MsgCreateValidator{},
&gravitytypes.MsgDelegateKeys{},
)
interfaceRegistry.RegisterImplementations((*cryptotypes.PubKey)(nil), &secp256k1.PubKey{}, &ed25519.PubKey{})

protoCodec := codec.NewProtoCodec(interfaceRegistry)
txCfg := sdkTx.NewTxConfig(protoCodec, sdkTx.DefaultSignModes)

encodingConfig := params.EncodingConfig{
InterfaceRegistry: interfaceRegistry,
Marshaler: protoCodec,
TxConfig: txCfg,
Amino: amino,
}
//simapp.ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino)
//simapp.ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry)
encodingConfig.InterfaceRegistry.RegisterImplementations((*cryptotypes.PubKey)(nil), &secp256k1.PubKey{}, &ed25519.PubKey{})

rpcClient, err := rpchttp.New(nodeURI, "/websocket")
if err != nil {
Expand All @@ -217,7 +248,7 @@ func (c *chain) clientContext(nodeURI string, kb *keyring.Keyring, fromName stri

clientContext := client.Context{}.
WithChainID(c.id).
WithCodec(protoCodec).
WithCodec(encodingConfig.Codec).
WithInterfaceRegistry(encodingConfig.InterfaceRegistry).
WithTxConfig(encodingConfig.TxConfig).
WithLegacyAmino(encodingConfig.Amino).
Expand Down
35 changes: 22 additions & 13 deletions integration_tests/happy_path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,16 @@ func (s *IntegrationTestSuite) TestHappyPath() {
return true
}, 105*time.Second, 10*time.Second, "unable to fund community pool")

distrQueryClient := distrtypes.NewQueryClient(clientCtx)
poolRes, err := distrQueryClient.CommunityPool(context.Background(),
&distrtypes.QueryCommunityPoolRequest{},
)
s.Require().NoError(err, "error retrieving community pool")
s.Require().True(poolRes.Pool.AmountOf(testDenom).GT(sdk.NewDec(1000000000)))
s.Require().Eventuallyf(func() bool {
distrQueryClient := distrtypes.NewQueryClient(clientCtx)
poolRes, err := distrQueryClient.CommunityPool(context.Background(),
&distrtypes.QueryCommunityPoolRequest{},
)
s.Require().NoError(err, "error retrieving community pool")
s.Require().Greater(poolRes.Pool.AmountOf(testDenom).BigInt().Int64(), sdk.NewDec(1000000000).BigInt().Int64())

return true
}, 20*time.Second, 2*time.Second, "community pool balance not high enough")

s.T().Logf("deploying testgb as an ERC20")
gbQueryClient := types.NewQueryClient(clientCtx)
Expand Down Expand Up @@ -204,7 +208,7 @@ func (s *IntegrationTestSuite) TestHappyPath() {
clientCtx, err = s.chain.clientContext("tcp://localhost:26657", orch.keyring, "orch", orch.address())
s.Require().NoError(err)

sendAmount := int64(900000000)
sendAmount := int64(900)
proposal := types.CommunityPoolEthereumSpendProposal{
Title: "community pool spend ethereum",
Description: "community pool spend ethereum",
Expand All @@ -230,13 +234,18 @@ func (s *IntegrationTestSuite) TestHappyPath() {
s.Require().NoError(err)
s.Require().Zero(submitProposalResponse.Code, "raw log: %s", submitProposalResponse.RawLog)

s.T().Log("check proposal was submitted correctly")
govQueryClient := govtypesv1beta1.NewQueryClient(clientCtx)
proposalsQueryResponse, err := govQueryClient.Proposals(context.Background(), &govtypesv1beta1.QueryProposalsRequest{})
s.Require().NoError(err)
s.Require().NotEmpty(proposalsQueryResponse.Proposals)
s.Require().Equal(uint64(1), proposalsQueryResponse.Proposals[0].ProposalId, "not proposal id 1")
s.Require().Equal(govtypesv1beta1.StatusVotingPeriod, proposalsQueryResponse.Proposals[0].Status, "proposal not in voting period")

s.Require().Eventually(func() bool {
s.T().Log("check proposal was submitted correctly")
govQueryClient = govtypesv1beta1.NewQueryClient(clientCtx)
proposalsQueryResponse, err := govQueryClient.Proposals(context.Background(), &govtypesv1beta1.QueryProposalsRequest{})
s.Require().NoError(err)
s.Require().NotEmpty(proposalsQueryResponse.Proposals)
s.Require().Equal(uint64(1), proposalsQueryResponse.Proposals[0].ProposalId, "not proposal id 1")
s.Require().Equal(govtypesv1beta1.StatusVotingPeriod, proposalsQueryResponse.Proposals[0].Status, "proposal not in voting period")
return true
}, 20*time.Second, 2*time.Second, "proposal not submitted correctly")

s.T().Log("vote for community spend proposal")
for _, val := range s.chain.validators {
Expand Down
2 changes: 2 additions & 0 deletions module/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ func NewGravityApp(
authority,
)

app.govKeeper.SetLegacyRouter(govRouter)

app.setupUpgradeStoreLoaders()

var skipGenesisInvariants = cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants))
Expand Down

0 comments on commit 224b19f

Please sign in to comment.