Skip to content

Commit 9dbaae7

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

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
@@ -1249,10 +1249,8 @@ impl TestSyncStore {
12491249
},
12501250
}
12511251
}
1252-
}
12531252

1254-
impl KVStoreSync for TestSyncStore {
1255-
fn read(
1253+
fn read_internal(
12561254
&self, primary_namespace: &str, secondary_namespace: &str, key: &str,
12571255
) -> lightning::io::Result<Vec<u8>> {
12581256
let _guard = self.serializer.read().unwrap();
@@ -1277,7 +1275,7 @@ impl KVStoreSync for TestSyncStore {
12771275
}
12781276
}
12791277

1280-
fn write(
1278+
fn write_internal(
12811279
&self, primary_namespace: &str, secondary_namespace: &str, key: &str, buf: Vec<u8>,
12821280
) -> lightning::io::Result<()> {
12831281
let _guard = self.serializer.write().unwrap();
@@ -1306,7 +1304,7 @@ impl KVStoreSync for TestSyncStore {
13061304
}
13071305
}
13081306

1309-
fn remove(
1307+
fn remove_internal(
13101308
&self, primary_namespace: &str, secondary_namespace: &str, key: &str, lazy: bool,
13111309
) -> lightning::io::Result<()> {
13121310
let _guard = self.serializer.write().unwrap();
@@ -1334,10 +1332,36 @@ impl KVStoreSync for TestSyncStore {
13341332
}
13351333
}
13361334

1337-
fn list(
1335+
fn list_internal(
13381336
&self, primary_namespace: &str, secondary_namespace: &str,
13391337
) -> lightning::io::Result<Vec<String>> {
13401338
let _guard = self.serializer.read().unwrap();
13411339
self.do_list(primary_namespace, secondary_namespace)
13421340
}
13431341
}
1342+
1343+
impl KVStoreSync for TestSyncStore {
1344+
fn read(
1345+
&self, primary_namespace: &str, secondary_namespace: &str, key: &str,
1346+
) -> lightning::io::Result<Vec<u8>> {
1347+
self.read_internal(primary_namespace, secondary_namespace, key)
1348+
}
1349+
1350+
fn write(
1351+
&self, primary_namespace: &str, secondary_namespace: &str, key: &str, buf: Vec<u8>,
1352+
) -> lightning::io::Result<()> {
1353+
self.write_internal(primary_namespace, secondary_namespace, key, buf)
1354+
}
1355+
1356+
fn remove(
1357+
&self, primary_namespace: &str, secondary_namespace: &str, key: &str, lazy: bool,
1358+
) -> lightning::io::Result<()> {
1359+
self.remove_internal(primary_namespace, secondary_namespace, key, lazy)
1360+
}
1361+
1362+
fn list(
1363+
&self, primary_namespace: &str, secondary_namespace: &str,
1364+
) -> lightning::io::Result<Vec<String>> {
1365+
self.list_internal(primary_namespace, secondary_namespace)
1366+
}
1367+
}

0 commit comments

Comments
 (0)