Skip to content

Commit

Permalink
rpcsrv: fix insufficient funds use
Browse files Browse the repository at this point in the history
This is not the way intended in neo-project/proposals#156.
-511 covers _both_ cases because users hardly can distinguish one from another,
it's just that our mempool implementation has error codes for both..

Signed-off-by: Roman Khimov <roman@nspcc.ru>
  • Loading branch information
roman-khimov committed Mar 18, 2024
1 parent 445ab97 commit 27f79b8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/services/rpcsrv/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2657,7 +2657,7 @@ func getRelayResult(err error, hash util.Uint256) (any, *neorpc.Error) {
return nil, neorpc.WrapErrorWithData(neorpc.ErrInsufficientNetworkFee, err.Error())
case errors.Is(err, core.ErrInvalidAttribute):
return nil, neorpc.WrapErrorWithData(neorpc.ErrInvalidAttribute, err.Error())
case errors.Is(err, core.ErrMemPoolConflict):
case errors.Is(err, core.ErrInsufficientFunds), errors.Is(err, core.ErrMemPoolConflict):
return nil, neorpc.WrapErrorWithData(neorpc.ErrInsufficientFunds, err.Error())
case errors.Is(err, core.ErrInvalidSignature):
return nil, neorpc.WrapErrorWithData(neorpc.ErrInvalidSignature, err.Error())
Expand Down
2 changes: 1 addition & 1 deletion pkg/services/rpcsrv/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2659,7 +2659,7 @@ func testRPCProtocol(t *testing.T, doRPCCall func(string, string, *testing.T) []
t.Run("insufficient funds", func(t *testing.T) {
b := testchain.NewBlock(t, chain, 1, 0, newTxWithParams(t, chain, opcode.PUSH1, 10, 899999999999, 1, false))
body := doRPCCall(fmt.Sprintf(rpc, encodeBinaryToString(t, b)), httpSrv.URL, t)
checkErrGetResult(t, body, true, neorpc.ErrVerificationFailedCode)
checkErrGetResult(t, body, true, neorpc.ErrInsufficientFundsCode)
})
t.Run("positive", func(t *testing.T) {
b := testchain.NewBlock(t, chain, 1, 0, newTxWithParams(t, chain, opcode.PUSH1, 10, 0, 1, false))
Expand Down

0 comments on commit 27f79b8

Please sign in to comment.