Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Fix test by sorting results #5103

Merged
merged 1 commit into from
Feb 2, 2023

Conversation

Eric-Warehime
Copy link
Contributor

Summary

e544fc8 introduced additional test cases for the output of a model.LedgerStateDelta conversion from ledgercore.StateDelta, but it assumes that the output order of KvMods in the result will be equal to the input order.

In other words [{"box1"},{"box2"},{"box3"}] may convert to [{"box2"},{"box1"},{"box3"}] so we need to sort the output to get deterministic results.

Comment on lines +143 to +146
// sort the result so we have deterministic order
sort.Slice(*converted.KvMods, func(i, j int) bool {
return bytes.Compare(*(*converted.KvMods)[i].Key, *(*converted.KvMods)[j].Key) < 0
})
Copy link
Contributor

Choose a reason for hiding this comment

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

There is also a require.ElementsMatch feature which claims to ignore the order

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I wasn't sure if that would do a deep equals or not.

@codecov
Copy link

codecov bot commented Feb 2, 2023

Codecov Report

Merging #5103 (2b91ba7) into master (9ffa72a) will decrease coverage by 0.02%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #5103      +/-   ##
==========================================
- Coverage   53.41%   53.39%   -0.02%     
==========================================
  Files         431      431              
  Lines       54369    54369              
==========================================
- Hits        29040    29033       -7     
- Misses      23066    23074       +8     
+ Partials     2263     2262       -1     
Impacted Files Coverage Δ
network/wsPeer.go 65.97% <0.00%> (-2.30%) ⬇️
ledger/tracker.go 74.26% <0.00%> (-0.85%) ⬇️
ledger/acctupdates.go 69.11% <0.00%> (+0.12%) ⬆️
catchup/service.go 68.94% <0.00%> (+0.47%) ⬆️
ledger/testing/randomAccounts.go 56.88% <0.00%> (+0.61%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants