Skip to content

Commit 5a98b7f

Browse files
committed
Move TestStoreSync logic to _internal methods
.. to be easier reusable via `KVStore` also
1 parent 69b9631 commit 5a98b7f

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
@@ -1240,10 +1240,8 @@ impl TestSyncStore {
12401240
},
12411241
}
12421242
}
1243-
}
12441243

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

1271-
fn write(
1269+
fn write_internal(
12721270
&self, primary_namespace: &str, secondary_namespace: &str, key: &str, buf: Vec<u8>,
12731271
) -> lightning::io::Result<()> {
12741272
let _guard = self.serializer.write().unwrap();
@@ -1297,7 +1295,7 @@ impl KVStoreSync for TestSyncStore {
12971295
}
12981296
}
12991297

1300-
fn remove(
1298+
fn remove_internal(
13011299
&self, primary_namespace: &str, secondary_namespace: &str, key: &str, lazy: bool,
13021300
) -> lightning::io::Result<()> {
13031301
let _guard = self.serializer.write().unwrap();
@@ -1325,10 +1323,36 @@ impl KVStoreSync for TestSyncStore {
13251323
}
13261324
}
13271325

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

0 commit comments

Comments
 (0)