+ // ---- wormhole state -----------
+ state = rmr_wh_state( NULL, 0 );
+ errors += fail_if_equal( state, RMR_OK, "wh_state with bad context did not return error" );
+
+ state = rmr_wh_state( ctx, -1 );
+ errors += fail_if_equal( state, RMR_OK, "wh_state with bad whid did not return error" );
+
+ whid = rmr_wh_open( ctx, "localhost:9219" );
+ if( ! fail_if_equal( whid, -1, "skipping some wh_state tests: no whid returned" ) ) {
+ state = rmr_wh_state( ctx, whid );
+ errors += fail_not_equal( state, RMR_OK, "wh_state on an open wh did not return OK" );
+
+ rmr_wh_close( ctx, whid );
+ state = rmr_wh_state( ctx, whid );
+ errors += fail_if_equal( state, RMR_OK, "wh_state on a closed wh returned OK" );
+ whid = -1;
+ }
+
+ // ----- wormhole call --------------------------------------------------
+ mbuf = rmr_alloc_msg( ctx, 2048 ); // ensure we have a buffer to pass
+ resp = rmr_wh_call( NULL, 0, NULL, 1, 10 ); // ensure no msg when msg is nil
+ errors += fail_not_nil( resp, "wormhole call given nil context and msg didn't return nil message" );
+
+ resp = rmr_wh_call( NULL, 0, mbuf, 1, 10 ); // ensure invalid state when context is bad
+ errors += fail_if_nil( resp, "wormhole call given nil context and valid msg didn't return message pointer" );
+ if( resp != NULL ) {
+ errors += fail_if_equal( resp->state, RMR_OK, "wormhole call given nil context and valid message returned OK state" );
+ }
+
+ resp = rmr_wh_call( ctx, 2000, mbuf, 1, 10 ); // invalid wormhole id
+ errors += fail_if_nil( resp, "wormhole call given bad whid returned no msg" );
+ if( resp ) {
+ errors += fail_if_equal( resp->state, RMR_OK, "wormhole call given bad whid returned good state" );
+ }
+
+ whid = rmr_wh_open( ctx, "localhost:9219" ); // ensure one is open
+ resp = rmr_wh_call( ctx, whid, mbuf, 1, 1 );
+ errors += fail_if_nil( resp, "wormhole call given valid info returned nil response" );
+