Skip to content

Commit

Permalink
tests: use assertion gen func
Browse files Browse the repository at this point in the history
  • Loading branch information
bonedaddy committed Nov 12, 2020
1 parent 63aae49 commit 40a9d0a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions tests/peerstore_test.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "peerstore/peerstore.h"
#include "testutils/testutils.h"
// #include "testutils/testutils.h"
#include "crypto/ecdsa.h"
#include <stdio.h>
#include <assert.h>
#include <stdarg.h>
Expand Down Expand Up @@ -50,7 +51,7 @@ void peerstore_test_insert_peer(void **state) {
peerstore_t *pst = peerstore_new_assert(100);

for (int i = 0; i < 100; i++) {
ecdsa_private_key_t *priv_key = new_ecdsa_private_key();
ecdsa_private_key_t *priv_key = assert_new_ecdsa_private_key();
assert(priv_key != NULL);
peer_id_t *pid = libp2p_crypto_ecdsa_keypair_peerid(priv_key);
assert(pid != NULL);
Expand Down Expand Up @@ -83,7 +84,7 @@ void peerstore_test_insert_peer(void **state) {

assert(pst->num_peers == 100);

ecdsa_private_key_t *priv_key = new_ecdsa_private_key();
ecdsa_private_key_t *priv_key = assert_new_ecdsa_private_key();
assert(priv_key != NULL);
peer_id_t *pid = libp2p_crypto_ecdsa_keypair_peerid(priv_key);
assert(pid != NULL);
Expand Down
7 changes: 4 additions & 3 deletions tests/socket_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
#include "network/messages.h"
#include "network/socket_server.h"
#include "multiaddr/multiaddr.h"
#include "crypto/ecdsa.h"
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <netdb.h>
#include <netdb.h>
#include <netinet/in.h>
#include <pthread.h>
#include <signal.h>
Expand Down Expand Up @@ -51,8 +52,8 @@ void start_socker_server_wrapper(void *data) {
* @warning this test is currently leaking about 24 bytes likely because we are using two thread pools which rely on some sort of global stuff
*/
void test_new_socket_server(void **state) {
ecdsa_private_key_t *server1_pk = new_ecdsa_private_key();
ecdsa_private_key_t *server2_pk = new_ecdsa_private_key();
ecdsa_private_key_t *server1_pk = assert_new_ecdsa_private_key();
ecdsa_private_key_t *server2_pk = assert_new_ecdsa_private_key();

int rc = libp2p_crypto_ecdsa_private_key_save(server1_pk, "server1.pem");
assert(rc == 0);
Expand Down

0 comments on commit 40a9d0a

Please sign in to comment.