added a test case so that the enum wallet_payment_status which is critical for the communitcation with the data store will not accidentely being changed by some developer

[ Folded "cleaned up the test code" -- RR ]
[ Fixed prototype -- RR ]
This commit is contained in:
Rene Pickhardt 2018-07-27 12:55:37 +02:00 committed by Christian Decker
parent bd5bf1f168
commit 8b902729b9
2 changed files with 11 additions and 1 deletions

View File

@ -955,6 +955,14 @@ static bool test_payment_crud(struct lightningd *ld, const tal_t *ctx)
return true;
}
static bool test_wallet_payment_status_enum(void)
{
CHECK(PAYMENT_PENDING == 0);
CHECK(PAYMENT_COMPLETE == 1);
CHECK(PAYMENT_FAILED == 2);
return true;
}
int main(void)
{
setup_locale();
@ -979,6 +987,7 @@ int main(void)
ok &= test_channel_config_crud(ld, tmpctx);
ok &= test_htlc_crud(ld, tmpctx);
ok &= test_payment_crud(ld, tmpctx);
ok &= test_wallet_payment_status_enum();
/* Do not clean up in the case of an error, we might want to debug the
* database. */

View File

@ -81,7 +81,8 @@ struct wallet_shachain {
* get the preimage matching the rhash, or to
* `PAYMENT_FAILED`. */
/* /!\ This is a DB ENUM, please do not change the numbering of any
* already defined elements (adding is ok) /!\ */
* already defined elements (adding is ok but you should append the
* test case test_wallet_payment_status_enum() ) /!\ */
enum wallet_payment_status {
PAYMENT_PENDING = 0,
PAYMENT_COMPLETE = 1,