Fixing of test_core_api_object_cat

This commit is contained in:
John Jones 2017-09-20 10:50:32 -05:00
parent 215af9cfce
commit 07551151da
4 changed files with 21 additions and 8 deletions

View file

@ -42,12 +42,14 @@ int api_running(struct IpfsNode* local_node) {
return 0;
}
bzero((char *) &serv_addr, sizeof(serv_addr));
memset(&serv_addr, 0, sizeof(struct sockaddr_in));
serv_addr.sin_family = AF_INET;
memmove(&serv_addr.sin_addr.s_addr, server->h_addr_list[0], server->h_length);
/*
bcopy((char *)server->h_addr,
(char *)&serv_addr.sin_addr.s_addr,
server->h_length);
*/
serv_addr.sin_port = htons(portno);
int retVal = connect(sockfd,(struct sockaddr *) &serv_addr,sizeof(serv_addr));
close(sockfd);

View file

@ -50,9 +50,14 @@ char* ipfs_repo_get_home_directory(int argc, char** argv) {
*/
int ipfs_repo_get_directory(int argc, char** argv, char** repo_dir) {
char* home = ipfs_repo_get_home_directory(argc, argv);
int dir_len = strlen(home) + 7;
*repo_dir = malloc(dir_len);
os_utils_filepath_join(home, ".ipfs", *repo_dir, dir_len);
// it shouldn't include the .ipfs directory, but if it does, we're done
if (strstr(home, ".ipfs") == NULL) {
int dir_len = strlen(home) + 7;
*repo_dir = malloc(dir_len);
os_utils_filepath_join(home, ".ipfs", *repo_dir, dir_len);
} else {
*repo_dir = home;
}
return os_utils_directory_exists(*repo_dir);
}

View file

@ -1,7 +1,11 @@
#include <pthread.h>
#include "../test_helper.h"
#include "libp2p/utils/logger.h"
#include "ipfs/core/client_api.h"
#include "ipfs/core/daemon.h"
#include "ipfs/importer/exporter.h"
#include "ipfs/importer/importer.h"
int test_core_api_startup_shutdown() {
char* repo_path = "/tmp/ipfs_1";
@ -42,9 +46,9 @@ int test_core_api_object_cat() {
pthread_t daemon_thread2;
int thread_started1 = 0;
int thread_started2 = 0;
char* ipfs_path1 = "/tmp/ipfs_1";
char* ipfs_path1 = "/tmp/ipfs_1/.ipfs";
char* config_file1 = "config.test1";
char* ipfs_path2 = "/tmp/ipfs_2";
char* ipfs_path2 = "/tmp/ipfs_2/.ipfs";
char* config_file2 = "config.test2";
struct FSRepo* fs_repo = NULL;
char hash[256] = "";
@ -96,7 +100,7 @@ int test_core_api_object_cat() {
ipfs_node_offline_new(ipfs_path1, &local_node);
ipfs_import_file(NULL, filename, &node, local_node, &bytes_written, 0);
memset(hash, 0, 256);
ipfs_cid_hash_to_base58(node->hash, node->hash_size, hash, 256);
ipfs_cid_hash_to_base58(node->hash, node->hash_size, (unsigned char*)hash, 256);
ipfs_node_free(local_node);
ipfs_hashtable_node_free(node);

View file

@ -48,6 +48,7 @@ const char* names[] = {
"test_cid_cast_non_multihash",
"test_cid_protobuf_encode_decode",
"test_core_api_startup_shutdown",
"test_core_api_object_cat",
"test_daemon_startup_shutdown",
"test_datastore_list_journal",
"test_journal_db",
@ -111,6 +112,7 @@ int (*funcs[])(void) = {
test_cid_cast_non_multihash,
test_cid_protobuf_encode_decode,
test_core_api_startup_shutdown,
test_core_api_object_cat,
test_daemon_startup_shutdown,
test_datastore_list_journal,
test_journal_db,