@@ -118,14 +118,19 @@ type NodeStatus struct {
118118
119119// Status returns the node's status.
120120func (r Runner ) Status (ctx context.Context ) (NodeStatus , error ) {
121- b := & bytes. Buffer {}
121+ b := newBuffer ()
122122
123123 if err := r .run (ctx , runOptions {stdout : b , stderr : b }, r .chainCmd .StatusCommand ()); err != nil {
124124 return NodeStatus {}, err
125125 }
126126
127127 var chainID string
128128
129+ data , err := b .JSONEnsuredBytes ()
130+ if err != nil {
131+ return NodeStatus {}, err
132+ }
133+
129134 switch r .chainCmd .SDKVersion () {
130135 case cosmosver .StargateZeroFourtyAndAbove :
131136 out := struct {
@@ -134,7 +139,7 @@ func (r Runner) Status(ctx context.Context) (NodeStatus, error) {
134139 } `json:"NodeInfo"`
135140 }{}
136141
137- if err := json .NewDecoder ( b ). Decode ( & out ); err != nil {
142+ if err := json .Unmarshal ( data , & out ); err != nil {
138143 return NodeStatus {}, err
139144 }
140145
@@ -146,7 +151,7 @@ func (r Runner) Status(ctx context.Context) (NodeStatus, error) {
146151 } `json:"node_info"`
147152 }{}
148153
149- if err := json .NewDecoder ( b ). Decode ( & out ); err != nil {
154+ if err := json .Unmarshal ( data , & out ); err != nil {
150155 return NodeStatus {}, err
151156 }
152157
@@ -160,7 +165,7 @@ func (r Runner) Status(ctx context.Context) (NodeStatus, error) {
160165
161166// BankSend sends amount from fromAccount to toAccount.
162167func (r Runner ) BankSend (ctx context.Context , fromAccount , toAccount , amount string ) error {
163- b := & bytes. Buffer {}
168+ b := newBuffer ()
164169 opt := []step.Option {
165170 r .chainCmd .BankSendCommand (fromAccount , toAccount , amount ),
166171 }
@@ -188,7 +193,11 @@ func (r Runner) BankSend(ctx context.Context, fromAccount, toAccount, amount str
188193 Error string `json:"raw_log"`
189194 }{}
190195
191- if err := json .NewDecoder (b ).Decode (& out ); err != nil {
196+ data , err := b .JSONEnsuredBytes ()
197+ if err != nil {
198+ return err
199+ }
200+ if err := json .Unmarshal (data , & out ); err != nil {
192201 return err
193202 }
194203
@@ -235,7 +244,7 @@ type EventAttribute struct {
235244 Value string
236245}
237246
238- // r queries tx events by event selectors.
247+ // QueryTxEvents queries tx events by event selectors.
239248func (r Runner ) QueryTxEvents (
240249 ctx context.Context ,
241250 selector EventSelector ,
@@ -253,7 +262,7 @@ func (r Runner) QueryTxEvents(
253262 query := strings .Join (list , "&" )
254263
255264 // execute the commnd and parse the output.
256- b := & bytes. Buffer {}
265+ b := newBuffer ()
257266
258267 if err := r .run (ctx , runOptions {stdout : b }, r .chainCmd .QueryTxEventsCommand (query )); err != nil {
259268 return nil , err
@@ -274,7 +283,11 @@ func (r Runner) QueryTxEvents(
274283 } `json:"txs"`
275284 }{}
276285
277- if err := json .NewDecoder (b ).Decode (& out ); err != nil {
286+ data , err := b .JSONEnsuredBytes ()
287+ if err != nil {
288+ return nil , err
289+ }
290+ if err := json .Unmarshal (data , & out ); err != nil {
278291 return nil , err
279292 }
280293
0 commit comments