RegisterInterfaces registers service Msg type_urls (#7671)

* Add RegisterMsgServiceDesc

* Refactor newSendTxMsgServiceCmd

* Add test

* Register in all modules

* Remove RegisterMsgServiceDesc from baseapp

* Add explicit error message

* Add comment

* Update comment

* Add test

* Update comment

* Remove duplicate import

* Fix lint

* Forgot vesting

* Fix lint

* Fix test

* Put in types/module

* Put in types/msgservice

* Add comment about panic

* Update baseapp/msg_service_router.go

Co-authored-by: Robert Zaremba <robert@zaremba.ch>

* Update baseapp/msg_service_router.go

Co-authored-by: Robert Zaremba <robert@zaremba.ch>

* Update baseapp/msg_service_router.go

Co-authored-by: Robert Zaremba <robert@zaremba.ch>

* Add comment

* Add better test

* Update baseapp/msg_service_router.go

Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>

Co-authored-by: Robert Zaremba <robert@zaremba.ch>
Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
Amaury Martiny
2020-10-28 19:20:45 +00:00
committed by GitHub
co-authored by Robert Zaremba Marie Gauthier mergify[bot]
parent 1b0d6540d8
commit 82f15f306e
19 changed files with 259 additions and 117 deletions
+33 -6
View File
@@ -174,9 +174,11 @@ func (s *IntegrationTestSuite) TestCLIQueryTxCmd() {
account2, err := val.ClientCtx.Keyring.Key("newAccount2")
s.Require().NoError(err)
// Send coins.
sendTokens := sdk.NewInt64Coin(s.cfg.BondDenom, 10)
out, err := bankcli.MsgSendExec(
// Send coins, try both with legacy Msg and with Msg service.
// Legacy Msg.
legacyMsgOut, err := bankcli.MsgSendExec(
val.ClientCtx,
val.Address,
account2.GetAddress(),
@@ -187,31 +189,55 @@ func (s *IntegrationTestSuite) TestCLIQueryTxCmd() {
fmt.Sprintf("--gas=%d", flags.DefaultGasLimit),
)
s.Require().NoError(err)
var legacyMsgTxRes sdk.TxResponse
s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(legacyMsgOut.Bytes(), &legacyMsgTxRes))
// Service Msg.
out, err := bankcli.ServiceMsgSendExec(
val.ClientCtx,
val.Address,
account2.GetAddress(),
sdk.NewCoins(sendTokens),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
fmt.Sprintf("--gas=%d", flags.DefaultGasLimit),
)
s.Require().NoError(err)
var txRes sdk.TxResponse
s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &txRes))
s.Require().NoError(s.network.WaitForNextBlock())
testCases := []struct {
name string
args []string
expectErr bool
name string
args []string
expectErr bool
rawLogContains string
}{
{
"with invalid hash",
[]string{"somethinginvalid", fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
true,
"",
},
{
"with valid and not existing hash",
[]string{"C7E7D3A86A17AB3A321172239F3B61357937AF0F25D9FA4D2F4DCCAD9B0D7747", fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
true,
"",
},
{
"happy case",
"happy case (legacy Msg)",
[]string{legacyMsgTxRes.TxHash, fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
false,
"",
},
{
"happy case (service Msg)",
[]string{txRes.TxHash, fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
false,
"/cosmos.bank.v1beta1.Msg/Send",
},
}
@@ -230,6 +256,7 @@ func (s *IntegrationTestSuite) TestCLIQueryTxCmd() {
var result sdk.TxResponse
s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &result))
s.Require().NotNil(result.Height)
s.Require().Contains(result.RawLog, tc.rawLogContains)
}
})
}