Skip to content

Commit

Permalink
missing case
Browse files Browse the repository at this point in the history
  • Loading branch information
Vovke committed Nov 6, 2024
1 parent 35b3daf commit 5db1f32
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

## [0.2.6] - 2024-11-01

### 🚀 Features

- Force withdrawal call implementation
- Docker container for the app
- Containerized test environment

### 🐛 Bug Fixes

- Fixed the storage fetching.
Expand Down
46 changes: 46 additions & 0 deletions chopsticks/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
version: '3.8'

services:
chopsticks-polkadot:
build:
context: .
dockerfile: Dockerfile
container_name: chopsticks-polkadot
ports:
- "8000:8000"
volumes:
- ./pd.yml:/app/config.yml
command: ["chopsticks", "-c", "/app/config.yml", "-p", "8000", "--addr", "0.0.0.0"]

chopsticks-polkadot-2:
build:
context: .
dockerfile: Dockerfile
container_name: chopsticks-polkadot-2
ports:
- "8500:8500"
volumes:
- ./pd-2.yml:/app/config.yml
command: [ "chopsticks", "-c", "/app/config.yml", "-p", "8500", "--addr", "0.0.0.0" ]

chopsticks-statemint:
build:
context: .
dockerfile: Dockerfile
container_name: chopsticks-statemint
ports:
- "9000:9000"
volumes:
- ./pd-ah.yml:/app/config.yml
command: ["chopsticks", "-c", "/app/config.yml", "-p", "9000", "--addr", "0.0.0.0"]

chopsticks-statemint-2:
build:
context: .
dockerfile: Dockerfile
container_name: chopsticks-statemint-2
ports:
- "9500:9500"
volumes:
- ./pd-ah-2.yml:/app/config.yml
command: [ "chopsticks", "-c", "/app/config.yml", "-p", "9500", "--addr", "0.0.0.0" ]
11 changes: 6 additions & 5 deletions src/handlers/order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,19 @@ pub async fn process_force_withdrawal(
state: State,
order_id: String,
) -> Result<OrderResponse, ForceWithdrawalError> {
state
.force_withdrawal(order_id)
.await
.map_err(|e| ForceWithdrawalError::WithdrawalError(e.to_string()))
let response = state.force_withdrawal(order_id).await?;
Ok(response)
}

pub async fn force_withdrawal(
ExtractState(state): ExtractState<State>,
Path(order_id): Path<String>,
) -> Response {
match process_force_withdrawal(state, order_id).await {
Ok(a) => (StatusCode::CREATED, Json(a)).into_response(),
Ok(OrderResponse::FoundOrder(order_status)) => (StatusCode::CREATED, Json(order_status)).into_response(),
Ok(OrderResponse::NotFound) => (StatusCode::NOT_FOUND, "Order not found").into_response(),
// that will never happen
Ok(OrderResponse::NewOrder(_)) | Ok(OrderResponse::ModifiedOrder(_)) | Ok(OrderResponse::CollidedOrder(_)) => todo!(),
Err(ForceWithdrawalError::WithdrawalError(a)) => {
(StatusCode::BAD_REQUEST, Json(a)).into_response()
}
Expand Down
7 changes: 4 additions & 3 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,10 @@ impl State {
.await
.map_err(|_| ForceWithdrawalError::InvalidParameter(order.clone()))?;

self.order_status(&order)
.await
.map_err(|_| ForceWithdrawalError::InvalidParameter(order))
match self.order_status(&order).await {
Ok(order_status) => Ok(order_status),
Err(_) => Ok(OrderResponse::NotFound),
}
}
pub fn interface(&self) -> Self {
State {
Expand Down
2 changes: 1 addition & 1 deletion tests/kalatori-api-test-suite/tests/order.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ describe('Order Endpoint Blackbox Tests', () => {
expect(forcedOrderDetails.withdrawal_status).toBe('forced');
}, 100000);

it.skip('should return 404 for non-existing order on force withdrawal', async () => {
it('should return 404 for non-existing order on force withdrawal', async () => {
const nonExistingOrderId = 'nonExistingOrder123';
const response = await request(baseUrl)
.post(`/v2/order/${nonExistingOrderId}/forceWithdrawal`);
Expand Down

0 comments on commit 5db1f32

Please sign in to comment.