From c90b637d15671b95bef3d48ddab9c8571497e432 Mon Sep 17 00:00:00 2001 From: s2quake Date: Mon, 9 Dec 2024 15:55:10 +0900 Subject: [PATCH] test: Test code for SetValidatorCommission action --- .../SetValidatorCommissionTest.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.Lib9c.Tests/Action/ValidatorDelegation/SetValidatorCommissionTest.cs b/.Lib9c.Tests/Action/ValidatorDelegation/SetValidatorCommissionTest.cs index 97eacf55f1..1b6ef02a35 100644 --- a/.Lib9c.Tests/Action/ValidatorDelegation/SetValidatorCommissionTest.cs +++ b/.Lib9c.Tests/Action/ValidatorDelegation/SetValidatorCommissionTest.cs @@ -266,5 +266,33 @@ public void Execute_NotValidator_Throw() Assert.Throws( () => setValidatorCommission.Execute(actionContext)); } + + [Fact] + public void Execute_With_SameValue_Throw() + { + // Given + var world = World; + var validatorKey = new PrivateKey(); + var validatorGold = DelegationCurrency * 10; + var height = 1L; + world = EnsureToMintAsset(world, validatorKey, validatorGold, height++); + world = EnsurePromotedValidator(world, validatorKey, validatorGold, height); + + // When + var repository = new ValidatorRepository(world, new ActionContext()); + var delegatee = repository.GetValidatorDelegatee(validatorKey.Address); + var commissionPercentage = delegatee.CommissionPercentage; + var setValidatorCommission = new SetValidatorCommission( + commissionPercentage: commissionPercentage); + var actionContext = new ActionContext + { + PreviousState = world, + Signer = validatorKey.Address, + BlockIndex = height + CommissionPercentageChangeCooldown, + }; + + Assert.Throws( + () => setValidatorCommission.Execute(actionContext)); + } } }