finally actually writing the config file, although the peerid and private key are not included
This commit is contained in:
parent
d30fa55af7
commit
cba5d5cf20
7 changed files with 187 additions and 6 deletions
|
@ -10,6 +10,8 @@
|
|||
#define test_repo_config_h
|
||||
|
||||
#include "ipfs/repo/config/config.h"
|
||||
#include "ipfs/repo/fsrepo/fs_repo.h"
|
||||
#include "ipfs/os/utils.h"
|
||||
|
||||
int test_repo_config_init() {
|
||||
struct RepoConfig repoConfig;
|
||||
|
@ -27,6 +29,17 @@ int test_repo_config_init() {
|
|||
if (retVal != 0)
|
||||
return 0;
|
||||
|
||||
if (repoConfig.addresses.swarm.num_addresses != 2)
|
||||
return 0;
|
||||
|
||||
retVal = strncmp(repoConfig.addresses.swarm.addresses[0], "/ip4/0.0.0.0/tcp/4001", 21);
|
||||
if (retVal != 0)
|
||||
return 0;
|
||||
|
||||
retVal = strncmp(repoConfig.addresses.swarm.addresses[1], "/ip6/::/tcp/4001", 16);
|
||||
if (retVal != 0)
|
||||
return 0;
|
||||
|
||||
// datastore
|
||||
retVal = strncmp(repoConfig.datastore.path, "/Users/JohnJones/.ipfs/datastore", 32);
|
||||
if (retVal != 0)
|
||||
|
@ -37,4 +50,29 @@ int test_repo_config_init() {
|
|||
return 1;
|
||||
}
|
||||
|
||||
/***
|
||||
* test the writing of the config file
|
||||
*/
|
||||
int test_repo_config_write() {
|
||||
// first delete the existing one
|
||||
unlink("/tmp/config");
|
||||
|
||||
// now build a new one
|
||||
struct RepoConfig repoConfig;
|
||||
if (!repo_config_init(&repoConfig, 2048, "/tmp")) {
|
||||
repo_config_free(&repoConfig);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!fs_repo_write_config_file("/tmp", &repoConfig)) {
|
||||
repo_config_free(&repoConfig);
|
||||
return 0;
|
||||
}
|
||||
|
||||
repo_config_free(&repoConfig);
|
||||
|
||||
// check to see if the file exists
|
||||
return os_utils_file_exists("/tmp/config");
|
||||
}
|
||||
|
||||
#endif /* test_repo_config_h */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue