Skip to content

Commit 88404a1

Browse files
committed
fix: fix tests no pending fills
1 parent 99524a0 commit 88404a1

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

contracts/cosmwasm-vm/cw-intents-v1/src/contract.rs

+2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ impl<'a> CwIntentV1Service<'a> {
6666
if self.is_order_finished(deps.storage, &order_hash) {
6767
return Err(ContractError::OrderAlreadyComplete);
6868
}
69+
self.set_order_finished(deps.storage, &keccak256(&order.rlp_bytes()), true).unwrap();
6970
let mut response = self.receive_payment(
7071
deps.as_ref(),
7172
env.clone(),
@@ -119,6 +120,7 @@ impl<'a> CwIntentV1Service<'a> {
119120
response = response.add_message(fee_transfer);
120121
}
121122
response = response.add_event(order_fill_event);
123+
122124
Ok(response)
123125
}
124126

contracts/cosmwasm-vm/cw-intents-v1/src/types.rs

+43-3
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ mod tests {
217217
order_bytes: hex::decode("6c449988e2f33302803c93f8287dc1d8cb33848a").unwrap(),
218218
solver_address: "0xcb0a6bbccfccde6be9f10ae781b9d9b00d6e63".to_string(),
219219
};
220-
assert!(fill.rlp_bytes()==hex::decode("f84301946c449988e2f33302803c93f8287dc1d8cb33848aa8307863623061366262636366636364653662653966313061653738316239643962303064366536338201f401").unwrap());
220+
assert!(fill.rlp_bytes()==hex::decode("f83f01946c449988e2f33302803c93f8287dc1d8cb33848aa830786362306136626263636663636465366265396631306165373831623964396230306436653633").unwrap());
221221
}
222222

223223
#[test]
@@ -227,9 +227,49 @@ mod tests {
227227
order_bytes: hex::decode("cb0a6bbccfccde6be9f10ae781b9d9b00d6e63").unwrap(),
228228
solver_address: "0x6c449988e2f33302803c93f8287dc1d8cb33848a".to_string(),
229229
};
230-
assert!(fill.rlp_bytes()==hex::decode("f84b0293cb0a6bbccfccde6be9f10ae781b9d9b00d6e63aa3078366334343939383865326633333330323830336339336638323837646331643863623333383438618928a857425466f8000000").unwrap());
230+
assert!(fill.rlp_bytes()==hex::decode("f8400293cb0a6bbccfccde6be9f10ae781b9d9b00d6e63aa307836633434393938386532663333333032383033633933663832383764633164386362333338343861").unwrap());
231231
}
232232

233233
#[test]
234-
fn test_order_cancel_encoding() {}
234+
fn test_order_cancel_encoding() {
235+
let cancel= OrderCancel{
236+
order_bytes: hex::decode("6c449988e2f33302803c93f8287dc1d8cb33848a").unwrap(),
237+
};
238+
assert!(cancel.rlp_bytes()==hex::decode("d5946c449988e2f33302803c93f8287dc1d8cb33848a").unwrap());
239+
}
240+
241+
#[test]
242+
fn test_swap_order_encoding(){
243+
let order =SwapOrder {
244+
id: 1,
245+
emitter: "0xbe6452d4d6c61cee97d3".to_string(),
246+
src_nid: "Ethereum".to_string(),
247+
dst_nid: "Polygon".to_string(),
248+
creator: "0x3e36eddd65e239222e7e67".to_string(),
249+
destination_address: "0xd2c6218b875457a41b6fb7964e".to_string(),
250+
token: "0x14355340e857912188b7f202d550222487".to_string(),
251+
amount: 1000,
252+
to_token: "0x91a4728b517484f0f610de7b".to_string(),
253+
to_amount: 900,
254+
data: vec![],
255+
};
256+
assert!(order.rlp_bytes()==hex::decode("f8a601963078626536343532643464366336316365653937643388457468657265756d87506f6c79676f6e983078336533366564646436356532333932323265376536379c30786432633632313862383735343537613431623666623739363465a43078313433353533343065383537393132313838623766323032643535303232323438378203e89a307839316134373238623531373438346630663631306465376282038480").unwrap());
257+
258+
let order =SwapOrder {
259+
id: 1,
260+
emitter: "0xbe6452d4d6c61cee97d3".to_string(),
261+
src_nid: "Ethereum".to_string(),
262+
dst_nid: "Polygon".to_string(),
263+
creator: "0x3e36eddd65e239222e7e67".to_string(),
264+
destination_address: "0xd2c6218b875457a41b6fb7964e".to_string(),
265+
token: "0x14355340e857912188b7f202d550222487".to_string(),
266+
amount: 100000 * 10000000000000000000000,
267+
to_token: "0x91a4728b517484f0f610de7b".to_string(),
268+
to_amount: 900*10000000,
269+
data: hex::decode("6c449988e2f33302803c93f8287dc1d8cb33848a").unwrap(),
270+
};
271+
assert!(order.rlp_bytes()==hex::decode("f8c701963078626536343532643464366336316365653937643388457468657265756d87506f6c79676f6e983078336533366564646436356532333932323265376536379c30786432633632313862383735343537613431623666623739363465a43078313433353533343065383537393132313838623766323032643535303232323438378c033b2e3c9fd0803ce80000009a3078393161343732386235313734383466306636313064653762850218711a00946c449988e2f33302803c93f8287dc1d8cb33848a").unwrap());
272+
273+
274+
}
235275
}

0 commit comments

Comments
 (0)