core-lightning/common/test
Vasil Dimov 55173a56b7 Use dedicated type for error codes
Before this patch we used `int` for error codes. The problem with
`int` is that we try to pass it to/from wire and the size of `int` is
not defined by the standard. So a sender with 4-byte `int` would write
4 bytes to the wire and a receiver with 2-byte `int` (for example) would
read just 2 bytes from the wire.

To resolve this:

* Introduce an error code type with a known size:
  `typedef s32 errcode_t`.

* Change all error code macros to constants of type `errcode_t`.
  Constants also play better with gdb - it would visualize the name of
  the constant instead of the numeric value.

* Change all functions that take error codes to take the new type
  `errcode_t` instead of `int`.

* Introduce towire / fromwire functions to send / receive the newly added
  type `errcode_t` and use it instead of `towire_int()`.

In addition:

* Remove the now unneeded `towire_int()`.

* Replace a hardcoded error code `-2` with a new constant
  `INVOICE_EXPIRED_DURING_WAIT` (903).

Changelog-Changed: The waitinvoice command would now return error code 903 to designate that the invoice expired during wait, instead of the previous -2
2020-01-31 06:02:47 +00:00
..
Makefile unit test: fix run-sphinx dependencies and update mocks 2019-11-26 21:25:25 +01:00
onion-test-v0.json sphinx: Introduce a runtest command to the onion tool 2019-07-30 02:14:49 +00:00
run-amount.c bitcoin/tx: use fromwire_fail in pull_bitcoin_tx. 2019-06-21 03:56:59 +00:00
run-bigsize.c elements: Add amount_asset to support more than just plain satoshis 2019-10-03 04:32:57 +00:00
run-bolt11.c common/bolt11: add secret support. 2019-11-24 23:33:17 +00:00
run-cryptomsg.c common: allow subdaemons to specify the node_id in status messages. 2019-11-18 04:50:22 +00:00
run-derive_basepoints.c elements: Add amount_asset to support more than just plain satoshis 2019-10-03 04:32:57 +00:00
run-features.c common/features: clean up feature handling for different cases. 2019-11-24 23:33:17 +00:00
run-funding_tx.c elements: Add amount_asset to support more than just plain satoshis 2019-10-03 04:32:57 +00:00
run-gossip_rcvd_filter.c elements: Add amount_asset to support more than just plain satoshis 2019-10-03 04:32:57 +00:00
run-ip_port_parsing.c elements: Add amount_asset to support more than just plain satoshis 2019-10-03 04:32:57 +00:00
run-json.c elements: Add amount_asset to support more than just plain satoshis 2019-10-03 04:32:57 +00:00
run-json_remove.c elements: Add amount_asset to support more than just plain satoshis 2019-10-03 04:32:57 +00:00
run-key_derive.c elements: Add amount_asset to support more than just plain satoshis 2019-10-03 04:32:57 +00:00
run-lock.c elements: Add amount_asset to support more than just plain satoshis 2019-10-03 04:32:57 +00:00
run-param.c Use dedicated type for error codes 2020-01-31 06:02:47 +00:00
run-softref.c utils: add set_softref() / clear_softref(). 2019-10-10 21:48:52 -05:00
run-sphinx.c common: use struct onionreply. 2020-01-23 16:17:42 +10:30