MCPcopy Create free account
hub / github.com/cowprotocol/services / postgres_cancel_order

Function postgres_cancel_order

crates/database/src/orders.rs:1710–1731  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1708 #[tokio::test]
1709 #[ignore]
1710 async fn postgres_cancel_order() {
1711 let mut db = PgConnection::connect("postgresql://").await.unwrap();
1712 let mut db = db.begin().await.unwrap();
1713 crate::clear_DANGER_(&mut db).await.unwrap();
1714
1715 let order = Order::default();
1716 insert_order(&mut db, &order).await.unwrap();
1717 let order = read_order(&mut db, &order.uid).await.unwrap().unwrap();
1718 assert!(order.cancellation_timestamp.is_none());
1719
1720 let time = Utc.timestamp_opt(1234567890, 0).unwrap();
1721 cancel_order(&mut db, &order.uid, time).await.unwrap();
1722 let order = read_order(&mut db, &order.uid).await.unwrap().unwrap();
1723 assert_eq!(time, order.cancellation_timestamp.unwrap());
1724
1725 // Cancel again and verify that cancellation timestamp was not changed.
1726 let irrelevant_time = Utc.timestamp_opt(1234564319, 1_000_000_000).unwrap();
1727 assert_ne!(irrelevant_time, time);
1728 cancel_order(&mut db, &order.uid, time).await.unwrap();
1729 let order = read_order(&mut db, &order.uid).await.unwrap().unwrap();
1730 assert_eq!(time, order.cancellation_timestamp.unwrap());
1731 }
1732
1733 // In the schema we set the type of executed amounts in individual events to a
1734 // 78 decimal digit number. Summing over multiple events could overflow this

Callers

nothing calls this directly

Calls 6

connectFunction · 0.85
clear_DANGER_Function · 0.85
unwrapMethod · 0.80
insert_orderFunction · 0.70
read_orderFunction · 0.70
cancel_orderFunction · 0.70

Tested by

no test coverage detected