1

I want to create an end-to-end test in order to validate that an application doesn't let you spend before an incoming transaction confirms. I'm trying to broadcast an invalid tx to the Monero network via Monero's JSON RPC.

curl --request POST \
  --url http://127.0.0.1:38084/json_rpc \
  --header 'Authorization: Basic [redacted]' \
  --header 'Content-Type: application/jsons/developer-guides/wallet-rpc.html' \
  --data '{"jsonrpc":"2.0","id":"0","method":"transfer","params":{"destinations":[{"amount":250000,"address":"[redacted]"}],"priority":0,"get_tx_metadata":true}}'

Problem is, there are too many sanity checks. I need to force monero to broadcast this transaction regardless of its invalid nature.

{
  "error": {
    "code": -17,
    "message": "not enough money"
    },
  "id": "2555",
  "jsonrpc": "2.0"
}

I have read https://web.getmonero.org/resources/developer-guides/wallet-rpc.html, and I have asked on /r/monerosupport, I have also searched online for solutions to this issue, and haven't found anything useful.

I guess it doesn't necessarily have to be a double-spend, it just needs to attempt to spend more crypto than the wallet's actual balance, even though the transaction is fully intended to fail confirmation.

Alice
  • 422
  • 1
  • 9
  • 28
  • You could create 2 TXs referencing the same input, the second TX should trigger the error response from the node. On a sidenote, do you really need it to be an e2e test? Why not just stub the expected error response inside your application's integration testing phase? – J11 Apr 01 '23 at 14:24

0 Answers0