Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lez_core_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ int64_t LEZCoreModule::get_last_synced_block() {
const WalletFfiError error = wallet_ffi_get_last_synced_block(walletHandle, &block_id);
if (error != SUCCESS) {
fprintf(stderr, "get_last_synced_block: wallet FFI error %d\n", error);
return 0;
return -1;
}
Comment on lines 483 to 487
return static_cast<int64_t>(block_id);
}
Expand All @@ -493,7 +493,7 @@ int64_t LEZCoreModule::get_current_block_height() {
const WalletFfiError error = wallet_ffi_get_current_block_height(walletHandle, &block_height);
if (error != SUCCESS) {
fprintf(stderr, "get_current_block_height: wallet FFI error %d\n", error);
return 0;
return -1;
}
return static_cast<int64_t>(block_height);
}
Expand Down
12 changes: 10 additions & 2 deletions tests/test_lez_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,12 @@ LOGOS_TEST(get_last_synced_block_returns_value) {
LOGOS_ASSERT_EQ(module.get_last_synced_block(), static_cast<int64_t>(55));
}

LOGOS_TEST(get_last_synced_block_error_returns_zero) {
LOGOS_TEST(get_last_synced_block_error_returns_negative_sentinel) {
auto t = LogosTestContext("logos_execution_zone");
t.mockCFunction("wallet_ffi_get_last_synced_block").returns(static_cast<int>(INTERNAL_ERROR));
LEZCoreModule module;

LOGOS_ASSERT_EQ(module.get_last_synced_block(), static_cast<int64_t>(0));
LOGOS_ASSERT_EQ(module.get_last_synced_block(), static_cast<int64_t>(-1));
}

LOGOS_TEST(get_current_block_height_returns_value) {
Expand All @@ -236,6 +236,14 @@ LOGOS_TEST(get_current_block_height_returns_value) {
LOGOS_ASSERT_EQ(module.get_current_block_height(), static_cast<int64_t>(999));
}

LOGOS_TEST(get_current_block_height_error_returns_negative_sentinel) {
auto t = LogosTestContext("logos_execution_zone");
t.mockCFunction("wallet_ffi_get_current_block_height").returns(static_cast<int>(INTERNAL_ERROR));
LEZCoreModule module;

LOGOS_ASSERT_EQ(module.get_current_block_height(), static_cast<int64_t>(-1));
}

// ============================================================================
// Transfers / registration
// ============================================================================
Expand Down
Loading