Skip to content

Commit 399f9cb

Browse files
committed
Move TestStoreSync logic to _internal methods
.. to be easier reusable via `KVStore` also
1 parent 41528da commit 399f9cb

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

tests/common/mod.rs

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,10 +1241,8 @@ impl TestSyncStore {
12411241
},
12421242
}
12431243
}
1244-
}
12451244

1246-
impl KVStoreSync for TestSyncStore {
1247-
fn read(
1245+
fn read_internal(
12481246
&self, primary_namespace: &str, secondary_namespace: &str, key: &str,
12491247
) -> lightning::io::Result<Vec<u8>> {
12501248
let _guard = self.serializer.read().unwrap();
@@ -1269,7 +1267,7 @@ impl KVStoreSync for TestSyncStore {
12691267
}
12701268
}
12711269

1272-
fn write(
1270+
fn write_internal(
12731271
&self, primary_namespace: &str, secondary_namespace: &str, key: &str, buf: Vec<u8>,
12741272
) -> lightning::io::Result<()> {
12751273
let _guard = self.serializer.write().unwrap();
@@ -1298,7 +1296,7 @@ impl KVStoreSync for TestSyncStore {
12981296
}
12991297
}
13001298

1301-
fn remove(
1299+
fn remove_internal(
13021300
&self, primary_namespace: &str, secondary_namespace: &str, key: &str, lazy: bool,
13031301
) -> lightning::io::Result<()> {
13041302
let _guard = self.serializer.write().unwrap();
@@ -1326,10 +1324,36 @@ impl KVStoreSync for TestSyncStore {
13261324
}
13271325
}
13281326

1329-
fn list(
1327+
fn list_internal(
13301328
&self, primary_namespace: &str, secondary_namespace: &str,
13311329
) -> lightning::io::Result<Vec<String>> {
13321330
let _guard = self.serializer.read().unwrap();
13331331
self.do_list(primary_namespace, secondary_namespace)
13341332
}
13351333
}
1334+
1335+
impl KVStoreSync for TestSyncStore {
1336+
fn read(
1337+
&self, primary_namespace: &str, secondary_namespace: &str, key: &str,
1338+
) -> lightning::io::Result<Vec<u8>> {
1339+
self.read_internal(primary_namespace, secondary_namespace, key)
1340+
}
1341+
1342+
fn write(
1343+
&self, primary_namespace: &str, secondary_namespace: &str, key: &str, buf: Vec<u8>,
1344+
) -> lightning::io::Result<()> {
1345+
self.write_internal(primary_namespace, secondary_namespace, key, buf)
1346+
}
1347+
1348+
fn remove(
1349+
&self, primary_namespace: &str, secondary_namespace: &str, key: &str, lazy: bool,
1350+
) -> lightning::io::Result<()> {
1351+
self.remove_internal(primary_namespace, secondary_namespace, key, lazy)
1352+
}
1353+
1354+
fn list(
1355+
&self, primary_namespace: &str, secondary_namespace: &str,
1356+
) -> lightning::io::Result<Vec<String>> {
1357+
self.list_internal(primary_namespace, secondary_namespace)
1358+
}
1359+
}

0 commit comments

Comments
 (0)