Skip to content

fix(Route): Enforce no empty swaps on Router::new()#258

Open
dianacarvalho1 wants to merge 1 commit into
mainfrom
maintenance/dc/ENG-6023-enforce-no-empty-swaps-in-route
Open

fix(Route): Enforce no empty swaps on Router::new()#258
dianacarvalho1 wants to merge 1 commit into
mainfrom
maintenance/dc/ENG-6023-enforce-no-empty-swaps-in-route

Conversation

@dianacarvalho1

Copy link
Copy Markdown
Collaborator

No description provided.

@dianacarvalho1 dianacarvalho1 self-assigned this Jun 26, 2026
@dianacarvalho1 dianacarvalho1 force-pushed the maintenance/dc/ENG-6023-enforce-no-empty-swaps-in-route branch from 501eae5 to 33bf08b Compare June 26, 2026 08:20

@Troshchk Troshchk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you @dianacarvalho1! 🤩
I like the change and it looks good to me, only left one question!

Comment on lines +1739 to +1746
// Constructs a `Route` directly, bypassing `Route::new`'s non-empty check, so
// accessor behaviour on empty routes (reachable via deserialization) stays testable.
fn make_route(swaps: Vec<(u8, u8)>) -> Route {
let swaps: Vec<Swap> = swaps
.into_iter()
.map(|(a, b)| make_swap(a, b, 1000, 990))
.collect();
Route::new(swaps, HashMap::new())
Route { swaps, tokens: HashMap::new() }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we enforce to not have empty swaps in the Route, why do we need to keep it testable?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

when we create a Route through deserialization it is still possible to have empty swaps

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

but shouldn't we also have a check the result after the deserialization and make sure it is not empty?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

actually.. I think deserialisation never truly happens inside of Fynd. Route is only a response type. Enforcing at new closes the only realistic source (algorithm code) without touching the public API

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