Skip to content

Commit

Permalink
remove silent failure on cancel (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
brittcyr authored Aug 26, 2024
1 parent f3fb5a3 commit b735660
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
18 changes: 18 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions programs/manifest/src/state/market.rs
Original file line number Diff line number Diff line change
Expand Up @@ -861,10 +861,8 @@ impl<Fixed: DerefOrBorrowMut<MarketFixed>, Dynamic: DerefOrBorrowMut<[u8]>>
}
}

// TODO: Remove the silent failures
// Silently fails because order could have matched before our cancel got
// there and that is correct behavior in that case.
Ok(())
// Do not fail silently.
Err(ManifestError::InvalidCancel.into())
}

pub fn cancel_order_by_index(
Expand Down
4 changes: 2 additions & 2 deletions programs/manifest/tests/cases/cancel_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ async fn cancel_order_sequence_number_not_exist_test() -> anyhow::Result<()> {
.place_order(Side::Ask, 1, 1, 0, u32::MAX, OrderType::Limit)
.await?;

// Sequence number does not exist, but it fails open.
test_fixture.cancel_order(1234).await?;
// Sequence number does not exist. It fails closed.
assert!(test_fixture.cancel_order(1234).await.is_err());

Ok(())
}
Expand Down

0 comments on commit b735660

Please sign in to comment.