aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2013-03-04 14:24:02 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2013-03-04 14:24:02 +0000
commitd0d1948a8d8519e46562737decdfaa6862dc89f5 (patch)
treeb219a6281bf6eff862dca90cf73cd102a7c721d9 /src/testing
parentdcb57a9e51e8fe7412948ec0c47d383ed390ed61 (diff)
downloadgnunet-d0d1948a8d8519e46562737decdfaa6862dc89f5.tar.gz
gnunet-d0d1948a8d8519e46562737decdfaa6862dc89f5.zip
cache peer identities
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/testing.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/testing/testing.c b/src/testing/testing.c
index 826c5753f..1711531c4 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -180,6 +180,12 @@ struct GNUNET_TESTING_Peer
180 struct GNUNET_OS_Process *main_process; 180 struct GNUNET_OS_Process *main_process;
181 181
182 /** 182 /**
183 * The cached identity of this peer. Will be populated on call to
184 * GNUNET_TESTING_peer_get_identity()
185 */
186 struct GNUNET_PeerIdentity *id;
187
188 /**
183 * The keynumber of this peer's hostkey 189 * The keynumber of this peer's hostkey
184 */ 190 */
185 uint32_t key_number; 191 uint32_t key_number;
@@ -977,12 +983,19 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
977 * @param id identifier for the daemon, will be set 983 * @param id identifier for the daemon, will be set
978 */ 984 */
979void 985void
980GNUNET_TESTING_peer_get_identity (const struct GNUNET_TESTING_Peer *peer, 986GNUNET_TESTING_peer_get_identity (struct GNUNET_TESTING_Peer *peer,
981 struct GNUNET_PeerIdentity *id) 987 struct GNUNET_PeerIdentity *id)
982{ 988{
989 if (NULL != peer->id)
990 {
991 memcpy (id, peer->id, sizeof (struct GNUNET_PeerIdentity));
992 return;
993 }
994 peer->id = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity));
983 GNUNET_CRYPTO_ecc_key_free (GNUNET_TESTING_hostkey_get (peer->system, 995 GNUNET_CRYPTO_ecc_key_free (GNUNET_TESTING_hostkey_get (peer->system,
984 peer->key_number, 996 peer->key_number,
985 id)); 997 peer->id));
998 memcpy (id, peer->id, sizeof (struct GNUNET_PeerIdentity));
986} 999}
987 1000
988 1001
@@ -1101,6 +1114,7 @@ GNUNET_TESTING_peer_destroy (struct GNUNET_TESTING_Peer *peer)
1101 GNUNET_free (peer->cfgfile); 1114 GNUNET_free (peer->cfgfile);
1102 GNUNET_free (peer->main_binary); 1115 GNUNET_free (peer->main_binary);
1103 GNUNET_free (peer->args); 1116 GNUNET_free (peer->args);
1117 GNUNET_free_non_null (peer->id);
1104 GNUNET_free (peer); 1118 GNUNET_free (peer);
1105} 1119}
1106 1120