Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Planner tests: Undelegate action #1841

Open
Tracked by #691
grod220 opened this issue Oct 4, 2024 · 0 comments
Open
Tracked by #691

Planner tests: Undelegate action #1841

grod220 opened this issue Oct 4, 2024 · 0 comments
Labels
testing Related to writing tests

Comments

@grod220
Copy link
Collaborator

grod220 commented Oct 4, 2024

Write tests for undelegate action:

for tpr::Undelegate { value, rate_data } in request.undelegations {
let epoch = storage.get_latest_known_epoch().await?.unwrap();
let value: Value = value
.ok_or_else(|| anyhow!("missing value in undelegation"))?
.try_into()?;
let rate_data: RateData = rate_data
.ok_or_else(|| anyhow!("missing rate data in undelegation"))?
.try_into()?;
let undelegate = rate_data.build_undelegate(epoch.into(), value.amount);
save_unbonding_token_metadata_if_needed(&undelegate, &storage).await?;
actions_list.push(undelegate);
}

and undelegate claim action:

for tpr::UndelegateClaim {
validator_identity,
unbonding_start_height,
penalty,
unbonding_amount,
..
} in request.undelegation_claims
{
let validator_identity: IdentityKey = validator_identity
.ok_or_else(|| anyhow!("missing validator identity in undelegation claim"))?
.try_into()?;
let penalty: Penalty = penalty
.ok_or_else(|| anyhow!("missing penalty in undelegation claim"))?
.try_into()?;
let unbonding_amount: Amount = unbonding_amount
.ok_or_else(|| anyhow!("missing unbonding amount in undelegation claim"))?
.try_into()?;
let undelegate_claim_plan = UndelegateClaimPlan {
validator_identity,
unbonding_start_height,
penalty,
unbonding_amount,
balance_blinding: Fr::rand(&mut OsRng),
proof_blinding_r: Fq::rand(&mut OsRng),
proof_blinding_s: Fq::rand(&mut OsRng),
};
actions_list.push(ActionPlan::UndelegateClaim(undelegate_claim_plan));
}

@github-project-automation github-project-automation bot moved this to 🗄️ Backlog in Penumbra web Oct 4, 2024
@grod220 grod220 added the testing Related to writing tests label Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing Related to writing tests
Projects
Status: 🗄️ Backlog
Development

No branches or pull requests

1 participant