Skip to content

Commit

Permalink
Blockchain write tests pass
Browse files Browse the repository at this point in the history
Signed-off-by: leonard.kosta <[email protected]>
  • Loading branch information
kostaleonard committed Feb 2, 2024
1 parent bb96995 commit 39f0a4a
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions tests/test_blockchain.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,20 @@ void test_blockchain_write_to_file_creates_nonempty_file() {
assert_true(SUCCESS == return_code);
return_code = blockchain_add_block(blockchain, genesis_block);
assert_true(SUCCESS == return_code);
// TODO
char output_directory[TESTS_MAX_PATH];
get_output_directory(output_directory);
char *outfile = "TODO"; //TEST_OUTPUT_DIR "blockchain";
return_code = blockchain_write_to_file(blockchain, outfile);
assert_true(SUCCESS == return_code);
char outfile[TESTS_MAX_PATH];
snprintf(
outfile,
TESTS_MAX_PATH,
"%s/%s",
output_directory,
"blockchain_test_blockchain_write_to_file_creates_nonempty_file");
struct stat file_stats = {0};
assert_true(0 != stat(outfile, &file_stats));
return_code = blockchain_write_to_file(blockchain, outfile);
assert_true(SUCCESS == return_code);
assert_true(0 == stat(outfile, &file_stats));
assert_true(0 != file_stats.st_size);
blockchain_destroy(blockchain);
}
Expand All @@ -362,8 +368,15 @@ void test_blockchain_write_to_file_fails_on_invalid_input() {
assert_true(SUCCESS == return_code);
return_code = blockchain_add_block(blockchain, genesis_block);
assert_true(SUCCESS == return_code);
// TODO
char *outfile = "TODO"; //TEST_OUTPUT_DIR "blockchain";
char output_directory[TESTS_MAX_PATH];
get_output_directory(output_directory);
char outfile[TESTS_MAX_PATH];
snprintf(
outfile,
TESTS_MAX_PATH,
"%s/%s",
output_directory,
"blockchain_test_blockchain_write_to_file_fails_on_invalid_input");
return_code = blockchain_write_to_file(blockchain, NULL);
assert_true(FAILURE_INVALID_INPUT == return_code);
return_code = blockchain_write_to_file(NULL, outfile);
Expand Down

0 comments on commit 39f0a4a

Please sign in to comment.