forked from agorise/c-ipfs
Added flatfs, as well as fixed some memory leaks. Valgrind across tests now reports 0 memory leaks.
53 lines
2.8 KiB
C
53 lines
2.8 KiB
C
//
|
|
// test_repo_identity.h
|
|
// c-ipfs
|
|
//
|
|
// Created by John Jones on 10/31/16.
|
|
// Copyright © 2016 JMJAtlanta. All rights reserved.
|
|
//
|
|
|
|
#ifndef test_repo_identity_h
|
|
#define test_repo_identity_h
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "ipfs/repo/config/identity.h"
|
|
#include "libp2p/crypto/encoding/base64.h"
|
|
|
|
int test_repo_config_identity_new() {
|
|
struct Identity* identity;
|
|
int retVal = repo_config_identity_new(&identity);
|
|
if (retVal == 0)
|
|
return 0;
|
|
|
|
retVal = repo_config_identity_init(identity, 2046);
|
|
if (retVal == 0)
|
|
return 0;
|
|
|
|
// now examine it
|
|
int privateKeySize = sizeof(identity->private_key);
|
|
if (privateKeySize < 0) {
|
|
printf("Private key structure size should be greater than 0\n");
|
|
return 0;
|
|
}
|
|
|
|
retVal = repo_config_identity_free(identity);
|
|
|
|
return retVal;
|
|
}
|
|
|
|
// test this key
|
|
int test_repo_config_identity_private_key() {
|
|
const char* priv_b64 = "CAASpwkwggSjAgEAAoIBAQDTDJBWjDzS/HxDNOHazvzH2bu9CPMVHUrrvKRdBUM5ansL6/CC3MVZ6HVm4O6QHRapN6EF2CbrTgI4KBOXIL125Xo8MlROnyfXYk3O5q2tgwL/MbW8kXjtkyCfBak7MUoLOdLU7Svg0gkl3l+uDAiDcCLnwJVcFfq9ch6z4wMOhYJqE5dtx0uXxn6IuKWl1B69FTvBXCc0thw8Rw54b941FDcsBH5ttV9mRNCJym3poZ5qalNgXlxoIIB+PUx5QD+aq7KMJdpAX8HkapBntCOahP/QUceRmma0grlZLeYkH6/oi/hIrM6se3KUZ+F6tBuDFys8UAZy/X2BCUbKjbxtAgMBAAECggEANWfQfpYuLhXGPBt9q6kFPm1SnJtPJ+CpvM2XqhJS2IyhZnrl+bd0G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ox92V0q0bRrD5ztqQwSONI0hSRb1iiMWR6MuFnAFajUJfASjjIlZ6nIQjQslI7vjlvYyyHS/p/Codxap+yJlTLWwVEOXp2D9pWwiMq1xEyf0TH1BosvM=";
|
|
size_t decoded_len = libp2p_crypto_encoding_base64_decode_size(strlen(priv_b64));
|
|
char* out_buff = malloc(sizeof(char) * decoded_len);
|
|
libp2p_crypto_encoding_base64_decode(priv_b64, strlen(priv_b64), out_buff, decoded_len, &decoded_len);
|
|
char str[decoded_len];
|
|
int j = 0;
|
|
free(out_buff);
|
|
// now test
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif /* test_repo_identity_h */
|