Skip to content

Commit

Permalink
test: Test code for SetValidatorCommission action
Browse files Browse the repository at this point in the history
  • Loading branch information
s2quake committed Dec 9, 2024
1 parent 7a52316 commit c90b637
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,5 +266,33 @@ public void Execute_NotValidator_Throw()
Assert.Throws<FailedLoadStateException>(
() => 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<InvalidOperationException>(
() => setValidatorCommission.Execute(actionContext));
}
}
}

0 comments on commit c90b637

Please sign in to comment.