Skip to content

Conversation

@eito-fis
Copy link
Collaborator

@eito-fis eito-fis commented Apr 24, 2022

Closes #32, Closes #52

In progress, moving tests over to CMocka fixture based structure.

Copy link
Owner

@teadetime teadetime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks amazing, did a look through of it all -- need to understand the composing bit but this looks much cleaner!

project(OlinCoin C CXX)
enable_testing()
#set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_BUILD_TYPE Debug)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change back before final PR


if (block->txs != NULL) {
for (unsigned int i = 0; i < block->num_txs; i++)
if (block->txs[i] != NULL)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check isn't actually needed, it is done in free_tx

@@ -0,0 +1,17 @@
add_library(fixtures STATIC
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting that the fixtures end up requiring all our base libraries

add_subdirectory(global)
add_subdirectory(txs)
add_subdirectory(utils)
add_subdirectory(fixtures)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you handled the cmake stuff very cleanly here

@@ -0,0 +1,66 @@
#include "fixtures_block.h"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks super cool

}

int fixture_setup_utxo_to_tx(void **state) {
utxo_to_tx_init();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure this is done in mempool init...

composition = *state;
*state = NULL;

int i = 0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unclear what composing means or composed fixture (Very small comments in the headers might clear this up)

sub_state = malloc(sizeof(void*) * 2);
fixture_setup_unlinked_tx(&sub_state[0]);
fixture_setup_unlinked_keypair(&sub_state[1]);
*state = sub_state;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

single pointer being set to a double pointer -> not sure what is actually happening here

return NULL;
static void test_utxo_pool_init(void **state) {
(void)state;
assert_ptr_not_equal(utxo_pool_db, NULL);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think we may have discused that we should not check leveldb to Null, maybe we test the init funciton for a valid return ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Implement CMocka Investigate Unit Testing with Cmocka or Check

3 participants