WIP for Mikhail

This commit is contained in:
Alexey Proshutinskiy 2021-05-16 23:06:07 +03:00
parent f9c62f2e9a
commit 957bf5ba9f
6 changed files with 16 additions and 13 deletions

15
Cargo.lock generated
View File

@ -482,9 +482,8 @@ dependencies = [
[[package]] [[package]]
name = "fluence-test" name = "fluence-test"
version = "0.1.7" version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/fluencelabs/rust-sdk?branch=separate_struct_module#fd2fc07595c5a037c7267cb848b8ea6eb741c735"
checksum = "7be0d7928e5e6a74a8e303b7f539116fdb4043f5788f78e9eaf32c53700c4c18"
dependencies = [ dependencies = [
"fluence-app-service", "fluence-app-service",
"marine-test-macro", "marine-test-macro",
@ -929,9 +928,8 @@ dependencies = [
[[package]] [[package]]
name = "marine-test-macro" name = "marine-test-macro"
version = "0.1.6" version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/fluencelabs/rust-sdk?branch=separate_struct_module#fd2fc07595c5a037c7267cb848b8ea6eb741c735"
checksum = "709eebc4ee6c8e6aa49066ab066c9f137d9cf164f298f578a67bfb11a0508f65"
dependencies = [ dependencies = [
"marine-test-macro-impl", "marine-test-macro-impl",
"proc-macro-error", "proc-macro-error",
@ -942,9 +940,8 @@ dependencies = [
[[package]] [[package]]
name = "marine-test-macro-impl" name = "marine-test-macro-impl"
version = "0.1.5" version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/fluencelabs/rust-sdk?branch=separate_struct_module#fd2fc07595c5a037c7267cb848b8ea6eb741c735"
checksum = "e2432fd5233a088981c79324668b76f3ee2ae6d313d4522b5490226e5e7827ce"
dependencies = [ dependencies = [
"darling", "darling",
"fluence-app-service", "fluence-app-service",

View File

@ -16,5 +16,5 @@ fstrings = "0.2.3"
eyre = "0.6.5" eyre = "0.6.5"
[dev-dependencies] [dev-dependencies]
fluence-test = "0.1.7" fluence-test = {git ="https://github.com/fluencelabs/rust-sdk", branch = "separate_struct_module"}
rusqlite = "0.25.1" rusqlite = "0.25.1"

View File

@ -176,7 +176,7 @@ pub fn republish_values_impl(key: String, records: Vec<Record>, current_timestam
let _key = get_key_metadata_helper(&connection, key.clone())?; let _key = get_key_metadata_helper(&connection, key.clone())?;
let mut updated = 0u64; let mut updated = 0u64;
for record in records { for record in records.iter() {
connection.execute( connection.execute(
f!("INSERT OR REPLACE INTO {VALUES_TABLE_NAME} \ f!("INSERT OR REPLACE INTO {VALUES_TABLE_NAME} \
VALUES ('{key}', '{record.value}', '{record.peer_id}', '{record.relay_id}',\ VALUES ('{key}', '{record.value}', '{record.peer_id}', '{record.relay_id}',\

View File

@ -82,7 +82,7 @@ pub fn republish_values(key: String, records: Vec<Record>, current_timestamp: u6
pub fn clear_expired(current_timestamp: u64) -> ClearExpiredResult { pub fn clear_expired(current_timestamp: u64) -> ClearExpiredResult {
clear_expired_impl(current_timestamp).into() clear_expired_impl(current_timestamp).into()
} }
//
// #[marine] // #[marine]
// pub fn evict_stale(current_timestamp: u64) -> GetStaleResult { // pub fn evict_stale(current_timestamp: u64) -> GetStaleResult {
// evict_stale_impl(current_timestamp).into() // evict_stale_impl(current_timestamp).into()

View File

@ -226,3 +226,8 @@ impl From<SqliteResult<u64>> for RepublishValuesResult {
} }
} }
} }
// #[marine]
// pub struct EvictStaleResult {
//
// }

View File

@ -162,12 +162,13 @@ mod tests {
#[marine_test(config_path = "../Config.toml", modules_dir = "../artifacts/")] #[marine_test(config_path = "../Config.toml", modules_dir = "../artifacts/")]
fn republish_key_not_exists() { fn republish_key_not_exists() {
clear_db(); clear_db();
let key = __m_generated_aqua_dht::Key { let key = aqua_dht_structs::Key {
key: "some_key".to_string(), key: "some_key".to_string(),
peer_id: "some_peer".to_string(), peer_id: "some_peer".to_string(),
timestamp_created: 0, timestamp_created: 0,
}; };
println!("{:?}", key);
republish_key_and_check!(aqua_dht, key, 123u64, get_correct_timestamp_cp(1)); republish_key_and_check!(aqua_dht, key, 123u64, get_correct_timestamp_cp(1));
} }