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

Function postgres_insert_quote_metadata

crates/database/src/quotes.rs:751–791  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

749 #[tokio::test]
750 #[ignore]
751 async fn postgres_insert_quote_metadata() {
752 let mut db = PgConnection::connect("postgresql://").await.unwrap();
753 let mut db = db.begin().await.unwrap();
754 crate::clear_DANGER_(&mut db).await.unwrap();
755
756 let metadata: serde_json::Value = serde_json::from_str(
757 r#"{ "version":"1.0", "interactions": [ {
758 "target": "0x0102030405060708091011121314151617181920",
759 "value": "1",
760 "callData": "0x0A0B0C102030"
761 },{
762 "target": "0xFF02030405060708091011121314151617181920",
763 "value": "2",
764 "callData": "0xFF0B0C102030"
765 }]
766 }"#,
767 )
768 .unwrap();
769
770 let mut quote = Quote {
771 id: Default::default(),
772 sell_token: ByteArray([1; 20]),
773 buy_token: ByteArray([2; 20]),
774 sell_amount: 3.into(),
775 buy_amount: 4.into(),
776 gas_amount: 5.,
777 gas_price: 6.,
778 sell_token_price: 7.,
779 order_kind: OrderKind::Sell,
780 expiration_timestamp: low_precision_now(),
781 quote_kind: QuoteKind::Standard,
782 solver: ByteArray([1; 20]),
783 verified: false,
784 metadata: metadata.clone(),
785 };
786 // store quote in database
787 let id = save_with_new_id(&mut db, &mut quote).await;
788
789 let stored_quote = get(&mut db, id).await.unwrap().unwrap();
790 assert_eq!(stored_quote.metadata, metadata);
791 }
792}

Callers

nothing calls this directly

Calls 9

clear_DANGER_Function · 0.85
ByteArrayClass · 0.85
low_precision_nowFunction · 0.85
save_with_new_idFunction · 0.85
unwrapMethod · 0.80
getFunction · 0.70
connectFunction · 0.50
intoMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected