-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'mve3' into feat/proposal-template-models
# Conflicts: # catalyst-gateway/bin/Cargo.toml
- Loading branch information
Showing
90 changed files
with
2,927 additions
and
779 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//! Signed docs queries | ||
#[cfg(test)] | ||
mod tests; | ||
|
||
use super::EventDB; | ||
|
||
/// Insert sql query | ||
const INSERT_SIGNED_DOCS: &str = include_str!("./sql/insert_signed_documents.sql"); | ||
|
||
/// Make an insert query into the `event-db` by adding data into the `signed_docs` table | ||
/// | ||
/// * IF the record primary key (id,ver) does not exist, then add the new record. Return | ||
/// success. | ||
/// * IF the record does exist, but all values are the same as stored, return Success. | ||
/// * Otherwise return an error. (Can not over-write an existing record with new data). | ||
/// | ||
/// # Arguments: | ||
/// - `id` is a UUID v7 | ||
/// - `ver` is a UUID v7 | ||
/// - `doc_type` is a UUID v4 | ||
#[allow(dead_code)] | ||
pub(crate) async fn insert_signed_docs( | ||
id: &uuid::Uuid, ver: &uuid::Uuid, doc_type: &uuid::Uuid, author: &String, | ||
metadata: &Option<serde_json::Value>, payload: &Option<serde_json::Value>, raw: &Vec<u8>, | ||
) -> anyhow::Result<()> { | ||
EventDB::modify(INSERT_SIGNED_DOCS, &[ | ||
id, ver, doc_type, author, metadata, payload, raw, | ||
]) | ||
.await?; | ||
Ok(()) | ||
} |
12 changes: 12 additions & 0 deletions
12
catalyst-gateway/bin/src/db/event/signed_docs/sql/insert_signed_documents.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
INSERT INTO signed_docs | ||
( | ||
id, | ||
ver, | ||
type, | ||
author, | ||
metadata, | ||
payload, | ||
raw | ||
) | ||
VALUES | ||
($1, $2, $3, $4, $5, $6, $7) |
50 changes: 50 additions & 0 deletions
50
catalyst-gateway/bin/src/db/event/signed_docs/tests/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
//! Integration tests of the `signed docs` queries | ||
use super::*; | ||
use crate::db::event::establish_connection; | ||
|
||
#[ignore = "An integration test which requires a running EventDB instance, disabled from `testunit` CI run"] | ||
#[tokio::test] | ||
async fn some_test() { | ||
establish_connection(); | ||
|
||
let docs = [ | ||
( | ||
uuid::Uuid::now_v7(), | ||
uuid::Uuid::now_v7(), | ||
uuid::Uuid::new_v4(), | ||
"Alex".to_string(), | ||
&Some(serde_json::Value::Null), | ||
&Some(serde_json::Value::Null), | ||
vec![1, 2, 3, 4], | ||
), | ||
( | ||
uuid::Uuid::now_v7(), | ||
uuid::Uuid::now_v7(), | ||
uuid::Uuid::new_v4(), | ||
"Steven".to_string(), | ||
&Some(serde_json::Value::Null), | ||
&Some(serde_json::Value::Null), | ||
vec![5, 6, 7, 8], | ||
), | ||
( | ||
uuid::Uuid::now_v7(), | ||
uuid::Uuid::now_v7(), | ||
uuid::Uuid::new_v4(), | ||
"Sasha".to_string(), | ||
&None, | ||
&None, | ||
vec![9, 10, 11, 12], | ||
), | ||
]; | ||
|
||
for (id, ver, doc_type, author, metadata, payload, raw) in &docs { | ||
insert_signed_docs(id, ver, doc_type, author, metadata, payload, raw) | ||
.await | ||
.unwrap(); | ||
// // try to insert the same data again | ||
// insert_signed_docs(id, ver, doc_type, author, metadata, payload, raw) | ||
// .await | ||
// .unwrap(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.