strangelove-ventures / interchaintest

e2e testing framework for the interchain
https://interchaintest-docs.vercel.app
Apache License 2.0
186 stars 118 forks source link

unable to resolve type URL error when running tests #1268

Open akankshadhyani05 opened 4 days ago

akankshadhyani05 commented 4 days ago

Hi, I am running an appchain using the latest sdk version (0.50.8) and I am trying to run test but I am getting error in my code which I have posted below: Error is originating from this code(here cctptypes is a dependency that i am importing in my repo):

msgs := []sdk.Msg{}

msgs = append(msgs, &cctptypes.MsgAddRemoteTokenMessenger{
    From:     gw.fiatTfRoles.Owner.FormattedAddress(),
    DomainId: 0,
    Address:  tokenMessenger,
})

The error is: "unable to resolve type URL /cctp.MsgAddRemoteTokenMessenger"

I have pasted the code snippet of its tx.pb.go file :

proto.RegisterType((MsgAddRemoteTokenMessenger)(nil), "cctp.MsgAddRemoteTokenMessenger") proto.RegisterType((MsgAddRemoteTokenMessengerResponse)(nil), "cctp.MsgAddRemoteTokenMessengerResponse") where could the issue be?

I have added these lines in my app.go file:

app.BasicModuleManager = module.NewBasicManagerFromManager( app.mm, map[string]module.AppModuleBasic{ genutiltypes.ModuleName: genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator), govtypes.ModuleName: gov.NewAppModuleBasic( []govclient.ProposalHandler{ paramsclient.ProposalHandler, }, ), CCTPModuleName: cctp.AppModuleBasic{} }, )

app.BasicModuleManager.RegisterLegacyAminoCodec(legacyAmino)
app.BasicModuleManager.RegisterInterfaces(interfaceRegistry)
misko9 commented 3 days ago

If this is an error in the interchaintest logs, you can try setting a custom encoding config in your chain config. I.e.:

import (
         cctptypes "github.com/yourorg/yourchain/cctptypes"
    "github.com/cosmos/cosmos-sdk/types/module/testutil"
    "github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
)

func EncodingConfigWithCctp() *testutil.TestEncodingConfig{
  cfg := cosmos.DefaultEncoding()
  cctptypes.RegisterInterface(cfg.InterfaceRegistry)
  return &cfg
}
...
cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{
    {
        ChainConfig: ibc.ChainConfig{
            Type:    "cosmos",
            Name:    "custom",
            ...
            EncodingConfig: EncodingConfigWithCctp(),
        },
    },
})
...