mirror of
https://gitlab.com/veilid/veilid.git
synced 2024-10-01 01:26:08 -04:00
fix bugs
This commit is contained in:
parent
9bccb59f77
commit
7a1e6f96e6
@ -60,6 +60,7 @@ pub use typed_signature::*;
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[allow(clippy::enum_variant_names)]
|
||||
pub(in crate::rpc_processor) enum QuestionContext {
|
||||
GetValue(ValidateGetValueContext),
|
||||
SetValue(ValidateSetValueContext),
|
||||
|
@ -58,9 +58,10 @@ impl RPCOperationWatchValueQ {
|
||||
count: u32,
|
||||
watch_id: Option<u64>,
|
||||
) -> Vec<u8> {
|
||||
let subkeys_len = subkeys.ranges_len();
|
||||
let subkeys_ranges_len = subkeys.ranges_len();
|
||||
|
||||
let mut sig_data = Vec::with_capacity(PUBLIC_KEY_LENGTH + 4 + (subkeys_len * 8) + 8 + 8);
|
||||
let mut sig_data =
|
||||
Vec::with_capacity(PUBLIC_KEY_LENGTH + 4 + (subkeys_ranges_len * 8) + 8 + 8);
|
||||
sig_data.extend_from_slice(&key.kind.0);
|
||||
sig_data.extend_from_slice(&key.value.bytes);
|
||||
for sk in subkeys.ranges() {
|
||||
|
@ -252,14 +252,14 @@ impl RPCProcessor {
|
||||
log_dht!(debug "{}", debug_string_answer);
|
||||
}
|
||||
|
||||
// Make GetValue answer
|
||||
// Make InspectValue answer
|
||||
let inspect_value_a = RPCOperationInspectValueA::new(
|
||||
inspect_result_seqs,
|
||||
closer_to_key_peers,
|
||||
inspect_result_descriptor.map(|x| (*x).clone()),
|
||||
)?;
|
||||
|
||||
// Send GetValue answer
|
||||
// Send InspectValue answer
|
||||
self.answer(msg, RPCAnswer::new(RPCAnswerDetail::InspectValueA(Box::new(inspect_value_a))))
|
||||
.await
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ impl StorageManager {
|
||||
}
|
||||
|
||||
// If we have a prior seqs list, merge in the new seqs
|
||||
if ctx.seqs.len() == 0 {
|
||||
if ctx.seqs.is_empty() {
|
||||
ctx.seqs = iva.answer.seqs.clone();
|
||||
// One node has shown us the newest sequence numbers so far
|
||||
ctx.value_nodes = vec![next_node];
|
||||
@ -157,7 +157,7 @@ impl StorageManager {
|
||||
let check_done = |_closest_nodes: &[NodeRef]| {
|
||||
// If we have reached sufficient consensus, return done
|
||||
let ctx = context.lock();
|
||||
if ctx.seqs.len() > 0
|
||||
if !ctx.seqs.is_empty()
|
||||
&& ctx.descriptor.is_some()
|
||||
&& ctx.value_nodes.len() >= consensus_count
|
||||
{
|
||||
|
@ -62,10 +62,7 @@ pub async fn test_create_delete_dht_record_simple(api: VeilidAPI) {
|
||||
.unwrap();
|
||||
|
||||
let rec = rc
|
||||
.create_dht_record(
|
||||
DHTSchema::DFLT(DHTSchemaDFLT { o_cnt: 1 }),
|
||||
Some(CRYPTO_KIND_VLD0),
|
||||
)
|
||||
.create_dht_record(DHTSchema::dflt(1).unwrap(), Some(CRYPTO_KIND_VLD0))
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -82,10 +79,7 @@ pub async fn test_get_dht_value_nonexistent(api: VeilidAPI) {
|
||||
.unwrap();
|
||||
|
||||
let rec = rc
|
||||
.create_dht_record(
|
||||
DHTSchema::DFLT(DHTSchemaDFLT { o_cnt: 1 }),
|
||||
Some(CRYPTO_KIND_VLD0),
|
||||
)
|
||||
.create_dht_record(DHTSchema::dflt(1).unwrap(), Some(CRYPTO_KIND_VLD0))
|
||||
.await
|
||||
.unwrap();
|
||||
let dht_key = *rec.key();
|
||||
@ -104,10 +98,7 @@ pub async fn test_set_get_dht_value(api: VeilidAPI) {
|
||||
.unwrap();
|
||||
|
||||
let rec = rc
|
||||
.create_dht_record(
|
||||
DHTSchema::DFLT(DHTSchemaDFLT { o_cnt: 2 }),
|
||||
Some(CRYPTO_KIND_VLD0),
|
||||
)
|
||||
.create_dht_record(DHTSchema::dflt(2).unwrap(), Some(CRYPTO_KIND_VLD0))
|
||||
.await
|
||||
.unwrap();
|
||||
let dht_key = *rec.key();
|
||||
@ -159,10 +150,7 @@ pub async fn test_open_writer_dht_value(api: VeilidAPI) {
|
||||
.unwrap();
|
||||
|
||||
let rec = rc
|
||||
.create_dht_record(
|
||||
DHTSchema::DFLT(DHTSchemaDFLT { o_cnt: 2 }),
|
||||
Some(CRYPTO_KIND_VLD0),
|
||||
)
|
||||
.create_dht_record(DHTSchema::dflt(2).unwrap(), Some(CRYPTO_KIND_VLD0))
|
||||
.await
|
||||
.unwrap();
|
||||
let key = *rec.key();
|
||||
@ -252,10 +240,7 @@ pub async fn test_open_writer_dht_value(api: VeilidAPI) {
|
||||
assert_eq!(rec.key().kind, key.kind);
|
||||
assert_eq!(rec.owner(), owner);
|
||||
assert_eq!(rec.owner_secret().unwrap(), secret);
|
||||
assert!(matches!(
|
||||
rec.schema().clone(),
|
||||
DHTSchema::DFLT(DHTSchemaDFLT { o_cnt: 2 })
|
||||
));
|
||||
assert_eq!(rec.schema(), &DHTSchema::dflt(2).unwrap());
|
||||
|
||||
//Verify subkey 1 can be set before it is get but newer is available online
|
||||
let set_dht_test_value_1_result = rc.set_dht_value(key, 1, test_data_3.clone(), None).await;
|
||||
@ -301,11 +286,7 @@ pub async fn test_open_writer_dht_value(api: VeilidAPI) {
|
||||
assert_eq!(rec.key().kind, key.kind);
|
||||
assert_eq!(rec.owner(), owner);
|
||||
assert_eq!(rec.owner_secret(), None);
|
||||
let schema = rec.schema().clone();
|
||||
assert!(matches!(
|
||||
schema,
|
||||
DHTSchema::DFLT(DHTSchemaDFLT { o_cnt: 2 })
|
||||
));
|
||||
assert_eq!(rec.schema(), &DHTSchema::dflt(2).unwrap());
|
||||
|
||||
// Verify subkey 1 can NOT be set because we have the wrong writer
|
||||
let set_dht_test_value_0_result = rc.set_dht_value(key, 1, test_value_1.clone(), None).await;
|
||||
|
Loading…
Reference in New Issue
Block a user