updating tests to match api
authorMatthias Wachs <wachs@net.in.tum.de>
Fri, 5 Jul 2013 09:56:33 +0000 (09:56 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Fri, 5 Jul 2013 09:56:33 +0000 (09:56 +0000)
src/ats/perf_ats_mlp.c
src/ats/test_ats_mlp.c
src/ats/test_ats_simplistic_switch_networks.c

index b6955b7664fd65addf35ae2d24762e7fa2d66b1e..5f39c24d78b98b0ab9ba38e8bde98f2556ff6066 100644 (file)
@@ -143,7 +143,7 @@ bandwidth_changed_cb (void *cls, struct ATS_Address *address)
 
 static void
 normalized_property_changed_cb (void *cls,
-                                                                                                                const struct ATS_Address *peer,
+                                                                                                                struct ATS_Address *peer,
                                                                                                                 uint32_t type,
                                                                                                                 double prop_rel)
 {
@@ -184,13 +184,13 @@ perf_create_address (int cp, int ca)
 static void
 address_initial_update (void *solver, struct GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address)
 {
-       ats[0].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
-       ats[0].value = htonl (GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 100));
+       GAS_mlp_address_property_changed (mlp, address,
+                       GNUNET_ATS_QUALITY_NET_DELAY, 100,
+                       (double)(100 + GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 100)) / 100);
 
-       ats[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
-       ats[1].value = htonl (GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 10));
-
-       GAS_mlp_address_update (mlp, address, 0, GNUNET_YES, ats, 2);
+       GAS_mlp_address_property_changed (mlp, address,
+                       GNUNET_ATS_QUALITY_NET_DISTANCE, 10,
+                       (double)(100 + GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 100)) / 100);
 }
 
 
@@ -204,24 +204,26 @@ update_single_addresses (struct ATS_Address *cur)
        switch (r_type) {
                case 0:
                        r_val = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 100);
-                       ats[0].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
-                       ats[0].value = htonl (r_val);
                        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating peer `%s' address %p type %s val %u\n",
                                        GNUNET_i2s (&cur->peer), cur,
                                        "GNUNET_ATS_QUALITY_NET_DELAY", r_val);
+                       GAS_mlp_address_property_changed (mlp, cur, GNUNET_ATS_QUALITY_NET_DELAY, r_val,
+                                       (double)(100 + r_val / 100));
                        break;
                case 1:
                        r_val = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 10);
-                       ats[0].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
-                       ats[0].value = htonl (r_val);
+
                        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating peer `%s' address %p type %s val %u\n",
                                        GNUNET_i2s (&cur->peer), cur,
                                        "GNUNET_ATS_QUALITY_NET_DISTANCE", r_val);
+                       GAS_mlp_address_property_changed (mlp, cur, GNUNET_ATS_QUALITY_NET_DISTANCE, r_val,
+                                       (double)(100 + r_val) / 100);
                        break;
                default:
                        break;
        }
-       GAS_mlp_address_update (mlp, cur, 0, GNUNET_YES, ats, 1);
+       GAS_mlp_address_inuse_changed(mlp, cur, 0, GNUNET_YES);
+
 }
 
 static void
index ea1e5076a22f993d4f4ac5647d295a2c406b5a99..be5e39fcf68dc4e5a7fd74c929b5f3512c7f99e3 100644 (file)
@@ -127,7 +127,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 }
 
 
-static const double *
+const double *
 get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id)
 {
        return GAS_normalization_get_preferences (id);
@@ -139,10 +139,9 @@ get_property_cb (void *cls, const struct ATS_Address *address)
        return GAS_normalization_get_properties ((struct ATS_Address *) address);
 }
 
-
 static void
 normalized_property_changed_cb (void *cls,
-                                                                                                                const struct ATS_Address *peer,
+                                                                                                                struct ATS_Address *peer,
                                                                                                                 uint32_t type,
                                                                                                                 double prop_rel)
 {
@@ -190,7 +189,6 @@ check (void *cls, char *const *args, const char *cfgfile,
   int quotas[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType;
   unsigned long long  quotas_in[GNUNET_ATS_NetworkTypeCount];
   unsigned long long  quotas_out[GNUNET_ATS_NetworkTypeCount];
-  struct GNUNET_ATS_Information ats;
 
 #if !HAVE_LIBGLPK
   GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed!");
@@ -293,9 +291,7 @@ check (void *cls, char *const *args, const char *cfgfile,
 
 
   /* Updating address 0*/
-  ats.type =  htonl (GNUNET_ATS_NETWORK_TYPE);
-  ats.value = htonl (GNUNET_ATS_NET_WAN);
-  GAS_mlp_address_update (mlp, address[0], 1, GNUNET_NO, &ats, 1);
+  GAS_mlp_address_change_network(mlp, address[0], GNUNET_ATS_NET_UNSPECIFIED, GNUNET_ATS_NET_WAN);
 
   /* Retrieving preferred address for peer and wait for callback */
   GAS_mlp_get_preferred_address (mlp, &p[0]);
index 6d15486517e3e856913a2e36c71214b4c80ee7fb..53df468a0813f13cdfd74d22553b484ce8370472 100644 (file)
@@ -133,7 +133,7 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
   char *text;
   if (0 == stage)
   {
-    GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
+    //GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
     if (GNUNET_OK == compare_addresses(address, session, &test_hello_address, test_session))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback for correct address `%s'\n",