Adjustments for testing
This commit is contained in:
parent
8b8a2844bd
commit
630985c698
5 changed files with 28 additions and 13 deletions
|
@ -123,6 +123,7 @@ struct Block* ipfs_block_new() {
|
||||||
return 0;
|
return 0;
|
||||||
block->data = NULL;
|
block->data = NULL;
|
||||||
block->data_length = 0;
|
block->data_length = 0;
|
||||||
|
block->cid = NULL;
|
||||||
|
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
@ -158,7 +159,8 @@ int ipfs_blocks_block_add_data(const unsigned char* data, size_t data_size, stru
|
||||||
*/
|
*/
|
||||||
int ipfs_block_free(struct Block* block) {
|
int ipfs_block_free(struct Block* block) {
|
||||||
if (block != NULL) {
|
if (block != NULL) {
|
||||||
ipfs_cid_free(block->cid);
|
if (block->cid != NULL)
|
||||||
|
ipfs_cid_free(block->cid);
|
||||||
if (block->data != NULL)
|
if (block->data != NULL)
|
||||||
free(block->data);
|
free(block->data);
|
||||||
free(block);
|
free(block);
|
||||||
|
|
|
@ -43,8 +43,17 @@ void* ipfs_bitswap_engine_wantlist_processor_start(void* ctx) {
|
||||||
while (!context->bitswap_engine->shutting_down) {
|
while (!context->bitswap_engine->shutting_down) {
|
||||||
struct WantListQueueEntry* item = ipfs_bitswap_wantlist_queue_pop(context->localWantlist);
|
struct WantListQueueEntry* item = ipfs_bitswap_wantlist_queue_pop(context->localWantlist);
|
||||||
if (item != NULL) {
|
if (item != NULL) {
|
||||||
// if there is something on the queue process it.
|
if (item->attempts > 10) {
|
||||||
ipfs_bitswap_wantlist_process_entry(context, item);
|
// we have tried too many times
|
||||||
|
for (int i = 0; i < item->sessionsRequesting->total; i++) {
|
||||||
|
struct WantListSession* curr_session = (struct WantListSession*) libp2p_utils_vector_get(item->sessionsRequesting, i);
|
||||||
|
ipfs_bitswap_wantlist_queue_remove(context->localWantlist, item->cid, curr_session);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// if there is something on the queue process it.
|
||||||
|
ipfs_bitswap_wantlist_process_entry(context, item);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// if there is nothing on the queue, wait...
|
// if there is nothing on the queue, wait...
|
||||||
sleep(2);
|
sleep(2);
|
||||||
|
|
|
@ -189,10 +189,10 @@ int test_core_api_name_resolve() {
|
||||||
libp2p_logger_debug("test_api", "*** Firing up daemons ***\n");
|
libp2p_logger_debug("test_api", "*** Firing up daemons ***\n");
|
||||||
pthread_create(&daemon_thread1, NULL, test_daemon_start, (void*)ipfs_path1);
|
pthread_create(&daemon_thread1, NULL, test_daemon_start, (void*)ipfs_path1);
|
||||||
thread_started1 = 1;
|
thread_started1 = 1;
|
||||||
sleep(3);
|
sleep(5);
|
||||||
pthread_create(&daemon_thread2, NULL, test_daemon_start, (void*)ipfs_path2);
|
pthread_create(&daemon_thread2, NULL, test_daemon_start, (void*)ipfs_path2);
|
||||||
thread_started2 = 1;
|
thread_started2 = 1;
|
||||||
sleep(3);
|
sleep(10);
|
||||||
|
|
||||||
// publish name on server 1
|
// publish name on server 1
|
||||||
args = cli_arguments_new(6, publish_args);
|
args = cli_arguments_new(6, publish_args);
|
||||||
|
@ -200,12 +200,16 @@ int test_core_api_name_resolve() {
|
||||||
cli_arguments_free(args);
|
cli_arguments_free(args);
|
||||||
args = NULL;
|
args = NULL;
|
||||||
|
|
||||||
|
sleep(3);
|
||||||
|
|
||||||
// use a client of server2 to to ask for the "name resolve" on server 1
|
// use a client of server2 to to ask for the "name resolve" on server 1
|
||||||
args = cli_arguments_new(6, resolve_args);
|
args = cli_arguments_new(6, resolve_args);
|
||||||
if (ipfs_name(args) == 0) {
|
if (ipfs_name(args) == 0) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sleep(5);
|
||||||
|
|
||||||
retVal = 1;
|
retVal = 1;
|
||||||
exit:
|
exit:
|
||||||
cli_arguments_free(args);
|
cli_arguments_free(args);
|
||||||
|
|
|
@ -317,7 +317,7 @@ int test_bitswap_retrieve_file_known_remote() {
|
||||||
if (!ipfs_cid_decode_hash_from_base58((unsigned char*)hello_world_hash, strlen(hello_world_hash), &cid))
|
if (!ipfs_cid_decode_hash_from_base58((unsigned char*)hello_world_hash, strlen(hello_world_hash), &cid))
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
sleep(300);
|
sleep(3);
|
||||||
|
|
||||||
// this does the heavy lifting...
|
// this does the heavy lifting...
|
||||||
if (!ipfs_node2->exchange->GetBlock(ipfs_node2->exchange, cid, &result)) {
|
if (!ipfs_node2->exchange->GetBlock(ipfs_node2->exchange, cid, &result)) {
|
||||||
|
|
|
@ -29,12 +29,12 @@
|
||||||
#include "namesys/test_namesys.h"
|
#include "namesys/test_namesys.h"
|
||||||
|
|
||||||
int testit(const char* name, int (*func)(void)) {
|
int testit(const char* name, int (*func)(void)) {
|
||||||
printf("TESTING %s...\n", name);
|
fprintf(stderr, "TESTING %s...\n", name);
|
||||||
int retVal = func();
|
int retVal = func();
|
||||||
if (retVal)
|
if (retVal)
|
||||||
printf("%s success!\n", name);
|
fprintf(stderr, "%s success!\n", name);
|
||||||
else
|
else
|
||||||
printf("** Uh oh! %s failed.**\n", name);
|
fprintf(stderr, "** Uh oh! %s failed.**\n", name);
|
||||||
return retVal == 0;
|
return retVal == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ int main(int argc, char** argv) {
|
||||||
int array_length = sizeof(funcs) / sizeof(funcs[0]);
|
int array_length = sizeof(funcs) / sizeof(funcs[0]);
|
||||||
int array2_length = sizeof(names) / sizeof(names[0]);
|
int array2_length = sizeof(names) / sizeof(names[0]);
|
||||||
if (array_length != array2_length) {
|
if (array_length != array2_length) {
|
||||||
printf("Test arrays are not of the same length. Funcs: %d, Names: %d\n", array_length, array2_length);
|
fprintf(stderr, "Test arrays are not of the same length. Funcs: %d, Names: %d\n", array_length, array2_length);
|
||||||
}
|
}
|
||||||
test_wanted = get_test(argc, argv, current_test_arg);
|
test_wanted = get_test(argc, argv, current_test_arg);
|
||||||
while (!certain_tests || test_wanted != NULL) {
|
while (!certain_tests || test_wanted != NULL) {
|
||||||
|
@ -240,12 +240,12 @@ int main(int argc, char** argv) {
|
||||||
test_wanted = get_test(argc, argv, ++current_test_arg);
|
test_wanted = get_test(argc, argv, ++current_test_arg);
|
||||||
}
|
}
|
||||||
if (tests_ran == 0)
|
if (tests_ran == 0)
|
||||||
printf("***** No tests found *****\n");
|
fprintf(stderr, "***** No tests found *****\n");
|
||||||
else {
|
else {
|
||||||
if (counter > 0) {
|
if (counter > 0) {
|
||||||
printf("***** There were %d failed (out of %d) test(s) *****\n", counter, tests_ran);
|
fprintf(stderr, "***** There were %d failed (out of %d) test(s) *****\n", counter, tests_ran);
|
||||||
} else {
|
} else {
|
||||||
printf("All %d tests passed\n", tests_ran);
|
fprintf(stderr, "All %d tests passed\n", tests_ran);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
libp2p_logger_free();
|
libp2p_logger_free();
|
||||||
|
|
Loading…
Reference in a new issue