Skip to content

Commit 82840dd

Browse files
authored
Merge pull request #299 from seita-uc/fix/access-http-response-error
Fix access http post error response
2 parents 9b81f2a + a05f4d7 commit 82840dd

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

access/http/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func (h *httpHandler) post(_ context.Context, url *url.URL, body []byte, model i
149149
}
150150

151151
var httpErr HTTPError
152-
err = json.Unmarshal(body, &httpErr)
152+
err = json.Unmarshal(responseBody, &httpErr)
153153
if err != nil {
154154
return err
155155
}

access/http/handler_test.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ func TestHandler_ExecuteScript(t *testing.T) {
358358
)
359359

360360
_, err := handler.executeScriptAtBlockHeight(ctx, height, script, nil)
361-
assert.EqualError(t, err, "executing script main() { return 42; } failed: ") // todo check desc
361+
assert.EqualError(t, err, "executing script main() { return 42; } failed: execution failure") // todo check desc
362362
}))
363363
}
364364

@@ -376,6 +376,25 @@ func TestHandler_SendTransaction(t *testing.T) {
376376
err = handler.sendTransaction(ctx, rawTx)
377377
assert.NoError(t, err)
378378
}))
379+
380+
t.Run("Invalid Argument", handlerTest(func(ctx context.Context, t *testing.T, handler httpHandler, req *testRequest) {
381+
httpTx := transactionFlowFixture()
382+
u, _ := url.Parse("/transactions")
383+
384+
req.SetErr(
385+
*u,
386+
models.ModelError{
387+
Code: http.StatusBadRequest,
388+
Message: "rpc error: code = InvalidArgument",
389+
},
390+
)
391+
392+
rawTx, err := json.Marshal(httpTx)
393+
assert.NoError(t, err)
394+
395+
err = handler.sendTransaction(ctx, rawTx)
396+
assert.EqualError(t, err, "rpc error: code = InvalidArgument")
397+
}))
379398
}
380399

381400
func newTransactionURL(id string, query map[string]string) url.URL {

0 commit comments

Comments
 (0)