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

Function postgres_save

crates/database/src/order_execution.rs:139–193  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

137 #[tokio::test]
138 #[ignore]
139 async fn postgres_save() {
140 let mut db = PgConnection::connect("postgresql://").await.unwrap();
141 let mut db = db.begin().await.unwrap();
142 crate::clear_DANGER_(&mut db).await.unwrap();
143
144 // save entry with protocol fees
145 let protocol_fees = vec![
146 Asset {
147 amount: BigDecimal::from(1),
148 token: Default::default(),
149 },
150 Asset {
151 amount: BigDecimal::from(2),
152 token: Default::default(),
153 },
154 ];
155 save(
156 &mut db,
157 &Default::default(),
158 1,
159 0,
160 Asset {
161 amount: BigDecimal::from(3),
162 token: Default::default(),
163 },
164 protocol_fees.as_slice(),
165 )
166 .await
167 .unwrap();
168
169 // save entry for an order without protocol fees
170 save(
171 &mut db,
172 &Default::default(),
173 2,
174 0,
175 Asset {
176 amount: BigDecimal::from(3),
177 token: Default::default(),
178 },
179 &[],
180 )
181 .await
182 .unwrap();
183
184 let keys: Vec<(AuctionId, OrderUid)> = vec![
185 (1, Default::default()),
186 (2, Default::default()),
187 (3, Default::default()),
188 ];
189
190 let read_protocol_fees = executed_protocol_fees(&mut db, &keys).await.unwrap();
191 assert_eq!(read_protocol_fees.len(), 2);
192 assert_eq!(read_protocol_fees[&(1, Default::default())], protocol_fees);
193 }
194}

Callers

nothing calls this directly

Calls 6

connectFunction · 0.85
clear_DANGER_Function · 0.85
executed_protocol_feesFunction · 0.85
unwrapMethod · 0.80
as_sliceMethod · 0.80
saveFunction · 0.70

Tested by

no test coverage detected