diff --git a/Makefile b/Makefile index d330145..aca6bdc 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,6 @@ all: cd importer; make all; cd merkledag; make all; cd multibase; make all; - cd node; make all; cd os; make all; cd repo; make all; cd flatfs; make all; @@ -28,7 +27,6 @@ clean: cd importer; make clean; cd merkledag; make clean; cd multibase; make clean; - cd node; make clean; cd os; make clean; cd repo; make clean; cd flatfs; make clean; diff --git a/importer/exporter.c b/importer/exporter.c index 0c72d3c..b26ece7 100644 --- a/importer/exporter.c +++ b/importer/exporter.c @@ -3,7 +3,7 @@ #include "ipfs/cid/cid.h" #include "ipfs/merkledag/merkledag.h" -#include "ipfs/node/node.h" +#include "ipfs/merkledag/node.h" #include "ipfs/repo/fsrepo/fs_repo.h" /** * pull objects from ipfs diff --git a/include/ipfs/importer/importer.h b/include/ipfs/importer/importer.h index b1292a7..34ab524 100644 --- a/include/ipfs/importer/importer.h +++ b/include/ipfs/importer/importer.h @@ -1,7 +1,7 @@ #ifndef __IPFS_IMPORTER_IMPORTER_H__ #define __IPFS_IMPORTER_IMPORTER_H__ -#include "ipfs/node/node.h" +#include "ipfs/merkledag/node.h" #include "ipfs/repo/fsrepo/fs_repo.h" /** diff --git a/include/ipfs/node/Example for this.c b/include/ipfs/merkledag/Example for node.c similarity index 100% rename from include/ipfs/node/Example for this.c rename to include/ipfs/merkledag/Example for node.c diff --git a/include/ipfs/merkledag/merkledag.h b/include/ipfs/merkledag/merkledag.h index 9817187..f58af38 100644 --- a/include/ipfs/merkledag/merkledag.h +++ b/include/ipfs/merkledag/merkledag.h @@ -4,7 +4,7 @@ #ifndef __IPFS_MERKLEDAG_H__ #define __IPFS_MERKLEDAG_H__ -#include "ipfs/node/node.h" +#include "ipfs/merkledag/node.h" #include "ipfs/repo/fsrepo/fs_repo.h" /*** diff --git a/include/ipfs/node/node.h b/include/ipfs/merkledag/node.h similarity index 100% rename from include/ipfs/node/node.h rename to include/ipfs/merkledag/node.h diff --git a/merkledag/Makefile b/merkledag/Makefile index aadae27..4ef37d9 100644 --- a/merkledag/Makefile +++ b/merkledag/Makefile @@ -7,7 +7,7 @@ endif LFLAGS = DEPS = -OBJS = merkledag.o +OBJS = merkledag.o node.o %.o: %.c $(DEPS) $(CC) -c -o $@ $< $(CFLAGS) diff --git a/node/node.c b/merkledag/node.c similarity index 99% rename from node/node.c rename to merkledag/node.c index 18aea32..d2e854c 100644 --- a/node/node.c +++ b/merkledag/node.c @@ -8,7 +8,7 @@ #include "inttypes.h" #include "ipfs/cid/cid.h" -#include "ipfs/node/node.h" +#include "ipfs/merkledag/node.h" // for protobuf Node data & data_size encoded cid link_amount & links enum WireType ipfs_node_message_fields[] = { WIRETYPE_LENGTH_DELIMITED, WIRETYPE_LENGTH_DELIMITED, WIRETYPE_LENGTH_DELIMITED, WIRETYPE_LENGTH_DELIMITED }; diff --git a/node/Makefile b/node/Makefile deleted file mode 100644 index 40240eb..0000000 --- a/node/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -CC = gcc -CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../c-protobuf -Wall - -ifdef DEBUG -CFLAGS += -g3 -endif - -LFLAGS = -DEPS = -OBJS = node.o - -%.o: %.c $(DEPS) - $(CC) -c -o $@ $< $(CFLAGS) - -all: $(OBJS) - -clean: - rm -f *.o diff --git a/test/Makefile b/test/Makefile index dc32871..c5142ad 100644 --- a/test/Makefile +++ b/test/Makefile @@ -12,9 +12,8 @@ OBJS = testit.o test_helper.o \ ../flatfs/flatfs.o \ ../importer/importer.o \ ../importer/exporter.o \ - ../merkledag/merkledag.o \ + ../merkledag/merkledag.o ../merkledag/node.o \ ../multibase/multibase.o \ - ../node/node.o \ ../os/utils.o \ ../repo/fsrepo/fs_repo.o ../repo/fsrepo/jsmn.o ../repo/fsrepo/lmdb_datastore.o \ ../repo/config/config.o ../repo/config/identity.o \ diff --git a/test/merkledag/test_merkledag.h b/test/merkledag/test_merkledag.h index 1c12885..db19787 100644 --- a/test/merkledag/test_merkledag.h +++ b/test/merkledag/test_merkledag.h @@ -1,5 +1,5 @@ #include "ipfs/merkledag/merkledag.h" -#include "ipfs/node/node.h" +#include "ipfs/merkledag/node.h" #include "../test_helper.h" struct FSRepo* createAndOpenRepo(const char* dir) { diff --git a/test/node/test_importer.h b/test/node/test_importer.h index 43bda93..63097d8 100644 --- a/test/node/test_importer.h +++ b/test/node/test_importer.h @@ -131,6 +131,41 @@ int test_import_large_file() { size_t new_file_size = os_utils_file_size("/tmp/test_import_large_file.rsl"); if (new_file_size != bytes_size) { printf("File sizes are different. Should be %lu but the new one is %lu\n", bytes_size, new_file_size); + ipfs_repo_fsrepo_free(fs_repo); + ipfs_node_free(write_node); + ipfs_node_free(read_node); + return 0; + } + + FILE* f1 = fopen("/tmp/test_import_large.tmp", "rb"); + FILE* f2 = fopen("/tmp/test_import_large_file.rsl", "rb"); + + size_t bytes_read1 = 1; + size_t bytes_read2 = 1; + unsigned char buf1[100]; + unsigned char buf2[100]; + // compare bytes of files + while (bytes_read1 != 0 && bytes_read2 != 0) { + bytes_read1 = fread(buf1, 1, 100, f1); + bytes_read2 = fread(buf2, 1, 100, f2); + if (bytes_read1 != bytes_read2) { + printf("Error reading files for comparison. Read %lu bytes of file 1, but %lu bytes of file 2\n", bytes_read1, bytes_read2); + ipfs_repo_fsrepo_free(fs_repo); + ipfs_node_free(write_node); + ipfs_node_free(read_node); + fclose(f1); + fclose(f2); + return 0; + } + if (memcmp(buf1, buf2, bytes_read1) != 0) { + printf("The bytes between the files are different\n"); + ipfs_repo_fsrepo_free(fs_repo); + ipfs_node_free(write_node); + ipfs_node_free(read_node); + fclose(f1); + fclose(f2); + return 0; + } } ipfs_repo_fsrepo_free(fs_repo); diff --git a/test/node/test_node.h b/test/node/test_node.h index 155e72a..b65da53 100644 --- a/test/node/test_node.h +++ b/test/node/test_node.h @@ -1,4 +1,4 @@ -#include "ipfs/node/node.h" +#include "ipfs/merkledag/node.h" int test_node() { //Variables of link: