From b6bdb7482bdb10745ba1c02d2f27cb5073cd6808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Mon, 5 Aug 2024 16:47:34 +0300 Subject: [PATCH] potlock: distributePotToProjects: percentage req Modify require_correct_percentages from distributePotToProjects endpoint. The total may be lower than 100%. This enables the caller to distribute part of the pot. --- contracts/potlock/src/potlock_storage.rs | 4 ++-- contracts/potlock/tests/potlock_blackbox_tests.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/contracts/potlock/src/potlock_storage.rs b/contracts/potlock/src/potlock_storage.rs index 46f6df63..676bce9f 100644 --- a/contracts/potlock/src/potlock_storage.rs +++ b/contracts/potlock/src/potlock_storage.rs @@ -121,8 +121,8 @@ pub trait PotlockStorage { total_perc += perc; } require!( - total_perc == MAX_PERCENTAGE, - "Total percentages different than 100%" + total_perc <= MAX_PERCENTAGE, + "Total percentages more than 100%" ); } diff --git a/contracts/potlock/tests/potlock_blackbox_tests.rs b/contracts/potlock/tests/potlock_blackbox_tests.rs index d0e07cd3..994b8b53 100644 --- a/contracts/potlock/tests/potlock_blackbox_tests.rs +++ b/contracts/potlock/tests/potlock_blackbox_tests.rs @@ -583,7 +583,7 @@ fn test_fail_distribute_pot_to_projects2() { // Distribute Pot donations to projects let mut percentages = MultiValueVec::new(); - percentages.push((project_id, HALF_PERCENTAGE).into()); + percentages.push((project_id, 3* HALF_PERCENTAGE).into()); state .world .tx() @@ -591,7 +591,7 @@ fn test_fail_distribute_pot_to_projects2() { .to(POTLOCK_ADDRESS) .typed(potlock_proxy::PotlockProxy) .distribute_pot_to_projects(potlock_id, percentages) - .with_result(ExpectError(4, "Total percentages different than 100%")) + .with_result(ExpectError(4, "Total percentages more than 100%")) .run(); }