pytest: don't rely on sleep to ensure wait commands have been submitted.

Seems like sleep(1) isn't always enough.  Give in and put a log
message there, and use that:

```
	waitfut = executor.submit(l2.rpc.wait, subsystem='forwards', indexname='deleted', nextvalue=1)
        time.sleep(1)
    
        l2.rpc.delforward(scid12, 1, 'failed')
    
        waitres = waitfut.result(TIMEOUT)
>       assert waitres == {'subsystem': 'forwards',
                           'deleted': 1,
                           'forwards': {'in_channel': scid12,
                                        'in_htlc_id': 1,
                                        'status': 'failed'}}
E       AssertionError: assert {'subsystem': 'forwards', 'deleted': 1} == {'subsystem': 'forwards', 'deleted': 1, 'forwards': {'in_channel': '103x2x0', 'in_htlc_id': 1, 'status': 'failed'}}
E         
E         Common items:
E         {'deleted': 1, 'subsystem': 'forwards'}
E         Right contains 1 more item:
E         {'forwards': {'in_channel': '103x2x0', 'in_htlc_id': 1, 'status': 'failed'}}
E         
E         Full diff:
E           {
E               'deleted': 1,
E         -     'forwards': {
E         -         'in_channel': '103x2x0',
E         -         'in_htlc_id': 1,
E         -         'status': 'failed',
E         -     },
E               'subsystem': 'forwards',
E           }

tests/test_misc.py:3599: AssertionError
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2026-01-14 13:18:11 +10:30
parent fd64bb114b
commit 3be25d48d3
6 changed files with 28 additions and 20 deletions

View File

@@ -5,6 +5,7 @@
#include <common/json_command.h>
#include <common/overflows.h>
#include <db/exec.h>
#include <inttypes.h>
#include <lightningd/jsonrpc.h>
#include <lightningd/lightningd.h>
#include <lightningd/wait.h>
@@ -277,6 +278,10 @@ static struct command_result *json_wait(struct command *cmd,
waiter->cmd = cmd;
list_add_tail(&cmd->ld->wait_commands, &waiter->list);
log_trace(cmd->ld->log, "waiting on %s %s %"PRIu64,
wait_subsystem_name(*waiter->subsystem),
wait_index_name(*waiter->index),
*waiter->nextval);
return command_still_pending(cmd);
}