diff options
author | George Kadianakis <desnacked@riseup.net> | 2013-07-16 14:07:03 +0300 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2013-07-16 14:07:03 +0300 |
commit | 4ccd4b5c51e1c59b921ca4bfcbc010232c076aaa (patch) | |
tree | d71d8dad53ab0f49ece93c4413bff4e0d68b8240 /src/test/test_pt.c | |
parent | fab99844fc324b2c9d415b1b1c192a25cf1c4230 (diff) | |
download | tor-4ccd4b5c51e1c59b921ca4bfcbc010232c076aaa.tar.gz tor-4ccd4b5c51e1c59b921ca4bfcbc010232c076aaa.zip |
Test deeper in test_pt_parsing().
We used to test parse_{c,s}method_line() without actually testing that
the resulting transport_t was well formed.
Diffstat (limited to 'src/test/test_pt.c')
-rw-r--r-- | src/test/test_pt.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/test/test_pt.c b/src/test/test_pt.c index d4cc0ae97b..16daa2836a 100644 --- a/src/test/test_pt.c +++ b/src/test/test_pt.c @@ -22,6 +22,8 @@ static void test_pt_parsing(void) { char line[200]; + transport_t *transport = NULL; + tor_addr_t test_addr; managed_proxy_t *mp = tor_malloc(sizeof(managed_proxy_t)); mp->conf_state = PT_PROTO_INFANT; @@ -48,7 +50,17 @@ test_pt_parsing(void) /* correct line */ strlcpy(line,"CMETHOD trebuchet socks5 127.0.0.1:1999",sizeof(line)); test_assert(parse_cmethod_line(line, mp) == 0); - test_assert(smartlist_len(mp->transports)); + test_assert(smartlist_len(mp->transports) == 1); + transport = smartlist_get(mp->transports, 0); + /* test registered address of transport */ + tor_addr_parse(&test_addr, "127.0.0.1"); + test_assert(tor_addr_eq(&test_addr, &transport->addr)); + /* test registered port of transport */ + test_assert(transport->port == 1999); + /* test registered SOCKS version of transport */ + test_assert(transport->socks_version == PROXY_SOCKS5); + /* test registered name of transport */ + test_streq(transport->name, "trebuchet"); reset_mp(mp); @@ -65,8 +77,17 @@ test_pt_parsing(void) reset_mp(mp); /* cowwect */ - strlcpy(line,"SMETHOD trebuchy 127.0.0.1:1999",sizeof(line)); + strlcpy(line,"SMETHOD trebuchy 127.0.0.2:2999",sizeof(line)); test_assert(parse_smethod_line(line, mp) == 0); + test_assert(smartlist_len(mp->transports) == 1); + transport = smartlist_get(mp->transports, 0); + /* test registered address of transport */ + tor_addr_parse(&test_addr, "127.0.0.2"); + test_assert(tor_addr_eq(&test_addr, &transport->addr)); + /* test registered port of transport */ + test_assert(transport->port == 2999); + /* test registered name of transport */ + test_streq(transport->name, "trebuchy"); reset_mp(mp); |