pytest: don't assume that tags will always be in the same order.
What changed, and why it matters
This change only affects internal test helper code. It makes test comparisons of tag lists ignore the order of tags by sorting them first. There is no security issue; it is a test robustness fix.
No security action needed. Treat as a normal test-quality improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies tests/utils.py to sort tag lists before comparing them in several test utility functions (move_matches, check_coin_moves, matchup_events). Previously these helpers assumed tag ordering was deterministic, which could cause flaky test failures. The change is purely in test infrastructure and does not alter production code, protocol handling, or any security-sensitive logic.
Changed components
tests/utils.pyInspect captured patch +4 / −4
diff --git a/tests/utils.py b/tests/utils.py
index ed1e12a7..6c701021 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -88,7 +88,7 @@ def move_matches(exp, mv):
return False
if Millisatoshi(mv['debit_msat']) != Millisatoshi(exp['debit_msat']):
return False
- if mv['tags'] != exp['tags']:
+ if sorted(mv['tags']) != sorted(exp['tags']):
return False
if 'fees_msat' in exp:
if 'fees_msat' not in mv:
@@ -144,7 +144,7 @@ def check_coin_moves(n, account_id, expected_moves, chainparams):
.format(mv['type'],
Millisatoshi(mv['credit_msat']).millisatoshis,
Millisatoshi(mv['debit_msat']).millisatoshis,
- mv['tags'],
+ sorted(mv['tags']),
mv['fees_msat'] if 'fees_msat' in mv else ''))
if mv['version'] != 2:
raise ValueError(f'version not 2 {mv}')
@@ -277,7 +277,7 @@ def matchup_events(u_set, evs, chans, tag_list):
else:
acct = ev[0]
- if u[0]['account_id'] != acct or u[0]['tags'] != ev[1]:
+ if u[0]['account_id'] != acct or sorted(u[0]['tags']) != sorted(ev[1]):
continue
if ev[2] is None:
@@ -301,7 +301,7 @@ def matchup_events(u_set, evs, chans, tag_list):
# Save the 'spent to' txid in the tag-list
tag_list[x[1]] = u[1]['txid']
else:
- if ev[2] != u[1]['tags']:
+ if sorted(ev[2]) != sorted(u[1]['tags']):
raise ValueError(f"tags dont' match. exp {ev}, actual ({u[1]}) full utxo info: {u}")
# Save the 'spent to' txid in the tag-list
if 'to_miner' not in u[1]['tags']:
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.