From 7303dfed953765fb042a8ea1d7ed179674a46bd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Tue, 28 Nov 2023 17:06:11 +0100 Subject: [PATCH] test/tx_redelegate: filter out invalid redelegations --- .../proptest-regressions/tx_redelegate.txt | 2 ++ wasm/wasm_source/src/tx_redelegate.rs | 22 ++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 wasm/wasm_source/proptest-regressions/tx_redelegate.txt diff --git a/wasm/wasm_source/proptest-regressions/tx_redelegate.txt b/wasm/wasm_source/proptest-regressions/tx_redelegate.txt new file mode 100644 index 0000000000..a8d6e7edba --- /dev/null +++ b/wasm/wasm_source/proptest-regressions/tx_redelegate.txt @@ -0,0 +1,2 @@ +cc 90825d666558e208bb8f4f46c746177abf8bf9499114dcdac1525ab600b7c6ce + diff --git a/wasm/wasm_source/src/tx_redelegate.rs b/wasm/wasm_source/src/tx_redelegate.rs index 8416c4d553..82f63cd9e4 100644 --- a/wasm/wasm_source/src/tx_redelegate.rs +++ b/wasm/wasm_source/src/tx_redelegate.rs @@ -403,15 +403,21 @@ mod tests { address::testing::arb_non_internal_address(), token::testing::arb_amount_non_zero_ceiled(max_amount), ) - .prop_map( + .prop_filter_map( + "Src and dest validator must not be the same", |(src_validator, dest_validator, owner, amount)| { - let src_validator = Address::Established(src_validator); - let dest_validator = Address::Established(dest_validator); - transaction::pos::Redelegation { - src_validator, - dest_validator, - owner, - amount, + if src_validator == dest_validator { + None + } else { + let src_validator = Address::Established(src_validator); + let dest_validator = + Address::Established(dest_validator); + Some(transaction::pos::Redelegation { + src_validator, + dest_validator, + owner, + amount, + }) } }, )