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: Position actions #1843

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

Planner tests: Position actions #1843

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 all position actions:

  • PositionOpen
  • PositionClose
  • PositionWithdraw

for tpr::PositionOpen { position } in request.position_opens {
actions_list.push(ActionPlan::PositionOpen(PositionOpen {
position: position
.ok_or_else(|| anyhow!("missing position in PositionOpen"))?
.try_into()?,
}));
}
for tpr::PositionClose { position_id } in request.position_closes {
actions_list.push(ActionPlan::PositionClose(PositionClose {
position_id: position_id
.ok_or_else(|| anyhow!("missing position_id in PositionClose"))?
.try_into()?,
}));
}
// Note: Currently this only supports an initial withdrawal from Closed, with no rewards.
for tpr::PositionWithdraw {
position_id,
reserves,
trading_pair,
} in request.position_withdraws
{
actions_list.push(ActionPlan::PositionWithdraw(PositionWithdrawPlan {
position_id: position_id
.ok_or_else(|| anyhow!("missing position_id in PositionWithdraw"))?
.try_into()?,
reserves: reserves
.ok_or_else(|| anyhow!("missing reserves in PositionWithdraw"))?
.try_into()?,
pair: trading_pair
.ok_or_else(|| anyhow!("missing trading_pair in PositionWithdraw"))?
.try_into()?,
sequence: 0,
rewards: vec![],
}));
}

@grod220 grod220 added the testing Related to writing tests label Oct 4, 2024
@github-project-automation github-project-automation bot moved this to 🗄️ Backlog in Penumbra web 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