@@ -2,19 +2,22 @@ package rest_test
2
2
3
3
import (
4
4
"fmt"
5
- "testing"
6
-
7
5
"strings"
6
+ "testing"
8
7
9
8
"github.com/stretchr/testify/suite"
10
9
10
+ "github.com/cosmos/cosmos-sdk/client/flags"
11
11
"github.com/cosmos/cosmos-sdk/client/tx"
12
+ "github.com/cosmos/cosmos-sdk/crypto/hd"
13
+ "github.com/cosmos/cosmos-sdk/crypto/keyring"
12
14
"github.com/cosmos/cosmos-sdk/testutil/network"
13
15
"github.com/cosmos/cosmos-sdk/testutil/testdata"
14
16
sdk "github.com/cosmos/cosmos-sdk/types"
15
17
"github.com/cosmos/cosmos-sdk/types/rest"
16
18
"github.com/cosmos/cosmos-sdk/types/tx/signing"
17
19
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
20
+ bankcli "github.com/cosmos/cosmos-sdk/x/bank/client/testutil"
18
21
19
22
rest2 "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
20
23
"github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx"
@@ -37,7 +40,11 @@ func (s *IntegrationTestSuite) SetupSuite() {
37
40
s .cfg = cfg
38
41
s .network = network .New (s .T (), cfg )
39
42
40
- _ , err := s .network .WaitForHeight (1 )
43
+ kb := s .network .Validators [0 ].ClientCtx .Keyring
44
+ _ , _ , err := kb .NewMnemonic ("newAccount" , keyring .English , sdk .FullFundraiserPath , hd .Secp256k1 )
45
+ s .Require ().NoError (err )
46
+
47
+ _ , err = s .network .WaitForHeight (1 )
41
48
s .Require ().NoError (err )
42
49
}
43
50
@@ -128,6 +135,43 @@ func (s *IntegrationTestSuite) TestQueryTxByHash() {
128
135
s .Require ().True (strings .Contains (string (txJSON ), stdTx .Memo ))
129
136
}
130
137
138
+ func (s * IntegrationTestSuite ) TestQueryTxByHashWithServiceMessage () {
139
+ val := s .network .Validators [0 ]
140
+
141
+ account , err := val .ClientCtx .Keyring .Key ("newAccount" )
142
+ s .Require ().NoError (err )
143
+
144
+ sendTokens := sdk .NewInt64Coin (s .cfg .BondDenom , 10 )
145
+
146
+ out , err := bankcli .ServiceMsgSendExec (
147
+ val .ClientCtx ,
148
+ val .Address ,
149
+ account .GetAddress (),
150
+ sdk .NewCoins (sendTokens ),
151
+ fmt .Sprintf ("--%s=true" , flags .FlagSkipConfirmation ),
152
+ fmt .Sprintf ("--%s=%s" , flags .FlagBroadcastMode , flags .BroadcastBlock ),
153
+ fmt .Sprintf ("--%s=%s" , flags .FlagFees , sdk .NewCoins (sdk .NewCoin (s .cfg .BondDenom , sdk .NewInt (10 ))).String ()),
154
+ fmt .Sprintf ("--gas=%d" , flags .DefaultGasLimit ),
155
+ )
156
+
157
+ s .Require ().NoError (err )
158
+ var txRes sdk.TxResponse
159
+ s .Require ().NoError (val .ClientCtx .JSONMarshaler .UnmarshalJSON (out .Bytes (), & txRes ))
160
+
161
+ s .Require ().NoError (s .network .WaitForNextBlock ())
162
+
163
+ txJSON , err := rest .GetRequest (fmt .Sprintf ("%s/txs/%s" , val .APIAddress , txRes .TxHash ))
164
+ s .Require ().NoError (err )
165
+
166
+ var result legacytx.StdTx
167
+ s .Require ().NoError (val .ClientCtx .LegacyAmino .UnmarshalJSON (txJSON , & result ))
168
+ s .Require ().NotNil (result )
169
+ msgs := result .GetMsgs ()
170
+ s .Require ().Equal (len (msgs ), 1 )
171
+ _ , ok := msgs [0 ].(* types.MsgSend )
172
+ s .Require ().True (ok )
173
+ }
174
+
131
175
func (s * IntegrationTestSuite ) TestMultipleSyncBroadcastTxRequests () {
132
176
// First test transaction from validator should have sequence=1 (non-genesis tx)
133
177
testCases := []struct {
0 commit comments