Skip to content

Commit bb0167d

Browse files
committed
#303 Upgrade Cosmos-SDK to v0.47.3
- Modify BroadcastTx method - Enable external access of REST and gRPC endpoints Signed-off-by: Abdulbois <abdulbois.tursunov@dsr-corporation.com> Signed-off-by: Abdulbois <abdulbois123@gmail.com>
1 parent 2552f31 commit bb0167d

File tree

4 files changed

+34
-12
lines changed

4 files changed

+34
-12
lines changed

cmd/dcld/cmd/root.go

-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ func initRootCmd(
184184
txCommand(),
185185
keys.Commands(app.DefaultNodeHome),
186186
)
187-
188187
}
189188

190189
// queryCommand returns the sub-command to send queries to the app.

genlocalnetconfig.sh

+4
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ for node_name in node0 node1 node2 node3 observer0; do
173173
if [[ -d "$LOCALNET_DIR/${node_name}" ]]; then
174174
# Make RPC endpoints available externally
175175
sed -i $SED_EXT 's/laddr = "tcp:\/\/127.0.0.1:26657"/laddr = "tcp:\/\/0.0.0.0:26657"/g' "$LOCALNET_DIR/${node_name}/config/config.toml"
176+
# Make REST endpoints available externally
177+
sed -i $SED_EXT 's/address = "tcp:\/\/localhost:1317"/address = "tcp:\/\/0.0.0.0:1317"/g' "$LOCALNET_DIR/${node_name}/config/app.toml"
178+
# Make gRPC endpoints available externally
179+
sed -i $SED_EXT 's/address = "localhost:9090"/address = "0.0.0.0:9090"/g' "$LOCALNET_DIR/${node_name}/config/app.toml"
176180

177181
# sets proper moniker
178182
sed -i $SED_EXT "s/moniker = .*/moniker = \"$node_name\"/g" "$LOCALNET_DIR/${node_name}/config/config.toml"

integration_tests/run-all.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ init_pool() {
7676
make localnet_start &>${DETAILED_OUTPUT_TARGET}
7777

7878
log "-> Waiting for the second block (needed to request proofs)" >${DETAILED_OUTPUT_TARGET}
79-
sleep 10
79+
sleep 20
8080
wait_for_height 2 20
8181
}
8282

integration_tests/utils/grpc_rest.go

+29-10
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,19 @@ import (
2121
"fmt"
2222
"os"
2323
"path/filepath"
24+
"strings"
2425
"testing"
26+
"time"
2527

2628
//nolint:staticcheck
27-
"github.com/golang/protobuf/proto"
29+
"github.com/cosmos/gogoproto/proto"
2830
"github.com/stretchr/testify/require"
2931
"google.golang.org/grpc"
3032
"google.golang.org/grpc/credentials/insecure"
3133

3234
sdkerrors "cosmossdk.io/errors"
3335
clienttx "github.com/cosmos/cosmos-sdk/client/tx"
36+
"github.com/cosmos/cosmos-sdk/codec"
3437
"github.com/cosmos/cosmos-sdk/crypto/keyring"
3538
sdk "github.com/cosmos/cosmos-sdk/types"
3639
"github.com/cosmos/cosmos-sdk/types/tx"
@@ -59,6 +62,7 @@ func (suite *TestSuite) GetGRPCConn() *grpc.ClientConn {
5962
grpcConn, err := grpc.Dial(
6063
"127.0.0.1:26630", // Or your gRPC server address.
6164
grpc.WithTransportCredentials(insecure.NewCredentials()), // The SDK doesn't support any transport security mechanism.
65+
grpc.WithDefaultCallOptions(grpc.ForceCodec(codec.NewProtoCodec(suite.EncodingConfig.InterfaceRegistry).GRPCCodec())),
6266
)
6367
require.NoError(suite.T, err)
6468

@@ -144,21 +148,30 @@ func (suite *TestSuite) BroadcastTx(txBytes []byte) (*sdk.TxResponse, error) {
144148
TxBytes: txBytes,
145149
}
146150

147-
if suite.Rest {
148-
var _resp tx.GetTxResponse
151+
if suite.Rest { //nolint:nestif
152+
var _getResp tx.GetTxResponse
153+
var _brdResp tx.BroadcastTxResponse
149154

150155
bodyBytes, err := suite.EncodingConfig.Codec.MarshalJSON(&body)
151156
require.NoError(suite.T, err)
152157

153-
_, err = SendPostRequest("/cosmos/tx/v1beta1/txs", bodyBytes, "", "")
158+
respBytes, err := SendPostRequest("/cosmos/tx/v1beta1/txs", bodyBytes, "", "")
159+
require.NoError(suite.T, err)
160+
require.NoError(suite.T, suite.EncodingConfig.Codec.UnmarshalJSON(respBytes, &_brdResp))
161+
162+
for i := 1; i <= 10; i++ {
163+
respBytes, err = SendGetRequest(fmt.Sprintf("/cosmos/tx/v1beta1/txs/%s", _brdResp.GetTxResponse().TxHash))
164+
if err == nil {
165+
require.NoError(suite.T, suite.EncodingConfig.Codec.UnmarshalJSON(respBytes, &_getResp))
166+
167+
break
168+
}
169+
time.Sleep(2 * time.Second)
170+
}
154171
if err != nil {
155172
return nil, err
156173
}
157-
158-
respBytes, err := SendGetRequest(fmt.Sprintf("/cosmos/tx/v1beta1/txs/%s", _resp.GetTxResponse().TxHash))
159-
require.NoError(suite.T, err)
160-
require.NoError(suite.T, suite.EncodingConfig.Codec.UnmarshalJSON(respBytes, &_resp))
161-
txResponse = &_resp
174+
txResponse = &_getResp
162175
} else {
163176
grpcConn := suite.GetGRPCConn()
164177
defer grpcConn.Close()
@@ -171,7 +184,13 @@ func (suite *TestSuite) BroadcastTx(txBytes []byte) (*sdk.TxResponse, error) {
171184
return nil, err
172185
}
173186

174-
txResponse, err = txClient.GetTx(context.Background(), &tx.GetTxRequest{Hash: broadCastResponse.GetTxResponse().TxHash})
187+
for i := 1; i <= 10; i++ {
188+
txResponse, err = txClient.GetTx(context.Background(), &tx.GetTxRequest{Hash: broadCastResponse.GetTxResponse().TxHash})
189+
if err == nil && !strings.Contains(txResponse.TxResponse.RawLog, "tx not found") {
190+
break
191+
}
192+
time.Sleep(2 * time.Second)
193+
}
175194
if err != nil {
176195
return nil, err
177196
}

0 commit comments

Comments
 (0)