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

Function postgres_app_data

crates/database/src/app_data.rs:57–83  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

55 #[tokio::test]
56 #[ignore]
57 async fn postgres_app_data() {
58 let mut db = PgConnection::connect("postgresql://").await.unwrap();
59 let mut tx = db.begin().await.unwrap();
60 crate::clear_DANGER_(&mut tx).await.unwrap();
61 tx.commit().await.unwrap();
62
63 let contract = ByteArray([0u8; 32]);
64 // fetch non existant app data
65 let result = fetch(&mut db, &contract).await.unwrap();
66 assert!(result.is_none());
67
68 let full = vec![1u8];
69 let result = insert(&mut db, &contract, &full).await.unwrap();
70 assert_eq!(result, None);
71
72 // now exists
73 let result = fetch(&mut db, &contract).await.unwrap();
74 assert_eq!(result, Some(full.clone()));
75
76 // insert again with same app data
77 let result = insert(&mut db, &contract, &full).await.unwrap();
78 assert_eq!(result, Some(full.clone()));
79
80 // insert again with different app data fails
81 let result = insert(&mut db, &contract, &[4, 2]).await.unwrap();
82 assert_eq!(result, Some(full));
83 }
84}

Callers

nothing calls this directly

Calls 7

connectFunction · 0.85
clear_DANGER_Function · 0.85
ByteArrayClass · 0.85
unwrapMethod · 0.80
commitMethod · 0.80
fetchFunction · 0.70
insertFunction · 0.70

Tested by

no test coverage detected