2017-09-20 12:53:36 +00:00
|
|
|
#include "../test_helper.h"
|
2017-09-13 10:02:59 +00:00
|
|
|
#include "libp2p/utils/logger.h"
|
2017-09-20 14:11:01 +00:00
|
|
|
#include "ipfs/core/client_api.h"
|
|
|
|
#include "ipfs/core/daemon.h"
|
2017-09-13 10:02:59 +00:00
|
|
|
|
|
|
|
int test_core_api_startup_shutdown() {
|
2017-09-20 12:32:12 +00:00
|
|
|
char* repo_path = "/tmp/ipfs_1";
|
|
|
|
char* peer_id = NULL;
|
|
|
|
int retVal = 0;
|
|
|
|
|
|
|
|
if (!drop_and_build_repository(repo_path, 4001, NULL, &peer_id))
|
|
|
|
goto exit;
|
|
|
|
|
|
|
|
// this should start the api
|
2017-09-20 14:11:01 +00:00
|
|
|
test_daemon_start(repo_path);
|
|
|
|
sleep(3);
|
2017-09-20 12:32:12 +00:00
|
|
|
|
2017-09-20 14:11:01 +00:00
|
|
|
struct IpfsNode* client_node = NULL;
|
|
|
|
if (!ipfs_node_offline_new(repo_path, &client_node)) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
// test to see if it is working
|
|
|
|
if (client_node->mode == MODE_API_AVAILABLE)
|
|
|
|
goto exit;
|
2017-09-20 12:32:12 +00:00
|
|
|
|
|
|
|
retVal = 1;
|
2017-09-20 14:11:01 +00:00
|
|
|
// cleanup
|
2017-09-20 12:32:12 +00:00
|
|
|
exit:
|
2017-09-20 14:11:01 +00:00
|
|
|
ipfs_daemon_stop();
|
|
|
|
if (peer_id != NULL)
|
|
|
|
free(peer_id);
|
2017-09-20 12:32:12 +00:00
|
|
|
|
|
|
|
return retVal;
|
2017-09-13 10:02:59 +00:00
|
|
|
}
|
2017-09-20 14:11:01 +00:00
|
|
|
|
|
|
|
int test_core_api_local_object_cat() {
|
|
|
|
// add a file to the store, then use the api to get it
|
|
|
|
return 0;
|
|
|
|
}
|