diff options
author | George Kadianakis <desnacked@riseup.net> | 2018-09-15 16:33:05 +0300 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2018-09-15 16:52:32 +0300 |
commit | b2092f1ced891737d83915f027b6776882d256b5 (patch) | |
tree | 99408c3e39062b725dbbf42430c4f39cf54f0d6b /src/test/test_helpers.c | |
parent | 6069185bcc61fe797582b9b9826a5d52e4aabb22 (diff) | |
download | tor-b2092f1ced891737d83915f027b6776882d256b5.tar.gz tor-b2092f1ced891737d83915f027b6776882d256b5.zip |
Add unittest for HiddenServiceExportCircuitID.
Had to move a function to test helpers.
Diffstat (limited to 'src/test/test_helpers.c')
-rw-r--r-- | src/test/test_helpers.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/test/test_helpers.c b/src/test/test_helpers.c index c9138611d8..a10821956e 100644 --- a/src/test/test_helpers.c +++ b/src/test/test_helpers.c @@ -125,6 +125,25 @@ connection_write_to_buf_mock(const char *string, size_t len, buf_add(conn->outbuf, string, len); } +char * +buf_get_contents(buf_t *buf, size_t *sz_out) +{ + tor_assert(buf); + tor_assert(sz_out); + + char *out; + *sz_out = buf_datalen(buf); + if (*sz_out >= ULONG_MAX) + return NULL; /* C'mon, really? */ + out = tor_malloc(*sz_out + 1); + if (buf_get_bytes(buf, out, (unsigned long)*sz_out) != 0) { + tor_free(out); + return NULL; + } + out[*sz_out] = '\0'; /* Hopefully gratuitous. */ + return out; +} + /* Set up a fake origin circuit with the specified number of cells, * Return a pointer to the newly-created dummy circuit */ circuit_t * |