Skip to content

fix(types/address): correct sort comparator in Compose to satisfy strict weak ordering#25944

Merged
aljo242 merged 11 commits intocosmos:mainfrom
songgaoye:fix_address_compose
Apr 27, 2026
Merged

fix(types/address): correct sort comparator in Compose to satisfy strict weak ordering#25944
aljo242 merged 11 commits intocosmos:mainfrom
songgaoye:fix_address_compose

Conversation

@songgaoye
Copy link
Copy Markdown
Contributor

Description

The Compose function used <= 0 in its sort comparator, which violates the
strict weak ordering requirement of sort.Interface. When comparing equal
elements, both less(i,j) and less(j,i) would return true, violating the
antisymmetry property.

Closes: #XXXX

@aljo242
Copy link
Copy Markdown
Contributor

aljo242 commented Feb 16, 2026

@songgaoye is there a test we can include to validate this behavior and can we add a changelog entry?

@songgaoye
Copy link
Copy Markdown
Contributor Author

songgaoye commented Feb 26, 2026

This unit test requires adding a lessBytes helper function @aljo242 in commit 09119d2.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.83%. Comparing base (d9bd545) to head (bd89e6f).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #25944      +/-   ##
==========================================
- Coverage   64.86%   64.83%   -0.03%     
==========================================
  Files         890      874      -16     
  Lines       58581    57601     -980     
==========================================
- Hits        37997    37346     -651     
+ Misses      20584    20255     -329     
Files with missing lines Coverage Δ
types/address/hash.go 100.00% <100.00%> (ø)

... and 21 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

@aljo242 aljo242 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add tests for the Compose function itself?

@songgaoye songgaoye requested a review from a team as a code owner April 25, 2026 14:11
@songgaoye songgaoye requested a review from aljo242 April 25, 2026 14:30
@aljo242 aljo242 enabled auto-merge April 27, 2026 17:15
@aljo242 aljo242 added this pull request to the merge queue Apr 27, 2026
Merged via the queue into cosmos:main with commit 6786515 Apr 27, 2026
43 checks passed
@songgaoye songgaoye deleted the fix_address_compose branch April 28, 2026 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants