From 1d8a0069e20b87d5fe4a2043a485c16a7cdf8e22 Mon Sep 17 00:00:00 2001 From: TAMARA LIPOWSKI Date: Wed, 10 Sep 2025 10:42:26 -0400 Subject: [PATCH] fix: Use permutations to get token directions - This is needed for pools which have >2 tokens. --- protocol-testing/src/test_runner.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/protocol-testing/src/test_runner.rs b/protocol-testing/src/test_runner.rs index 2876633..0254e89 100644 --- a/protocol-testing/src/test_runner.rs +++ b/protocol-testing/src/test_runner.rs @@ -5,6 +5,7 @@ use figment::{ providers::{Format, Yaml}, Figment, }; +use itertools::Itertools; use miette::{miette, IntoDiagnostic, WrapErr}; use num_bigint::BigUint; use num_traits::Zero; @@ -457,8 +458,12 @@ fn validate_state( // We then retrieve the amount out for 0.1%, 1% and 10%. let percentages = [0.001, 0.01, 0.1]; - // Test both swap directions - let swap_directions = [(&tokens[0], &tokens[1]), (&tokens[1], &tokens[0])]; + // Test all permutations of swap directions + let swap_directions: Vec<_> = tokens + .iter() + .permutations(2) + .map(|perm| (perm[0], perm[1])) + .collect(); for (token_in, token_out) in &swap_directions { let (max_input, max_output) = state