aboutsummaryrefslogtreecommitdiff
path: root/src/scalarproduct/test_scalarproduct_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/scalarproduct/test_scalarproduct_api.c')
-rw-r--r--src/scalarproduct/test_scalarproduct_api.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/scalarproduct/test_scalarproduct_api.c b/src/scalarproduct/test_scalarproduct_api.c
index e28074fd4..082723278 100644
--- a/src/scalarproduct/test_scalarproduct_api.c
+++ b/src/scalarproduct/test_scalarproduct_api.c
@@ -19,7 +19,7 @@
19 */ 19 */
20 20
21/** 21/**
22 * Aim of test_scalarproduct_api : This test creates two peers. Peer1 is the 22 * Aim of test_scalarproduct_api : This test creates two peers. Peer1 is the
23 * responder peer, Bob and Peer2 is the initiator peer, Alice. Both peers 23 * responder peer, Bob and Peer2 is the initiator peer, Alice. Both peers
24 * connect to VectorProduct Service, and use the API to issue requests to 24 * connect to VectorProduct Service, and use the API to issue requests to
25 * service. Test passes, when the expected scalar product is received from the 25 * service. Test passes, when the expected scalar product is received from the
@@ -219,7 +219,7 @@ do_close (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
219 219
220/** 220/**
221 * Shutdown a peer 221 * Shutdown a peer
222 * 222 *
223 * @param cls pointer to "struct PeerData" of the peer to be disconnected 223 * @param cls pointer to "struct PeerData" of the peer to be disconnected
224 * @param tc Task Context 224 * @param tc Task Context
225 */ 225 */
@@ -272,7 +272,7 @@ controller_event_cb (void *cls,
272 const struct GNUNET_TESTBED_EventInformation *event) 272 const struct GNUNET_TESTBED_EventInformation *event)
273{ 273{
274 GNUNET_assert (event->type == GNUNET_TESTBED_ET_OPERATION_FINISHED); 274 GNUNET_assert (event->type == GNUNET_TESTBED_ET_OPERATION_FINISHED);
275 275
276 switch (setup_state) 276 switch (setup_state)
277 { 277 {
278 case PEER1_SCALARPRODUCT_CONNECT: 278 case PEER1_SCALARPRODUCT_CONNECT:
@@ -366,7 +366,7 @@ requester_callback (void *cls,
366 { 366 {
367 LOG (GNUNET_ERROR_TYPE_INFO, "Requester Client expected response received!\n"); 367 LOG (GNUNET_ERROR_TYPE_INFO, "Requester Client expected response received!\n");
368 product_len = ntohl(msg->product_length); 368 product_len = ntohl(msg->product_length);
369 369
370 if (0 < product_len) 370 if (0 < product_len)
371 { 371 {
372 gcry_mpi_t result; 372 gcry_mpi_t result;
@@ -383,7 +383,7 @@ requester_callback (void *cls,
383 { 383 {
384 uint16_t i = 0; 384 uint16_t i = 0;
385 385
386 // calculate expected product 386 // calculate expected product
387 gcry_mpi_t expected_result; 387 gcry_mpi_t expected_result;
388 gcry_mpi_t v1; 388 gcry_mpi_t v1;
389 gcry_mpi_t v2; 389 gcry_mpi_t v2;
@@ -424,7 +424,7 @@ requester_callback (void *cls,
424 gcry_mpi_release (v1_v2_prod); 424 gcry_mpi_release (v1_v2_prod);
425 425
426 } 426 }
427 427
428 // compare the result 428 // compare the result
429 if (!gcry_mpi_cmp (expected_result, result)) 429 if (!gcry_mpi_cmp (expected_result, result))
430 { 430 {
@@ -453,7 +453,7 @@ requester_callback (void *cls,
453} 453}
454 454
455/** 455/**
456 * Prepare the message to be sent by peer2 to its scalarproduct service, to 456 * Prepare the message to be sent by peer2 to its scalarproduct service, to
457 * initiate a request to peer1. 457 * initiate a request to peer1.
458 */ 458 */
459static struct GNUNET_SCALARPRODUCT_QueueEntry * 459static struct GNUNET_SCALARPRODUCT_QueueEntry *
@@ -467,9 +467,9 @@ requester_request ()
467 int32_t element; 467 int32_t element;
468 struct GNUNET_SCALARPRODUCT_QueueEntry *qe; 468 struct GNUNET_SCALARPRODUCT_QueueEntry *qe;
469 struct GNUNET_HashCode key; 469 struct GNUNET_HashCode key;
470 470
471 GNUNET_assert (peer2.vh != NULL); 471 GNUNET_assert (peer2.vh != NULL);
472 472
473 GNUNET_CRYPTO_hash (input_key, strlen (input_key), &key); 473 GNUNET_CRYPTO_hash (input_key, strlen (input_key), &key);
474 474
475 /* Read input_elements_peer2, and put in elements_peer2 array */ 475 /* Read input_elements_peer2, and put in elements_peer2 array */
@@ -501,7 +501,7 @@ requester_request ()
501 while (!exit_loop && element_count_peer2 < max_mids); 501 while (!exit_loop && element_count_peer2 < max_mids);
502 GNUNET_assert (elements_peer2 != NULL); 502 GNUNET_assert (elements_peer2 != NULL);
503 GNUNET_assert (element_count_peer2 >= 1); 503 GNUNET_assert (element_count_peer2 >= 1);
504 504
505 /* Read input_mask_peer2 and read in mask_peer2 array */ 505 /* Read input_mask_peer2 and read in mask_peer2 array */
506 mask_length = element_count_peer2 / 8 + (element_count_peer2 % 8 ? 1 : 0); 506 mask_length = element_count_peer2 / 8 + (element_count_peer2 % 8 ? 1 : 0);
507 mask_peer2 = GNUNET_malloc ((element_count_peer2 / 8) + 2); 507 mask_peer2 = GNUNET_malloc ((element_count_peer2 / 8) + 2);
@@ -584,7 +584,7 @@ responder_prepare_response ()
584 int32_t element; 584 int32_t element;
585 struct GNUNET_SCALARPRODUCT_QueueEntry *qe; 585 struct GNUNET_SCALARPRODUCT_QueueEntry *qe;
586 struct GNUNET_HashCode key; 586 struct GNUNET_HashCode key;
587 587
588 GNUNET_CRYPTO_hash (input_key, strlen (input_key), &key); 588 GNUNET_CRYPTO_hash (input_key, strlen (input_key), &key);
589 589
590 /* Read input_elements_peer1, and put in elements_peer1 array */ 590 /* Read input_elements_peer1, and put in elements_peer1 array */
@@ -638,7 +638,7 @@ responder_prepare_response ()
638 638
639/** 639/**
640 * Scheduler task to initiate requester client 640 * Scheduler task to initiate requester client
641 * 641 *
642 * @param cls void* to struct PeerData 642 * @param cls void* to struct PeerData
643 * @param tc Task Context 643 * @param tc Task Context
644 */ 644 */
@@ -653,7 +653,7 @@ request_task(void *cls,
653 653
654/** 654/**
655 * Scheduler task to initiate responder client 655 * Scheduler task to initiate responder client
656 * 656 *
657 * @param cls void* to struct PeerData 657 * @param cls void* to struct PeerData
658 * @param tc Task Context 658 * @param tc Task Context
659 */ 659 */
@@ -661,7 +661,7 @@ static void
661prepare_response_task(void *cls, 661prepare_response_task(void *cls,
662 const struct GNUNET_SCHEDULER_TaskContext 662 const struct GNUNET_SCHEDULER_TaskContext
663 * tc) 663 * tc)
664{ 664{
665 responder_prepare_response(); 665 responder_prepare_response();
666 return; 666 return;
667} 667}
@@ -672,7 +672,7 @@ prepare_response_task(void *cls,
672 * a service. This function is called when GNUNET_TESTBED_operation_done is 672 * a service. This function is called when GNUNET_TESTBED_operation_done is
673 * called for peer->op, which holds the handle for GNUNET_TESTBED_service_connect 673 * called for peer->op, which holds the handle for GNUNET_TESTBED_service_connect
674 * operation. 674 * operation.
675 * 675 *
676 * @param cls closure 676 * @param cls closure
677 * @param op_result service handle returned from the connect adapter 677 * @param op_result service handle returned from the connect adapter
678 */ 678 */
@@ -689,7 +689,7 @@ scalarproduct_da (void *cls, void *op_result)
689/** 689/**
690 * Adapter function called to establish a connection to 690 * Adapter function called to establish a connection to
691 * a service. This function is called to by GNUNET_TESTBED_service_connect. 691 * a service. This function is called to by GNUNET_TESTBED_service_connect.
692 * 692 *
693 * @param cls closure 693 * @param cls closure
694 * @param cfg configuration of the peer to connect to; will be available until 694 * @param cfg configuration of the peer to connect to; will be available until
695 * GNUNET_TESTBED_operation_done() is called on the operation returned 695 * GNUNET_TESTBED_operation_done() is called on the operation returned
@@ -729,7 +729,7 @@ scalarproduct_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
729 GNUNET_SCHEDULER_add_now(&prepare_response_task, &peer1); 729 GNUNET_SCHEDULER_add_now(&prepare_response_task, &peer1);
730 GNUNET_SCHEDULER_add_now(&request_task, &peer2); 730 GNUNET_SCHEDULER_add_now(&request_task, &peer2);
731 } 731 }
732 732
733 return peer2.vh; 733 return peer2.vh;
734 default: 734 default:
735 GNUNET_assert (0); 735 GNUNET_assert (0);
@@ -814,7 +814,7 @@ test_master (void *cls, unsigned int num_peers,
814 GNUNET_TESTBED_PIT_IDENTITY, 814 GNUNET_TESTBED_PIT_IDENTITY,
815 &peerinfo_cb, NULL); 815 &peerinfo_cb, NULL);
816 setup_state = PEER1_GET_IDENTITY; 816 setup_state = PEER1_GET_IDENTITY;
817 817
818 /* Abort task for stopping test on timeout */ 818 /* Abort task for stopping test on timeout */
819 abort_task = 819 abort_task =
820 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 820 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
@@ -842,7 +842,7 @@ main (int argc, char **argv)
842 NUM_PEERS, event_mask, &controller_event_cb, 842 NUM_PEERS, event_mask, &controller_event_cb,
843 NULL, 843 NULL,
844 &test_master, NULL); 844 &test_master, NULL);
845 845
846 if (GNUNET_SYSERR == ok) 846 if (GNUNET_SYSERR == ok)
847 { 847 {
848 LOG (GNUNET_ERROR_TYPE_ERROR, "Test failing due to some error before calling API for request or prepare_response\n"); 848 LOG (GNUNET_ERROR_TYPE_ERROR, "Test failing due to some error before calling API for request or prepare_response\n");