aboutsummaryrefslogtreecommitdiff
path: root/src/or/conscache.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-04-04 13:51:34 -0400
committerNick Mathewson <nickm@torproject.org>2017-04-06 11:48:41 -0400
commit73e9bc914f43b21f3bed5eca5d2fc837cc5aa070 (patch)
treedfcfbe0d59a6d7760c3ec1d8b68bc5308b4755c2 /src/or/conscache.c
parent4404dc5756c929fccc5784a637014aee929bdfd1 (diff)
downloadtor-73e9bc914f43b21f3bed5eca5d2fc837cc5aa070.tar.gz
tor-73e9bc914f43b21f3bed5eca5d2fc837cc5aa070.zip
Tests for simple cases of conscache code.
Diffstat (limited to 'src/or/conscache.c')
-rw-r--r--src/or/conscache.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/or/conscache.c b/src/or/conscache.c
index 4bcf29cecf..2a6e1445e3 100644
--- a/src/or/conscache.c
+++ b/src/or/conscache.c
@@ -485,3 +485,22 @@ consensus_cache_entry_unmap(consensus_cache_entry_t *ent)
ent->unused_since = TIME_MAX;
}
+#ifdef TOR_UNIT_TESTS
+/**
+ * Testing only: Return true iff <b>ent</b> is mapped into memory.
+ *
+ * (In normal operation, this information is not exposed.)
+ */
+int
+consensus_cache_entry_is_mapped(consensus_cache_entry_t *ent)
+{
+ if (ent->map) {
+ tor_assert(ent->body);
+ return 1;
+ } else {
+ tor_assert(!ent->body);
+ return 0;
+ }
+}
+#endif
+