Minor fixes for yamux testing with GO

This commit is contained in:
John Jones 2017-11-23 07:45:06 -05:00
parent 6160dd841b
commit f96209fc4b
3 changed files with 50 additions and 1 deletions

View file

@ -6,6 +6,12 @@
#include "ipfs/core/swarm.h" #include "ipfs/core/swarm.h"
#include "ipfs/core/http_request.h" #include "ipfs/core/http_request.h"
/***
* Connect to a swarm
* @param local_node the local node
* @param address the address of the remote
* @returns true(1) on success, false(0) otherwise
*/
int ipfs_swarm_connect(struct IpfsNode* local_node, const char* address) { int ipfs_swarm_connect(struct IpfsNode* local_node, const char* address) {
char* response = NULL; char* response = NULL;
size_t response_size; size_t response_size;

View file

@ -0,0 +1,42 @@
#include "stdio.h"
#include "libp2p/utils/logger.h"
#include "ipfs/core/daemon.h"
#include "ipfs/core/swarm.h"
// forward declarations
int ipfs_swarm_connect(struct IpfsNode* local_node, const char* address);
int test_compat_go_join_swarm() {
int retVal = 0;
char* ipfs_path1 = "/tmp/ipfs_1";
char* config_file1 = "config.test1.wo_journal";
pthread_t daemon_thread;
struct FSRepo* fs_repo = NULL;
// Here is the connection information for the GO version:
char* remote_string = "/ip4/10.211.55.2/tcp/4001/ipfs/QmacSE6bCZiAu7nrYkhPATaSoL2q9BszkKzbX6fCiXuBGA";
// build repo
if (!drop_build_open_repo(ipfs_path1, &fs_repo, config_file1)) {
ipfs_repo_fsrepo_free(fs_repo);
libp2p_logger_error("test_api", "Unable to drop and build repository at %s\n", ipfs_path1);
goto exit;
}
ipfs_repo_fsrepo_free(fs_repo);
// start daemon
pthread_create(&daemon_thread, NULL, test_daemon_start, (void*)ipfs_path1);
sleep(3);
// try to connect to a remote swarm
struct IpfsNode *local_node = NULL;
ipfs_node_offline_new(ipfs_path1, &local_node);
ipfs_swarm_connect(local_node, remote_string);
retVal = 1;
exit:
ipfs_daemon_stop();
pthread_join(daemon_thread, NULL);
return retVal;
}

View file

@ -7,6 +7,7 @@
#include "core/test_null.h" #include "core/test_null.h"
#include "core/test_daemon.h" #include "core/test_daemon.h"
#include "core/test_node.h" #include "core/test_node.h"
#include "core/test_compat_go.h"
#include "exchange/test_bitswap.h" #include "exchange/test_bitswap.h"
#include "exchange/test_bitswap_request_queue.h" #include "exchange/test_bitswap_request_queue.h"
#include "flatfs/test_flatfs.h" #include "flatfs/test_flatfs.h"
@ -124,7 +125,6 @@ int build_test_collection() {
add_test("test_merkledag_get_data", test_merkledag_get_data, 1); add_test("test_merkledag_get_data", test_merkledag_get_data, 1);
add_test("test_merkledag_add_node", test_merkledag_add_node, 1); add_test("test_merkledag_add_node", test_merkledag_add_node, 1);
add_test("test_merkledag_add_node_with_links", test_merkledag_add_node_with_links, 1); add_test("test_merkledag_add_node_with_links", test_merkledag_add_node_with_links, 1);
// 50 below
add_test("test_namesys_publisher_publish", test_namesys_publisher_publish, 1); add_test("test_namesys_publisher_publish", test_namesys_publisher_publish, 1);
add_test("test_namesys_resolver_resolve", test_namesys_resolver_resolve, 1); add_test("test_namesys_resolver_resolve", test_namesys_resolver_resolve, 1);
add_test("test_resolver_get", test_resolver_get, 0); // not working (test directory does not exist) add_test("test_resolver_get", test_resolver_get, 0); // not working (test directory does not exist)
@ -142,6 +142,7 @@ int build_test_collection() {
add_test("test_ping", test_ping, 0); // socket connect failed add_test("test_ping", test_ping, 0); // socket connect failed
add_test("test_ping_remote", test_ping_remote, 0); // need to test more add_test("test_ping_remote", test_ping_remote, 0); // need to test more
add_test("test_null_add_provider", test_null_add_provider, 0); // need to test more add_test("test_null_add_provider", test_null_add_provider, 0); // need to test more
add_test("test_compat_go_join_swarm", test_compat_go_join_swarm, 0); // remote must be running
return 1; return 1;
} }