Skip to content

Commit c566e73

Browse files
committed
Move TestStoreSync logic to _internal methods
.. to be easier reusable via `KVStore` also
1 parent cc35230 commit c566e73

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
@@ -1242,10 +1242,8 @@ impl TestSyncStore {
12421242
},
12431243
}
12441244
}
1245-
}
12461245

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

1273-
fn write(
1271+
fn write_internal(
12741272
&self, primary_namespace: &str, secondary_namespace: &str, key: &str, buf: Vec<u8>,
12751273
) -> lightning::io::Result<()> {
12761274
let _guard = self.serializer.write().unwrap();
@@ -1299,7 +1297,7 @@ impl KVStoreSync for TestSyncStore {
12991297
}
13001298
}
13011299

1302-
fn remove(
1300+
fn remove_internal(
13031301
&self, primary_namespace: &str, secondary_namespace: &str, key: &str, lazy: bool,
13041302
) -> lightning::io::Result<()> {
13051303
let _guard = self.serializer.write().unwrap();
@@ -1327,10 +1325,36 @@ impl KVStoreSync for TestSyncStore {
13271325
}
13281326
}
13291327

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

0 commit comments

Comments
 (0)