Merge pull request #2612 from TheBlueMatt/2023-09-namespace-split
[rust-lightning] / lightning / src / util / test_utils.rs
index 50467a1735fd919e179cc9eb63a0eb2eafbea396..18c3db76f18efac38cb0ebf529f42c32b7ef4757 100644 (file)
@@ -441,12 +441,12 @@ impl TestStore {
 }
 
 impl KVStore for TestStore {
-       fn read(&self, namespace: &str, sub_namespace: &str, key: &str) -> io::Result<Vec<u8>> {
+       fn read(&self, primary_namespace: &str, secondary_namespace: &str, key: &str) -> io::Result<Vec<u8>> {
                let persisted_lock = self.persisted_bytes.lock().unwrap();
-               let prefixed = if sub_namespace.is_empty() {
-                       namespace.to_string()
+               let prefixed = if secondary_namespace.is_empty() {
+                       primary_namespace.to_string()
                } else {
-                       format!("{}/{}", namespace, sub_namespace)
+                       format!("{}/{}", primary_namespace, secondary_namespace)
                };
 
                if let Some(outer_ref) = persisted_lock.get(&prefixed) {
@@ -461,7 +461,7 @@ impl KVStore for TestStore {
                }
        }
 
-       fn write(&self, namespace: &str, sub_namespace: &str, key: &str, buf: &[u8]) -> io::Result<()> {
+       fn write(&self, primary_namespace: &str, secondary_namespace: &str, key: &str, buf: &[u8]) -> io::Result<()> {
                if self.read_only {
                        return Err(io::Error::new(
                                io::ErrorKind::PermissionDenied,
@@ -470,10 +470,10 @@ impl KVStore for TestStore {
                }
                let mut persisted_lock = self.persisted_bytes.lock().unwrap();
 
-               let prefixed = if sub_namespace.is_empty() {
-                       namespace.to_string()
+               let prefixed = if secondary_namespace.is_empty() {
+                       primary_namespace.to_string()
                } else {
-                       format!("{}/{}", namespace, sub_namespace)
+                       format!("{}/{}", primary_namespace, secondary_namespace)
                };
                let outer_e = persisted_lock.entry(prefixed).or_insert(HashMap::new());
                let mut bytes = Vec::new();
@@ -482,7 +482,7 @@ impl KVStore for TestStore {
                Ok(())
        }
 
-       fn remove(&self, namespace: &str, sub_namespace: &str, key: &str, _lazy: bool) -> io::Result<()> {
+       fn remove(&self, primary_namespace: &str, secondary_namespace: &str, key: &str, _lazy: bool) -> io::Result<()> {
                if self.read_only {
                        return Err(io::Error::new(
                                io::ErrorKind::PermissionDenied,
@@ -492,10 +492,10 @@ impl KVStore for TestStore {
 
                let mut persisted_lock = self.persisted_bytes.lock().unwrap();
 
-               let prefixed = if sub_namespace.is_empty() {
-                       namespace.to_string()
+               let prefixed = if secondary_namespace.is_empty() {
+                       primary_namespace.to_string()
                } else {
-                       format!("{}/{}", namespace, sub_namespace)
+                       format!("{}/{}", primary_namespace, secondary_namespace)
                };
                if let Some(outer_ref) = persisted_lock.get_mut(&prefixed) {
                                outer_ref.remove(&key.to_string());
@@ -504,13 +504,13 @@ impl KVStore for TestStore {
                Ok(())
        }
 
-       fn list(&self, namespace: &str, sub_namespace: &str) -> io::Result<Vec<String>> {
+       fn list(&self, primary_namespace: &str, secondary_namespace: &str) -> io::Result<Vec<String>> {
                let mut persisted_lock = self.persisted_bytes.lock().unwrap();
 
-               let prefixed = if sub_namespace.is_empty() {
-                       namespace.to_string()
+               let prefixed = if secondary_namespace.is_empty() {
+                       primary_namespace.to_string()
                } else {
-                       format!("{}/{}", namespace, sub_namespace)
+                       format!("{}/{}", primary_namespace, secondary_namespace)
                };
                match persisted_lock.entry(prefixed) {
                        hash_map::Entry::Occupied(e) => Ok(e.get().keys().cloned().collect()),