From 27f79b8c63f9b0fb97371edcdd1369d8a2384daf Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Mon, 18 Mar 2024 20:35:49 +0300 Subject: [PATCH] rpcsrv: fix insufficient funds use This is not the way intended in https://github.com/neo-project/proposals/pull/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 --- pkg/services/rpcsrv/server.go | 2 +- pkg/services/rpcsrv/server_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/services/rpcsrv/server.go b/pkg/services/rpcsrv/server.go index 545418234..7f6a06b3b 100644 --- a/pkg/services/rpcsrv/server.go +++ b/pkg/services/rpcsrv/server.go @@ -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()) diff --git a/pkg/services/rpcsrv/server_test.go b/pkg/services/rpcsrv/server_test.go index 1b275d92c..1b74763ad 100644 --- a/pkg/services/rpcsrv/server_test.go +++ b/pkg/services/rpcsrv/server_test.go @@ -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))