Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(systemtest): Fix QueryBySig #23102

Merged
merged 2 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion server/v2/cometbft/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,12 +526,20 @@ func (c *consensus[T]) maybeHandleExternalServices(ctx context.Context, req *abc
if strings.HasPrefix(req.Path, "/cosmos.tx.v1beta1.Service") {
rpcClient, _ := client.NewClientFromNode(c.cfg.AppTomlConfig.Address)

txConfig := authtx.NewTxConfig(
c.appCodecs.AppCodec,
c.appCodecs.AppCodec.InterfaceRegistry().SigningContext().AddressCodec(),
c.appCodecs.AppCodec.InterfaceRegistry().SigningContext().ValidatorAddressCodec(),
authtx.DefaultSignModes,
)

// init simple client context
clientCtx := client.Context{}.
WithLegacyAmino(c.appCodecs.LegacyAmino.(*codec.LegacyAmino)).
WithCodec(c.appCodecs.AppCodec).
WithNodeURI(c.cfg.AppTomlConfig.Address).
WithClient(rpcClient)
WithClient(rpcClient).
WithTxConfig(txConfig)
Comment on lines +541 to +542
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Handle potential errors from RPC client creation.

You’re calling rpchttp.New(...) above without checking its error. This could lead to runtime issues if the RPC client fails to initialize. It’s recommended to validate and handle this error path rather than ignoring it.

- rpcClient, _ := rpchttp.New(c.cfg.AppTomlConfig.RPC.ListenAddress)
+ rpcClient, err := rpchttp.New(c.cfg.AppTomlConfig.RPC.ListenAddress)
+ if err != nil {
+     return nil, fmt.Errorf("failed to create RPC client: %w", err)
+ }

Committable suggestion skipped: line range outside the PR's diff.


txService := txServer[T]{
clientCtx: clientCtx,
Expand Down
2 changes: 1 addition & 1 deletion tests/systemtests/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ func TestTxDecodeAmino_GRPC(t *testing.T) {
}{
{"nil request", nil, true, "request cannot be nil"},
{"empty request", &tx.TxDecodeAminoRequest{}, true, "invalid empty tx bytes"},
{"invalid tx bytes", &tx.TxDecodeAminoRequest{AminoBinary: invalidTxBytes}, true, "invalid request"},
{"invalid tx bytes", &tx.TxDecodeAminoRequest{AminoBinary: invalidTxBytes}, true, "unmarshal to legacytx.StdTx failed"},
{"valid request with tx bytes", &tx.TxDecodeAminoRequest{AminoBinary: encodedTx}, false, ""},
}

Expand Down
Loading