Page MenuHomePhabricator

[avalanche] Simplify the peermanager tests by deduplicating the addCoin lambdas
ClosedPublic

Authored by Fabien on Apr 13 2022, 11:34.

Details

Summary

These lambdas are used all over the tests, so make it a static function to maintain it in a single place and simplify the tests.
The amount and height values are updated when possible to make the code simpler by matching the default, allowing for complete removal at a later point in time.

Test Plan
ninja check-avalanche

Diff Detail

Event Timeline

Fabien requested review of this revision.Apr 13 2022, 11:34
Fabien planned changes to this revision.Apr 13 2022, 13:42

Add all the extra cases I was saving for a follow-up as it makes more sense to have them here

tyler-smith added a subscriber: tyler-smith.

The idea and implementation are great, but I have a minor bikeshed-nit about naming. I don't think that nit should hold up acceptance but is worth considering.

src/avalanche/test/peermanager_tests.cpp
72 ↗(On Diff #33207)

Should this be called something like addUtxo or createUtxo to be more clear about it creating and adding a new UTXO as opposed to simply retrieving an existing one? Reading the code using this function, especially when using defaults, makes it look like a simple lookup function.

COutPoint utxo = getUtxo(key);

Looks like it should get a UTXO owned by that key, or null/empty value.

This revision is now accepted and ready to land.Apr 13 2022, 17:10
src/avalanche/test/peermanager_tests.cpp
72 ↗(On Diff #33207)

Renamed createUtxo