diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/bus.c | 6 | ||||
| -rw-r--r-- | tests/device.c | 10 | ||||
| -rw-r--r-- | tests/pair1.c | 89 | ||||
| -rw-r--r-- | tests/pipeline.c | 23 | ||||
| -rw-r--r-- | tests/pollfd.c | 34 | ||||
| -rw-r--r-- | tests/pubsub.c | 29 | ||||
| -rw-r--r-- | tests/reconnect.c | 4 | ||||
| -rw-r--r-- | tests/reqrep.c | 25 | ||||
| -rw-r--r-- | tests/scalability.c | 8 | ||||
| -rw-r--r-- | tests/sock.c | 168 | ||||
| -rw-r--r-- | tests/survey.c | 24 | ||||
| -rw-r--r-- | tests/trantest.h | 4 | ||||
| -rw-r--r-- | tests/zt.c | 36 |
13 files changed, 195 insertions, 265 deletions
diff --git a/tests/bus.c b/tests/bus.c index c38f8c5a..3cf785d9 100644 --- a/tests/bus.c +++ b/tests/bus.c @@ -57,9 +57,9 @@ TestMain("BUS pattern", { So(nng_dial(bus3, addr, NULL, 0) == 0); rtimeo = 50000; - So(nng_setopt_usec(bus1, nng_optid_recvtimeo, rtimeo) == 0); - So(nng_setopt_usec(bus2, nng_optid_recvtimeo, rtimeo) == 0); - So(nng_setopt_usec(bus3, nng_optid_recvtimeo, rtimeo) == 0); + So(nng_setopt_usec(bus1, NNG_OPT_RECVTIMEO, rtimeo) == 0); + So(nng_setopt_usec(bus2, NNG_OPT_RECVTIMEO, rtimeo) == 0); + So(nng_setopt_usec(bus3, NNG_OPT_RECVTIMEO, rtimeo) == 0); Convey("Messages delivered", { nng_msg *msg; diff --git a/tests/device.c b/tests/device.c index d3407eab..d1e08449 100644 --- a/tests/device.c +++ b/tests/device.c @@ -49,8 +49,8 @@ Main({ So(nng_pair1_open(&dev1) == 0); So(nng_pair1_open(&dev2) == 0); - So(nng_setopt_int(dev1, nng_optid_raw, 1) == 0); - So(nng_setopt_int(dev2, nng_optid_raw, 1) == 0); + So(nng_setopt_int(dev1, NNG_OPT_RAW, 1) == 0); + So(nng_setopt_int(dev2, NNG_OPT_RAW, 1) == 0); struct dev_data ddata; ddata.s1 = dev1; @@ -73,10 +73,8 @@ Main({ So(nng_dial(end2, addr2, NULL, 0) == 0); tmo = 1000000; - So(nng_setopt_usec(end1, nng_optid_recvtimeo, tmo) == - 0); - So(nng_setopt_usec(end2, nng_optid_recvtimeo, tmo) == - 0); + So(nng_setopt_usec(end1, NNG_OPT_RECVTIMEO, tmo) == 0); + So(nng_setopt_usec(end2, NNG_OPT_RECVTIMEO, tmo) == 0); nng_usleep(100000); Convey("Device can send and receive", { diff --git a/tests/pair1.c b/tests/pair1.c index ba13d494..c82dd5cb 100644 --- a/tests/pair1.c +++ b/tests/pair1.c @@ -14,7 +14,6 @@ #include <string.h> -extern int nng_optid_pair1_poly; extern const char *nng_opt_pair1_poly; #define APPENDSTR(m, s) nng_msg_append(m, s, strlen(s)) @@ -47,25 +46,13 @@ TestMain("PAIRv1 protocol", { }); tmo = 300000; - So(nng_setopt_usec(s1, nng_optid_recvtimeo, tmo) == 0); - So(nng_setopt_usec(c1, nng_optid_recvtimeo, tmo) == 0); - So(nng_setopt_usec(c2, nng_optid_recvtimeo, tmo) == 0); + So(nng_setopt_usec(s1, NNG_OPT_RECVTIMEO, tmo) == 0); + So(nng_setopt_usec(c1, NNG_OPT_RECVTIMEO, tmo) == 0); + So(nng_setopt_usec(c2, NNG_OPT_RECVTIMEO, tmo) == 0); tmo = 0; - So(nng_getopt_usec(s1, nng_optid_recvtimeo, &tmo) == 0); + So(nng_getopt_usec(s1, NNG_OPT_RECVTIMEO, &tmo) == 0); So(tmo == 300000); - Convey("Polyamorous option id works", { - // This test has to be done after polyamorous mode - // is registered! - int poly; - poly = nng_option_lookup(nng_opt_pair1_poly); - So(poly >= 0); - So(poly == nng_optid_pair1_poly); - So(nng_option_name(poly) != 0); - So(strcmp(nng_option_name(poly), nng_opt_pair1_poly) == - 0); - }); - Convey("Monogamous cooked mode works", { nng_msg *msg; @@ -114,8 +101,8 @@ TestMain("PAIRv1 protocol", { So(nng_dial(c1, addr, NULL, 0) == 0); nng_usleep(100000); - So(nng_setopt_int(s1, nng_optid_raw, 1) == NNG_ESTATE); - So(nng_setopt_int(c1, nng_optid_raw, 1) == NNG_ESTATE); + So(nng_setopt_int(s1, NNG_OPT_RAW, 1) == NNG_ESTATE); + So(nng_setopt_int(c1, NNG_OPT_RAW, 1) == NNG_ESTATE); }); Convey("Polyamorous mode is best effort", { @@ -123,12 +110,12 @@ TestMain("PAIRv1 protocol", { int i; nng_msg *msg; - So(nng_setopt_int(s1, nng_optid_pair1_poly, 1) == 0); + So(nng_setopt_int(s1, nng_opt_pair1_poly, 1) == 0); - So(nng_setopt_int(s1, nng_optid_recvbuf, 1) == 0); - So(nng_setopt_int(s1, nng_optid_sendbuf, 1) == 0); - So(nng_setopt_int(c1, nng_optid_recvbuf, 1) == 0); - So(nng_setopt_usec(s1, nng_optid_sendtimeo, 100000) == + So(nng_setopt_int(s1, NNG_OPT_RECVBUF, 1) == 0); + So(nng_setopt_int(s1, NNG_OPT_SENDBUF, 1) == 0); + So(nng_setopt_int(c1, NNG_OPT_RECVBUF, 1) == 0); + So(nng_setopt_usec(s1, NNG_OPT_SENDTIMEO, 100000) == 0); So(nng_listen(s1, addr, NULL, 0) == 0); @@ -151,11 +138,10 @@ TestMain("PAIRv1 protocol", { int rv; nng_msg *msg; - So(nng_setopt_int(s1, nng_optid_recvbuf, 1) == 0); - So(nng_setopt_int(s1, nng_optid_sendbuf, 1) == 0); - So(nng_setopt_int(c1, nng_optid_recvbuf, 1) == 0); - So(nng_setopt_usec(s1, nng_optid_sendtimeo, 30000) == - 0); + So(nng_setopt_int(s1, NNG_OPT_RECVBUF, 1) == 0); + So(nng_setopt_int(s1, NNG_OPT_SENDBUF, 1) == 0); + So(nng_setopt_int(c1, NNG_OPT_RECVBUF, 1) == 0); + So(nng_setopt_usec(s1, NNG_OPT_SENDTIMEO, 30000) == 0); So(nng_listen(s1, addr, NULL, 0) == 0); So(nng_dial(c1, addr, NULL, 0) == 0); @@ -179,7 +165,7 @@ TestMain("PAIRv1 protocol", { So(nng_dial(c1, addr, NULL, 0) == 0); nng_usleep(100000); - So(nng_setopt_int(s1, nng_optid_pair1_poly, 1) == + So(nng_setopt_int(s1, nng_opt_pair1_poly, 1) == NNG_ESTATE); }); @@ -187,9 +173,9 @@ TestMain("PAIRv1 protocol", { nng_msg *msg; uint32_t hops; - So(nng_setopt_int(s1, nng_optid_raw, 1) == 0); - So(nng_setopt_int(c1, nng_optid_raw, 1) == 0); - So(nng_setopt_int(c2, nng_optid_raw, 1) == 0); + So(nng_setopt_int(s1, NNG_OPT_RAW, 1) == 0); + So(nng_setopt_int(c1, NNG_OPT_RAW, 1) == 0); + So(nng_setopt_int(c2, NNG_OPT_RAW, 1) == 0); So(nng_listen(s1, addr, NULL, 0) == 0); So(nng_dial(c1, addr, NULL, 0) == 0); @@ -267,10 +253,9 @@ TestMain("PAIRv1 protocol", { Convey("TTL is honored", { int ttl; - So(nng_setopt_int(s1, nng_optid_maxttl, 4) == + So(nng_setopt_int(s1, NNG_OPT_MAXTTL, 4) == 0); + So(nng_getopt_int(s1, NNG_OPT_MAXTTL, &ttl) == 0); - So(nng_getopt_int( - s1, nng_optid_maxttl, &ttl) == 0); So(ttl == 4); Convey("Bad TTL bounces", { So(nng_msg_alloc(&msg, 0) == 0); @@ -298,8 +283,8 @@ TestMain("PAIRv1 protocol", { Convey("Large TTL passes", { ttl = 0xff; - So(nng_setopt_int(s1, nng_optid_maxttl, - 0xff) == 0); + So(nng_setopt_int( + s1, NNG_OPT_MAXTTL, 0xff) == 0); So(nng_msg_alloc(&msg, 0) == 0); So(nng_msg_append_u32(msg, 1234) == 0); So(nng_msg_header_append_u32( @@ -316,8 +301,8 @@ TestMain("PAIRv1 protocol", { Convey("Max TTL fails", { ttl = 0xff; - So(nng_setopt_int(s1, nng_optid_maxttl, - 0xff) == 0); + So(nng_setopt_int( + s1, NNG_OPT_MAXTTL, 0xff) == 0); So(nng_msg_alloc(&msg, 0) == 0); So(nng_msg_header_append_u32( msg, 0xff) == 0); @@ -332,15 +317,15 @@ TestMain("PAIRv1 protocol", { int ttl; ttl = 0; - So(nng_setopt_int(s1, nng_optid_maxttl, 0) == + So(nng_setopt_int(s1, NNG_OPT_MAXTTL, 0) == NNG_EINVAL); - So(nng_setopt_int(s1, nng_optid_maxttl, 1000) == + So(nng_setopt_int(s1, NNG_OPT_MAXTTL, 1000) == NNG_EINVAL); sz = 1; ttl = 8; - So(nng_setopt(s1, nng_optid_maxttl, &ttl, sz) == + So(nng_setopt(s1, NNG_OPT_MAXTTL, &ttl, sz) == NNG_EINVAL); }); @@ -350,11 +335,11 @@ TestMain("PAIRv1 protocol", { nng_pipe p1; nng_pipe p2; - So(nng_getopt_int(s1, nng_optid_pair1_poly, &v) == 0); + So(nng_getopt_int(s1, nng_opt_pair1_poly, &v) == 0); So(v == 0); - So(nng_setopt_int(s1, nng_optid_pair1_poly, 1) == 0); - So(nng_getopt_int(s1, nng_optid_pair1_poly, &v) == 0); + So(nng_setopt_int(s1, nng_opt_pair1_poly, 1) == 0); + So(nng_getopt_int(s1, nng_opt_pair1_poly, &v) == 0); So(v == 1); So(nng_listen(s1, addr, NULL, 0) == 0); @@ -411,7 +396,7 @@ TestMain("PAIRv1 protocol", { Convey("Polyamorous default works", { nng_msg *msg; - So(nng_setopt_int(s1, nng_optid_pair1_poly, 1) == 0); + So(nng_setopt_int(s1, nng_opt_pair1_poly, 1) == 0); So(nng_listen(s1, addr, NULL, 0) == 0); So(nng_dial(c1, addr, NULL, 0) == 0); @@ -444,16 +429,16 @@ TestMain("PAIRv1 protocol", { nng_pipe p1; nng_pipe p2; - So(nng_getopt_int(s1, nng_optid_pair1_poly, &v) == 0); + So(nng_getopt_int(s1, nng_opt_pair1_poly, &v) == 0); So(v == 0); - So(nng_setopt_int(s1, nng_optid_pair1_poly, 1) == 0); - So(nng_getopt_int(s1, nng_optid_pair1_poly, &v) == 0); + So(nng_setopt_int(s1, nng_opt_pair1_poly, 1) == 0); + So(nng_getopt_int(s1, nng_opt_pair1_poly, &v) == 0); So(v == 1); v = 0; - So(nng_setopt_int(s1, nng_optid_raw, 1) == 0); - So(nng_getopt_int(s1, nng_optid_raw, &v) == 0); + So(nng_setopt_int(s1, NNG_OPT_RAW, 1) == 0); + So(nng_getopt_int(s1, NNG_OPT_RAW, &v) == 0); So(v == 1); So(nng_listen(s1, addr, NULL, 0) == 0); diff --git a/tests/pipeline.c b/tests/pipeline.c index 618b7227..c7ac2dd0 100644 --- a/tests/pipeline.c +++ b/tests/pipeline.c @@ -1,5 +1,6 @@ // // Copyright 2017 Garrett D'Amore <garrett@damore.org> +// Copyright 2017 Capitar IT Group BV <info@capitar.com> // // This software is supplied under the terms of the MIT License, a // copy of which should be located in the distribution where this @@ -122,14 +123,14 @@ TestMain("PIPELINE (PUSH/PULL) pattern", { // back during load balancing. Adding a small buffer // ensures that we can write to each stream, even if // the listeners are not running yet. - So(nng_setopt_int(push, nng_optid_recvbuf, 4) == 0); - So(nng_setopt_int(push, nng_optid_sendbuf, 4) == 0); - So(nng_setopt_int(pull1, nng_optid_recvbuf, 4) == 0); - So(nng_setopt_int(pull1, nng_optid_sendbuf, 4) == 0); - So(nng_setopt_int(pull2, nng_optid_recvbuf, 4) == 0); - So(nng_setopt_int(pull2, nng_optid_sendbuf, 4) == 0); - So(nng_setopt_int(pull3, nng_optid_recvbuf, 4) == 0); - So(nng_setopt_int(pull3, nng_optid_sendbuf, 4) == 0); + So(nng_setopt_int(push, NNG_OPT_RECVBUF, 4) == 0); + So(nng_setopt_int(push, NNG_OPT_SENDBUF, 4) == 0); + So(nng_setopt_int(pull1, NNG_OPT_RECVBUF, 4) == 0); + So(nng_setopt_int(pull1, NNG_OPT_SENDBUF, 4) == 0); + So(nng_setopt_int(pull2, NNG_OPT_RECVBUF, 4) == 0); + So(nng_setopt_int(pull2, NNG_OPT_SENDBUF, 4) == 0); + So(nng_setopt_int(pull3, NNG_OPT_RECVBUF, 4) == 0); + So(nng_setopt_int(pull3, NNG_OPT_SENDBUF, 4) == 0); So(nng_msg_alloc(&abc, 0) == 0); APPENDSTR(abc, "abc"); @@ -137,9 +138,9 @@ TestMain("PIPELINE (PUSH/PULL) pattern", { APPENDSTR(def, "def"); usecs = 100000; - So(nng_setopt_usec(pull1, nng_optid_recvtimeo, usecs) == 0); - So(nng_setopt_usec(pull2, nng_optid_recvtimeo, usecs) == 0); - So(nng_setopt_usec(pull3, nng_optid_recvtimeo, usecs) == 0); + So(nng_setopt_usec(pull1, NNG_OPT_RECVTIMEO, usecs) == 0); + So(nng_setopt_usec(pull2, NNG_OPT_RECVTIMEO, usecs) == 0); + So(nng_setopt_usec(pull3, NNG_OPT_RECVTIMEO, usecs) == 0); So(nng_listen(push, addr, NULL, 0) == 0); So(nng_dial(pull1, addr, NULL, 0) == 0); So(nng_dial(pull2, addr, NULL, 0) == 0); diff --git a/tests/pollfd.c b/tests/pollfd.c index 6cf712f1..e5130f57 100644 --- a/tests/pollfd.c +++ b/tests/pollfd.c @@ -34,24 +34,6 @@ TestMain("Poll FDs", { - Convey("Option values work", { - int opt; - const char *name; - - opt = nng_option_lookup(nng_opt_recvfd); - So(opt > 0); - So(opt == nng_optid_recvfd); - name = nng_option_name(opt); - So(name != NULL); - So(strcmp(name, nng_opt_recvfd) == 0); - opt = nng_option_lookup(nng_opt_sendfd); - So(opt > 0); - So(opt == nng_optid_sendfd); - name = nng_option_name(opt); - So(name != NULL); - So(strcmp(name, nng_opt_sendfd) == 0); - }); - Convey("Given a connected pair of sockets", { nng_socket s1; nng_socket s2; @@ -73,14 +55,14 @@ TestMain("Poll FDs", { size_t sz; sz = sizeof(fd); - So(nng_getopt(s1, nng_optid_recvfd, &fd, &sz) == 0); + So(nng_getopt(s1, NNG_OPT_RECVFD, &fd, &sz) == 0); So(fd != INVALID_SOCKET); Convey("And it is always the same fd", { int fd2; sz = sizeof(fd2); - So(nng_getopt( - s1, nng_optid_recvfd, &fd2, &sz) == 0); + So(nng_getopt(s1, NNG_OPT_RECVFD, &fd2, &sz) == + 0); So(fd2 == fd); }); @@ -111,7 +93,7 @@ TestMain("Poll FDs", { size_t sz; sz = sizeof(fd); - So(nng_getopt(s1, nng_optid_sendfd, &fd, &sz) == 0); + So(nng_getopt(s1, NNG_OPT_SENDFD, &fd, &sz) == 0); So(fd != INVALID_SOCKET); So(nng_send(s1, "oops", 4, 0) == 0); }); @@ -120,10 +102,10 @@ TestMain("Poll FDs", { int fd; size_t sz; sz = 1; - So(nng_getopt(s1, nng_optid_recvfd, &fd, &sz) == + So(nng_getopt(s1, NNG_OPT_RECVFD, &fd, &sz) == NNG_EINVAL); sz = 128; - So(nng_getopt(s1, nng_optid_recvfd, &fd, &sz) == 0); + So(nng_getopt(s1, NNG_OPT_RECVFD, &fd, &sz) == 0); So(sz == sizeof(fd)); }); Convey("We cannot get a send FD for PULL", { @@ -133,7 +115,7 @@ TestMain("Poll FDs", { So(nng_pull_open(&s3) == 0); Reset({ nng_close(s3); }); sz = sizeof(fd); - So(nng_getopt(s3, nng_optid_sendfd, &fd, &sz) == + So(nng_getopt(s3, NNG_OPT_SENDFD, &fd, &sz) == NNG_ENOTSUP); }); @@ -144,7 +126,7 @@ TestMain("Poll FDs", { So(nng_push_open(&s3) == 0); Reset({ nng_close(s3); }); sz = sizeof(fd); - So(nng_getopt(s3, nng_optid_recvfd, &fd, &sz) == + So(nng_getopt(s3, NNG_OPT_RECVFD, &fd, &sz) == NNG_ENOTSUP); }); }); diff --git a/tests/pubsub.c b/tests/pubsub.c index 3bdd8f8c..0c59f10e 100644 --- a/tests/pubsub.c +++ b/tests/pubsub.c @@ -84,34 +84,33 @@ TestMain("PUB/SUB pattern", { nng_usleep(20000); // give time for connecting threads Convey("Sub can subscribe", { - So(nng_setopt( - sub, nng_optid_sub_subscribe, "ABC", 3) == 0); - So(nng_setopt(sub, nng_optid_sub_subscribe, "", 0) == + So(nng_setopt(sub, NNG_OPT_SUB_SUBSCRIBE, "ABC", 3) == 0); + So(nng_setopt(sub, NNG_OPT_SUB_SUBSCRIBE, "", 0) == 0); Convey("Unsubscribe works", { - So(nng_setopt(sub, nng_optid_sub_unsubscribe, + So(nng_setopt(sub, NNG_OPT_SUB_UNSUBSCRIBE, "ABC", 3) == 0); - So(nng_setopt(sub, nng_optid_sub_unsubscribe, - "", 0) == 0); + So(nng_setopt(sub, NNG_OPT_SUB_UNSUBSCRIBE, "", + 0) == 0); - So(nng_setopt(sub, nng_optid_sub_unsubscribe, - "", 0) == NNG_ENOENT); - So(nng_setopt(sub, nng_optid_sub_unsubscribe, + So(nng_setopt(sub, NNG_OPT_SUB_UNSUBSCRIBE, "", + 0) == NNG_ENOENT); + So(nng_setopt(sub, NNG_OPT_SUB_UNSUBSCRIBE, "HELLO", 0) == NNG_ENOENT); }); }); Convey("Pub cannot subscribe", { - So(nng_setopt(pub, nng_optid_sub_subscribe, "", 0) == + So(nng_setopt(pub, NNG_OPT_SUB_SUBSCRIBE, "", 0) == NNG_ENOTSUP); }); Convey("Subs can receive from pubs", { nng_msg *msg; - So(nng_setopt(sub, nng_optid_sub_subscribe, "/some/", + So(nng_setopt(sub, NNG_OPT_SUB_SUBSCRIBE, "/some/", strlen("/some/")) == 0); - So(nng_setopt_usec(sub, nng_optid_recvtimeo, 90000) == + So(nng_setopt_usec(sub, NNG_OPT_RECVTIMEO, 90000) == 0); So(nng_msg_alloc(&msg, 0) == 0); @@ -141,7 +140,7 @@ TestMain("PUB/SUB pattern", { Convey("Subs without subsciptions don't receive", { nng_msg *msg; - So(nng_setopt_usec(sub, nng_optid_recvtimeo, 90000) == + So(nng_setopt_usec(sub, NNG_OPT_RECVTIMEO, 90000) == 0); So(nng_msg_alloc(&msg, 0) == 0); @@ -154,9 +153,9 @@ TestMain("PUB/SUB pattern", { nng_msg *msg; - So(nng_setopt_usec(sub, nng_optid_recvtimeo, 90000) == + So(nng_setopt_usec(sub, NNG_OPT_RECVTIMEO, 90000) == 0); - So(nng_setopt_int(sub, nng_optid_raw, 1) == 0); + So(nng_setopt_int(sub, NNG_OPT_RAW, 1) == 0); So(nng_msg_alloc(&msg, 0) == 0); APPENDSTR(msg, "/some/like/it/raw"); diff --git a/tests/reconnect.c b/tests/reconnect.c index 292f5d90..4c5ff645 100644 --- a/tests/reconnect.c +++ b/tests/reconnect.c @@ -32,8 +32,8 @@ TestMain("Reconnect works", { nng_close(pull); }); - So(nng_setopt_usec(pull, nng_optid_reconnmint, 10000) == 0); - So(nng_setopt_usec(pull, nng_optid_reconnmaxt, 10000) == 0); + So(nng_setopt_usec(pull, NNG_OPT_RECONNMINT, 10000) == 0); + So(nng_setopt_usec(pull, NNG_OPT_RECONNMAXT, 10000) == 0); Convey("Dialing before listening works", { So(nng_dial(push, addr, NULL, NNG_FLAG_NONBLOCK) == 0); diff --git a/tests/reqrep.c b/tests/reqrep.c index 537d45c8..c31f0212 100644 --- a/tests/reqrep.c +++ b/tests/reqrep.c @@ -13,9 +13,6 @@ #include <string.h> -extern const char *nng_opt_req_resendtime; -extern int nng_optid_req_resendtime; - TestMain("REQ/REP pattern", { int rv; const char *addr = "inproc://test"; @@ -32,19 +29,13 @@ TestMain("REQ/REP pattern", { }); Convey("Resend time option id works", { - int opt; - const char *name; - opt = nng_option_lookup(nng_opt_req_resendtime); - So(opt >= 0); - So(opt == nng_optid_req_resendtime); - name = nng_option_name(opt); - So(name != NULL); - So(strcmp(name, nng_opt_req_resendtime) == 0); // Set timeout. - So(nng_setopt_usec(req, opt, 10000) == 0); + So(nng_setopt_usec( + req, NNG_OPT_REQ_RESENDTIME, 10000) == 0); // Check invalid size - So(nng_setopt(req, opt, name, 1) == NNG_EINVAL); + So(nng_setopt(req, NNG_OPT_REQ_RESENDTIME, "", 1) == + NNG_EINVAL); }); Convey("Recv with no send fails", { @@ -75,8 +66,8 @@ TestMain("REQ/REP pattern", { }); Convey("Cannot set resend time", { - So(nng_setopt_usec(rep, nng_optid_req_resendtime, - 100) == NNG_ENOTSUP); + So(nng_setopt_usec(rep, NNG_OPT_REQ_RESENDTIME, 100) == + NNG_ENOTSUP); }); }); @@ -140,8 +131,8 @@ TestMain("REQ/REP pattern", { nng_close(req); }); - So(nng_setopt_usec(req, nng_optid_req_resendtime, retry) == 0); - So(nng_setopt_int(req, nng_optid_sendbuf, 16) == 0); + So(nng_setopt_usec(req, NNG_OPT_REQ_RESENDTIME, retry) == 0); + So(nng_setopt_int(req, NNG_OPT_SENDBUF, 16) == 0); So(nng_msg_alloc(&abc, 0) == 0); So(nng_msg_append(abc, "abc", 4) == 0); diff --git a/tests/scalability.c b/tests/scalability.c index 4b467b67..22b66d10 100644 --- a/tests/scalability.c +++ b/tests/scalability.c @@ -55,8 +55,8 @@ openclients(nng_socket *clients, int num) t = 100000; // 100ms nng_socket c; if (((rv = nng_req_open(&c)) != 0) || - ((rv = nng_setopt_usec(c, nng_optid_recvtimeo, t)) != 0) || - ((rv = nng_setopt_usec(c, nng_optid_sendtimeo, t)) != 0) || + ((rv = nng_setopt_usec(c, NNG_OPT_RECVTIMEO, t)) != 0) || + ((rv = nng_setopt_usec(c, NNG_OPT_SENDTIMEO, t)) != 0) || ((rv = nng_dial(c, addr, NULL, 0)) != 0)) { return (rv); } @@ -97,8 +97,8 @@ Main({ results = calloc(nclients, sizeof(int)); if ((nng_rep_open(&rep) != 0) || - (nng_setopt_int(rep, nng_optid_recvbuf, 256) != 0) || - (nng_setopt_int(rep, nng_optid_sendbuf, 256) != 0) || + (nng_setopt_int(rep, NNG_OPT_RECVBUF, 256) != 0) || + (nng_setopt_int(rep, NNG_OPT_SENDBUF, 256) != 0) || (nng_listen(rep, addr, NULL, 0) != 0) || (nng_thread_create(&server, serve, NULL) != 0)) { fprintf(stderr, "Unable to set up server!\n"); diff --git a/tests/sock.c b/tests/sock.c index 6c911250..ca125214 100644 --- a/tests/sock.c +++ b/tests/sock.c @@ -64,7 +64,7 @@ TestMain("Socket Operations", { now = nng_clock(); So(now > 0); - So(nng_setopt_usec(s1, nng_optid_recvtimeo, to) == 0); + So(nng_setopt_usec(s1, NNG_OPT_RECVTIMEO, to) == 0); So(nng_recvmsg(s1, &msg, 0) == NNG_ETIMEDOUT); So(msg == NULL); So(nng_clock() >= (now + to)); @@ -88,7 +88,7 @@ TestMain("Socket Operations", { So(msg != NULL); now = nng_clock(); - So(nng_setopt_usec(s1, nng_optid_sendtimeo, to) == 0); + So(nng_setopt_usec(s1, NNG_OPT_SENDTIMEO, to) == 0); So(nng_sendmsg(s1, msg, 0) == NNG_ETIMEDOUT); So(nng_clock() >= (now + to)); So(nng_clock() < (now + (to * 2))); @@ -100,17 +100,15 @@ TestMain("Socket Operations", { int64_t v = 0; size_t sz; - So(nng_setopt_usec(s1, nng_optid_sendtimeo, to) == 0); + So(nng_setopt_usec(s1, NNG_OPT_SENDTIMEO, to) == 0); Convey("Read only options handled properly", { - So(nng_setopt_int(s1, nng_optid_recvfd, 0) == - NNG_EINVAL); - So(nng_setopt_int(s1, nng_optid_sendfd, 0) == - NNG_EINVAL); - So(nng_setopt(s1, nng_optid_locaddr, "a", 1) == - NNG_EINVAL); - So(nng_setopt(s1, nng_optid_remaddr, "a", 1) == - NNG_EINVAL); + So(nng_setopt_int(s1, NNG_OPT_RECVFD, 0) == + NNG_EREADONLY); + So(nng_setopt_int(s1, NNG_OPT_SENDFD, 0) == + NNG_EREADONLY); + So(nng_setopt(s1, NNG_OPT_LOCADDR, "a", 1) == + NNG_EREADONLY); }); Convey("URL option works", { @@ -126,17 +124,21 @@ TestMain("Socket Operations", { memset(url, 0, sizeof(url)); sz = sizeof(url); So(nng_listener_getopt( - l, nng_optid_url, url, &sz) == 0); + l, NNG_OPT_URL, url, &sz) == 0); So(strcmp(url, "inproc://url1") == 0); + So(nng_listener_setopt(l, NNG_OPT_URL, url, + sz) == NNG_EREADONLY); sz = sizeof(url); So(nng_dialer_getopt( - d, nng_optid_url, url, &sz) == 0); + d, NNG_OPT_URL, url, &sz) == 0); So(strcmp(url, "inproc://url2") == 0); + So(nng_dialer_setopt(d, NNG_OPT_URL, url, + sz) == NNG_EREADONLY); Reset({ nng_dialer_close(d); nng_listener_close(l); - }) + }); }); Convey("We can apply options before endpoint", { @@ -146,52 +148,52 @@ TestMain("Socket Operations", { addr, "ipc:///tmp/lopt_%u"); So(nng_setopt_size( - s1, nng_optid_recvmaxsz, 543) == 0); + s1, NNG_OPT_RECVMAXSZ, 543) == 0); So(nng_listener_create(&l, s1, addr) == 0); So(nng_listener_getopt_size( - l, nng_optid_recvmaxsz, &sz) == 0); + l, NNG_OPT_RECVMAXSZ, &sz) == 0); So(sz == 543); Convey("Endpoint option can be overridden", { So(nng_listener_setopt_size(l, - nng_optid_recvmaxsz, 678) == 0); + NNG_OPT_RECVMAXSZ, 678) == 0); So(nng_listener_getopt_size(l, - nng_optid_recvmaxsz, &sz) == 0); + NNG_OPT_RECVMAXSZ, &sz) == 0); So(sz == 678); So(nng_getopt_size(s1, - nng_optid_recvmaxsz, &sz) == 0); + NNG_OPT_RECVMAXSZ, &sz) == 0); So(sz == 543); }); Convey("And socket overrides again", { So(nng_setopt_size(s1, - nng_optid_recvmaxsz, 911) == 0); + NNG_OPT_RECVMAXSZ, 911) == 0); So(nng_listener_getopt_size(l, - nng_optid_recvmaxsz, &sz) == 0); + NNG_OPT_RECVMAXSZ, &sz) == 0); So(sz == 911); }); }); Convey("Short size is not copied", { sz = 0; So(nng_getopt( - s1, nng_optid_sendtimeo, &v, &sz) == 0); + s1, NNG_OPT_SENDTIMEO, &v, &sz) == 0); So(sz == sizeof(v)); So(v == 0); sz = 0; - So(nng_getopt(s1, nng_optid_reconnmint, &v, - &sz) == 0); + So(nng_getopt( + s1, NNG_OPT_RECONNMINT, &v, &sz) == 0); So(v == 0); sz = 0; - So(nng_getopt(s1, nng_optid_reconnmaxt, &v, - &sz) == 0); + So(nng_getopt( + s1, NNG_OPT_RECONNMAXT, &v, &sz) == 0); So(v == 0); }); Convey("Correct size is copied", { sz = sizeof(v); So(nng_getopt( - s1, nng_optid_sendtimeo, &v, &sz) == 0); + s1, NNG_OPT_SENDTIMEO, &v, &sz) == 0); So(sz == sizeof(v)); So(v == 1234); }); @@ -199,47 +201,47 @@ TestMain("Socket Operations", { Convey("Short size buf is not copied", { int l = 5; sz = 0; - So(nng_getopt( - s1, nng_optid_recvbuf, &l, &sz) == 0); + So(nng_getopt(s1, NNG_OPT_RECVBUF, &l, &sz) == + 0); So(sz == sizeof(l)); So(l == 5); }); Convey("Insane buffer size fails", { - So(nng_setopt_int(s1, nng_optid_recvbuf, + So(nng_setopt_int(s1, NNG_OPT_RECVBUF, 0x100000) == NNG_EINVAL); - So(nng_setopt_int(s1, nng_optid_recvbuf, - -200) == NNG_EINVAL); + So(nng_setopt_int(s1, NNG_OPT_RECVBUF, -200) == + NNG_EINVAL); }); Convey("Negative timeout fails", { - So(nng_setopt_usec(s1, nng_optid_recvtimeo, + So(nng_setopt_usec(s1, NNG_OPT_RECVTIMEO, -5) == NNG_EINVAL); }); Convey("Short timeout fails", { to = 0; sz = sizeof(to) - 1; - So(nng_setopt(s1, nng_optid_recvtimeo, &to, + So(nng_setopt(s1, NNG_OPT_RECVTIMEO, &to, sz) == NNG_EINVAL); - So(nng_setopt(s1, nng_optid_reconnmint, &to, + So(nng_setopt(s1, NNG_OPT_RECONNMINT, &to, sz) == NNG_EINVAL); }); Convey("Bogus raw fails", { - So(nng_setopt_int(s1, nng_optid_raw, 42) == + So(nng_setopt_int(s1, NNG_OPT_RAW, 42) == NNG_EINVAL); - So(nng_setopt_int(s1, nng_optid_raw, -42) == + So(nng_setopt_int(s1, NNG_OPT_RAW, -42) == NNG_EINVAL); - So(nng_setopt_int(s1, nng_optid_raw, 0) == 0); - So(nng_setopt(s1, nng_optid_raw, "a", 1) == + So(nng_setopt_int(s1, NNG_OPT_RAW, 0) == 0); + So(nng_setopt(s1, NNG_OPT_RAW, "a", 1) == NNG_EINVAL); }); Convey("Unsupported options fail", { char *crap = "crap"; - So(nng_setopt(s1, nng_optid_sub_subscribe, - crap, strlen(crap)) == NNG_ENOTSUP); + So(nng_setopt(s1, NNG_OPT_SUB_SUBSCRIBE, crap, + strlen(crap)) == NNG_ENOTSUP); }); Convey("Bogus sizes fail", { @@ -247,30 +249,30 @@ TestMain("Socket Operations", { int i; So(nng_setopt_size( - s1, nng_optid_recvmaxsz, 6550) == 0); + s1, NNG_OPT_RECVMAXSZ, 6550) == 0); So(nng_getopt_size( - s1, nng_optid_recvmaxsz, &v) == 0); + s1, NNG_OPT_RECVMAXSZ, &v) == 0); So(v == 6550); v = 102400; - So(nng_setopt(s1, nng_optid_recvmaxsz, &v, - 1) == NNG_EINVAL); + So(nng_setopt(s1, NNG_OPT_RECVMAXSZ, &v, 1) == + NNG_EINVAL); So(nng_getopt_size( - s1, nng_optid_recvmaxsz, &v) == 0); + s1, NNG_OPT_RECVMAXSZ, &v) == 0); So(v == 6550); i = 42; - So(nng_setopt(s1, nng_optid_recvbuf, &i, 1) == + So(nng_setopt(s1, NNG_OPT_RECVBUF, &i, 1) == NNG_EINVAL); if (sizeof(size_t) == 8) { v = 0x10000; v <<= 30; So(nng_setopt_size(s1, - nng_optid_recvmaxsz, + NNG_OPT_RECVMAXSZ, v) == NNG_EINVAL); So(nng_getopt_size(s1, - nng_optid_recvmaxsz, &v) == 0); + NNG_OPT_RECVMAXSZ, &v) == 0); So(v == 6550); } }); @@ -343,21 +345,20 @@ TestMain("Socket Operations", { Convey("Options work", { size_t sz; So(nng_dialer_setopt_size( - ep, nng_optid_recvmaxsz, 4321) == 0); + ep, NNG_OPT_RECVMAXSZ, 4321) == 0); So(nng_dialer_getopt_size( - ep, nng_optid_recvmaxsz, &sz) == 0); + ep, NNG_OPT_RECVMAXSZ, &sz) == 0); So(sz == 4321); }); Convey("Socket opts not for dialer", { // Not appropriate for dialer. - So(nng_dialer_setopt_int( - ep, nng_optid_raw, 1) == NNG_ENOTSUP); + So(nng_dialer_setopt_int(ep, NNG_OPT_RAW, 1) == + NNG_ENOTSUP); So(nng_dialer_setopt_usec(ep, - nng_optid_reconnmint, - 1) == NNG_ENOTSUP); + NNG_OPT_RECONNMINT, 1) == NNG_ENOTSUP); }); Convey("Bad size checks", { - So(nng_dialer_setopt(ep, nng_optid_recvmaxsz, + So(nng_dialer_setopt(ep, NNG_OPT_RECVMAXSZ, "a", 1) == NNG_EINVAL); }); Convey("Cannot listen", @@ -372,21 +373,20 @@ TestMain("Socket Operations", { Convey("Options work", { size_t sz; So(nng_listener_setopt_size( - ep, nng_optid_recvmaxsz, 4321) == 0); + ep, NNG_OPT_RECVMAXSZ, 4321) == 0); So(nng_listener_getopt_size( - ep, nng_optid_recvmaxsz, &sz) == 0); + ep, NNG_OPT_RECVMAXSZ, &sz) == 0); So(sz == 4321); }); Convey("Socket opts not for dialer", { // Not appropriate for dialer. So(nng_listener_setopt_int( - ep, nng_optid_raw, 1) == NNG_ENOTSUP); + ep, NNG_OPT_RAW, 1) == NNG_ENOTSUP); So(nng_listener_setopt_usec(ep, - nng_optid_reconnmint, - 1) == NNG_ENOTSUP); + NNG_OPT_RECONNMINT, 1) == NNG_ENOTSUP); }); Convey("Bad size checks", { - So(nng_listener_setopt(ep, nng_optid_recvmaxsz, + So(nng_listener_setopt(ep, NNG_OPT_RECVMAXSZ, "a", 1) == NNG_EINVAL); }); Convey("Cannot dial", @@ -399,30 +399,30 @@ TestMain("Socket Operations", { uint64_t t; So(nng_dialer_setopt_size( - 1999, nng_optid_recvmaxsz, 10) == NNG_ENOENT); + 1999, NNG_OPT_RECVMAXSZ, 10) == NNG_ENOENT); So(nng_listener_setopt_size( - 1999, nng_optid_recvmaxsz, 10) == NNG_ENOENT); + 1999, NNG_OPT_RECVMAXSZ, 10) == NNG_ENOENT); s = 1; - So(nng_dialer_getopt(1999, nng_optid_raw, &i, &s) == + So(nng_dialer_getopt(1999, NNG_OPT_RAW, &i, &s) == NNG_ENOENT); - So(nng_listener_getopt(1999, nng_optid_raw, &i, &s) == + So(nng_listener_getopt(1999, NNG_OPT_RAW, &i, &s) == NNG_ENOENT); So(nng_dialer_getopt_size( - 1999, nng_optid_recvmaxsz, &s) == NNG_ENOENT); + 1999, NNG_OPT_RECVMAXSZ, &s) == NNG_ENOENT); So(nng_listener_getopt_size( - 1999, nng_optid_recvmaxsz, &s) == NNG_ENOENT); + 1999, NNG_OPT_RECVMAXSZ, &s) == NNG_ENOENT); - So(nng_dialer_getopt_int(1999, nng_optid_raw, &i) == + So(nng_dialer_getopt_int(1999, NNG_OPT_RAW, &i) == NNG_ENOENT); - So(nng_listener_getopt_int(1999, nng_optid_raw, &i) == + So(nng_listener_getopt_int(1999, NNG_OPT_RAW, &i) == NNG_ENOENT); - So(nng_dialer_getopt_usec( - 1999, nng_optid_linger, &t) == NNG_ENOENT); + So(nng_dialer_getopt_usec(1999, NNG_OPT_LINGER, &t) == + NNG_ENOENT); So(nng_listener_getopt_usec( - 1999, nng_optid_linger, &t) == NNG_ENOENT); + 1999, NNG_OPT_LINGER, &t) == NNG_ENOENT); }); @@ -433,8 +433,8 @@ TestMain("Socket Operations", { trantest_next_address(addr, "ipc:///tmp/sock_test_%u"); So(nng_dialer_create(&ep, s1, addr) == 0); So(nng_dialer_start(ep, NNG_FLAG_NONBLOCK) == 0); - So(nng_dialer_setopt_size( - ep, nng_optid_recvmaxsz, 10) == NNG_ESTATE); + So(nng_dialer_setopt_size(ep, NNG_OPT_RECVMAXSZ, 10) == + NNG_ESTATE); So(nng_dialer_close(ep) == 0); So(nng_dialer_close(ep) == NNG_ENOENT); }); @@ -448,7 +448,7 @@ TestMain("Socket Operations", { So(nng_listener_create(&ep, s1, addr) == 0); So(nng_listener_start(ep, 0) == 0); So(nng_listener_setopt_size( - ep, nng_optid_recvmaxsz, 10) == NNG_ESTATE); + ep, NNG_OPT_RECVMAXSZ, 10) == NNG_ESTATE); So(nng_listener_close(ep) == 0); So(nng_listener_close(ep) == NNG_ENOENT); }); @@ -464,17 +464,17 @@ TestMain("Socket Operations", { So(nng_pair_open(&s2) == 0); Reset({ nng_close(s2); }); - So(nng_setopt_int(s1, nng_optid_recvbuf, 1) == 0); - So(nng_getopt_int(s1, nng_optid_recvbuf, &len) == 0); + So(nng_setopt_int(s1, NNG_OPT_RECVBUF, 1) == 0); + So(nng_getopt_int(s1, NNG_OPT_RECVBUF, &len) == 0); So(len == 1); - So(nng_setopt_int(s1, nng_optid_sendbuf, 1) == 0); - So(nng_setopt_int(s2, nng_optid_sendbuf, 1) == 0); + So(nng_setopt_int(s1, NNG_OPT_SENDBUF, 1) == 0); + So(nng_setopt_int(s2, NNG_OPT_SENDBUF, 1) == 0); - So(nng_setopt_usec(s1, nng_optid_sendtimeo, to) == 0); - So(nng_setopt_usec(s1, nng_optid_recvtimeo, to) == 0); - So(nng_setopt_usec(s2, nng_optid_sendtimeo, to) == 0); - So(nng_setopt_usec(s2, nng_optid_recvtimeo, to) == 0); + So(nng_setopt_usec(s1, NNG_OPT_SENDTIMEO, to) == 0); + So(nng_setopt_usec(s1, NNG_OPT_RECVTIMEO, to) == 0); + So(nng_setopt_usec(s2, NNG_OPT_SENDTIMEO, to) == 0); + So(nng_setopt_usec(s2, NNG_OPT_RECVTIMEO, to) == 0); So(nng_listen(s1, a, NULL, 0) == 0); So(nng_dial(s2, a, NULL, 0) == 0); diff --git a/tests/survey.c b/tests/survey.c index ae252cd5..346f2f30 100644 --- a/tests/survey.c +++ b/tests/survey.c @@ -14,7 +14,6 @@ #include <string.h> extern const char *nng_opt_surveyor_surveytime; -extern int nng_optid_surveyor_surveytime; #define APPENDSTR(m, s) nng_msg_append(m, s, strlen(s)) #define CHECKSTR(m, s) \ @@ -33,17 +32,6 @@ TestMain("SURVEY pattern", { Reset({ nng_close(surv); }); - Convey("Surveytime option id works", { - int opt; - const char *name; - opt = nng_option_lookup(nng_opt_surveyor_surveytime); - So(opt >= 0); - So(opt == nng_optid_surveyor_surveytime); - name = nng_option_name(opt); - So(name != NULL); - So(strcmp(name, nng_opt_surveyor_surveytime) == 0); - }); - Convey("Protocols match", { So(nng_protocol(surv) == NNG_PROTO_SURVEYOR); So(nng_peer(surv) == NNG_PROTO_RESPONDENT); @@ -57,8 +45,8 @@ TestMain("SURVEY pattern", { Convey("Survey without responder times out", { nng_msg *msg; - So(nng_setopt_usec(surv, nng_optid_surveyor_surveytime, - 50000) == 0); + So(nng_setopt_usec( + surv, nng_opt_surveyor_surveytime, 50000) == 0); So(nng_msg_alloc(&msg, 0) == 0); So(nng_sendmsg(surv, msg, 0) == 0); So(nng_recvmsg(surv, &msg, 0) == NNG_ETIMEDOUT); @@ -97,8 +85,8 @@ TestMain("SURVEY pattern", { nng_close(resp); }); - So(nng_setopt_usec( - surv, nng_optid_surveyor_surveytime, 50000) == 0); + So(nng_setopt_usec(surv, nng_opt_surveyor_surveytime, 50000) == + 0); So(nng_listen(surv, addr, NULL, 0) == 0); So(nng_dial(resp, addr, NULL, 0) == 0); @@ -132,8 +120,8 @@ TestMain("SURVEY pattern", { Convey("And goes to non-survey state", { rtimeo = 200000; - So(nng_setopt_usec(surv, nng_optid_recvtimeo, - 200000) == 0); + So(nng_setopt_usec( + surv, NNG_OPT_RECVTIMEO, 200000) == 0); So(nng_recvmsg(surv, &msg, 0) == NNG_ESTATE); }); }); diff --git a/tests/trantest.h b/tests/trantest.h index 2e5f859d..b6843ea6 100644 --- a/tests/trantest.h +++ b/tests/trantest.h @@ -162,8 +162,8 @@ trantest_send_recv(trantest *tt) So(strcmp(nng_msg_body(recv), "acknowledge") == 0); p = nng_msg_get_pipe(recv); So(p != 0); - sz = sizeof (url); - So(nng_pipe_getopt(p, nng_optid_url, url, &sz) == 0); + sz = sizeof(url); + So(nng_pipe_getopt(p, NNG_OPT_URL, url, &sz) == 0); So(strcmp(url, tt->addr) == 0); nng_msg_free(recv); }); @@ -13,10 +13,9 @@ extern int nng_zt_register(void); extern const char *nng_opt_zt_home; -extern int nng_optid_zt_home; -extern int nng_optid_zt_node; -extern int nng_optid_zt_status; -extern int nng_optid_zt_network_name; +extern const char *nng_opt_zt_node; +extern const char *nng_opt_zt_status; +extern const char *nng_opt_zt_network_name; extern int nng_zt_status_ok; // zerotier tests. @@ -61,17 +60,11 @@ TestMain("ZeroTier Transport", { So(nng_listener_create(&l, s, addr) == 0); - Convey("We can lookup zerotier home option id", { - So(nng_optid_zt_home > 0); - So(nng_option_lookup(nng_opt_zt_home) == - nng_optid_zt_home); - }); - Convey("And it can be started...", { mkdir(path1, 0700); - So(nng_listener_setopt(l, nng_optid_zt_home, path1, + So(nng_listener_setopt(l, nng_opt_zt_home, path1, strlen(path1) + 1) == 0); So(nng_listener_start(l, 0) == 0); @@ -93,12 +86,6 @@ TestMain("ZeroTier Transport", { Reset({ nng_close(s); }); So(nng_dialer_create(&d, s, addr) == 0); - - Convey("We can lookup zerotier home option id", { - So(nng_optid_zt_home > 0); - So(nng_option_lookup(nng_opt_zt_home) == - nng_optid_zt_home); - }); }); Convey("We can create an ephemeral listener", { @@ -117,8 +104,7 @@ TestMain("ZeroTier Transport", { So(nng_listener_create(&l, s, addr) == 0); - So(nng_listener_getopt_usec(l, nng_optid_zt_node, &node1) == - 0); + So(nng_listener_getopt_usec(l, nng_opt_zt_node, &node1) == 0); So(node1 != 0); Convey("Network name & status options work", { @@ -128,11 +114,11 @@ TestMain("ZeroTier Transport", { namesz = sizeof(name); nng_usleep(10000000); - So(nng_listener_getopt(l, nng_optid_zt_network_name, + So(nng_listener_getopt(l, nng_opt_zt_network_name, name, &namesz) == 0); So(strcmp(name, "nng_test_open") == 0); So(nng_listener_getopt_int( - l, nng_optid_zt_status, &status) == 0); + l, nng_opt_zt_status, &status) == 0); So(status == nng_zt_status_ok); }); Convey("Connection refused works", { @@ -140,7 +126,7 @@ TestMain("ZeroTier Transport", { (unsigned long long) node1, 42u); So(nng_dialer_create(&d, s, addr) == 0); So(nng_dialer_getopt_usec( - d, nng_optid_zt_node, &node2) == 0); + d, nng_opt_zt_node, &node2) == 0); So(node2 == node1); So(nng_dialer_start(d, 0) == NNG_ECONNREFUSED); }); @@ -173,18 +159,18 @@ TestMain("ZeroTier Transport", { So(nng_listener_create(&l, s1, addr1) == 0); So(nng_listener_setopt( - l, nng_optid_zt_home, path1, strlen(path1) + 1) == 0); + l, nng_opt_zt_home, path1, strlen(path1) + 1) == 0); So(nng_listener_start(l, 0) == 0); node = 0; - So(nng_listener_getopt_usec(l, nng_optid_zt_node, &node) == 0); + So(nng_listener_getopt_usec(l, nng_opt_zt_node, &node) == 0); So(node != 0); snprintf(addr2, sizeof(addr2), "zt://" NWID "/%llx:%u", (unsigned long long) node, port); So(nng_dialer_create(&d, s2, addr2) == 0); So(nng_dialer_setopt( - d, nng_optid_zt_home, path2, strlen(path2) + 1) == 0); + d, nng_opt_zt_home, path2, strlen(path2) + 1) == 0); So(nng_dialer_start(d, 0) == 0); }); |
