Merge remote-tracking branch 'origin/master' into feat/list-claimable-vouchers

# Conflicts:
#	flake.lock
#	flake.nix
This commit is contained in:
Daniel 2026-06-18 15:46:11 +02:00
commit ea694d8b59
6 changed files with 718 additions and 437 deletions

936
flake.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -2,8 +2,9 @@
description = "Logos Blockchain Module - Qt6 Plugin"; description = "Logos Blockchain Module - Qt6 Plugin";
inputs = { inputs = {
logos-module-builder.url = "github:logos-co/logos-module-builder"; logos-module-builder.url = "github:logos-co/logos-module-builder?ref=bc868bf47f9d797637ac78af814b0db718dde4b8";
logos-blockchain.url = "github:logos-blockchain/logos-blockchain?rev=93b44bd9ff277546df240ca857a20003da953409"; # claimable vouchers C binding # v0.1.3-rc.10-compatible + rust-rapidsnark nix fixes + cli commands + leader_claim C binding + config generation fixes
logos-blockchain.url = "github:logos-blockchain/logos-blockchain?ref=3dc81b4ec49ba977220f3ff432885258265aa986";
}; };
outputs = inputs@{ logos-module-builder, ... }: outputs = inputs@{ logos-module-builder, ... }:

View File

@ -82,10 +82,10 @@ namespace {
uint16_t blend_port_val; uint16_t blend_port_val;
std::string http_addr_data; std::string http_addr_data;
std::string external_address_data; std::string external_address_data;
bool no_public_ip_check_val;
std::string custom_deployment_config_path_data;
Deployment deployment_val{};
std::string state_path_data; std::string state_path_data;
bool ibd_val;
std::string log_filter_data;
std::string kms_file_data;
// The FFI struct with pointers into owned data // The FFI struct with pointers into owned data
GenerateConfigArgs ffi_args{}; GenerateConfigArgs ffi_args{};
@ -150,39 +150,6 @@ namespace {
ffi_args.external_address = nullptr; ffi_args.external_address = nullptr;
} }
// no_public_ip_check (bool -> const bool*)
if (args.contains("no_public_ip_check") && args["no_public_ip_check"].is_boolean()) {
no_public_ip_check_val = args["no_public_ip_check"].get<bool>();
ffi_args.no_public_ip_check = &no_public_ip_check_val;
} else {
ffi_args.no_public_ip_check = nullptr;
}
// deployment (const struct Deployment*)
// Expected format: { "deployment": { "well_known_deployment": "devnet" } }
// OR: { "deployment": { "config_path": "/path/to/config" } }
if (args.contains("deployment") && args["deployment"].is_object()) {
const auto& deployment = args["deployment"];
if (deployment.contains("well_known_deployment") && deployment["well_known_deployment"].is_string()) {
deployment_val.deployment_type = DeploymentType::WellKnown;
const std::string wellknown = deployment["well_known_deployment"].get<std::string>();
if (wellknown == "devnet") {
deployment_val.well_known_deployment = WellKnownDeployment::Devnet;
}
deployment_val.custom_deployment_config_path = nullptr;
} else if (deployment.contains("config_path") && deployment["config_path"].is_string()) {
deployment_val.deployment_type = DeploymentType::Custom;
deployment_val.well_known_deployment = static_cast<WellKnownDeployment>(0);
custom_deployment_config_path_data = deployment["config_path"].get<std::string>();
deployment_val.custom_deployment_config_path = custom_deployment_config_path_data.c_str();
}
ffi_args.deployment = &deployment_val;
} else {
ffi_args.deployment = nullptr;
}
// state_path (string -> const char*) // state_path (string -> const char*)
if (args.contains("state_path") && args["state_path"].is_string()) { if (args.contains("state_path") && args["state_path"].is_string()) {
state_path_data = args["state_path"].get<std::string>(); state_path_data = args["state_path"].get<std::string>();
@ -190,6 +157,30 @@ namespace {
} else { } else {
ffi_args.state_path = nullptr; ffi_args.state_path = nullptr;
} }
// ibd (bool -> const bool*)
if (args.contains("ibd") && args["ibd"].is_boolean()) {
ibd_val = args["ibd"].get<bool>();
ffi_args.ibd = &ibd_val;
} else {
ffi_args.ibd = nullptr;
}
// log_filter (string -> const char*)
if (args.contains("log_filter") && args["log_filter"].is_string()) {
log_filter_data = args["log_filter"].get<std::string>();
ffi_args.log_filter = log_filter_data.c_str();
} else {
ffi_args.log_filter = nullptr;
}
// kms_file (string -> const char*)
if (args.contains("kms_file") && args["kms_file"].is_string()) {
kms_file_data = args["kms_file"].get<std::string>();
ffi_args.kms_file = kms_file_data.c_str();
} else {
ffi_args.kms_file = nullptr;
}
} }
}; };
} // namespace } // namespace
@ -247,13 +238,13 @@ LogosBlockchainModule::~LogosBlockchainModule() {
// Lifecycle // Lifecycle
int LogosBlockchainModule::generate_user_config(const std::string& json_args) { std::string LogosBlockchainModule::generate_user_config(const std::string& json_args) {
json parsed_args; json parsed_args;
try { try {
parsed_args = json::parse(json_args); parsed_args = json::parse(json_args);
} catch (const json::parse_error& e) { } catch (const json::parse_error& e) {
fprintf(stderr, "Failed to parse JSON args: %s\n", e.what()); fprintf(stderr, "Failed to parse JSON args: %s\n", e.what());
return 1; return "1";
} }
const OwnedGenerateConfigArgs owned_args(parsed_args); const OwnedGenerateConfigArgs owned_args(parsed_args);
@ -261,16 +252,16 @@ int LogosBlockchainModule::generate_user_config(const std::string& json_args) {
const OperationStatus status = ::generate_user_config(owned_args.ffi_args); const OperationStatus status = ::generate_user_config(owned_args.ffi_args);
if (!is_ok(&status)) { if (!is_ok(&status)) {
fprintf(stderr, "Failed to generate user config. Error: %d\n", status); fprintf(stderr, "Failed to generate user config. Error: %d\n", status);
return 1; return "1";
} }
return 0; return "0";
} }
int LogosBlockchainModule::start(const std::string& config_path, const std::string& deployment) { std::string LogosBlockchainModule::start(const std::string& config_path, const std::string& deployment) {
if (node) { if (node) {
fprintf(stderr, "Could not execute the operation: The node is already running.\n"); fprintf(stderr, "Could not execute the operation: The node is already running.\n");
return 1; return "1";
} }
const char* module_path_env = std::getenv("LOGOS_MODULE_PATH"); const char* module_path_env = std::getenv("LOGOS_MODULE_PATH");
@ -289,7 +280,7 @@ int LogosBlockchainModule::start(const std::string& config_path, const std::stri
fprintf(stderr, "Using config from LB_CONFIG_PATH: %s\n", effective_config_path.c_str()); fprintf(stderr, "Using config from LB_CONFIG_PATH: %s\n", effective_config_path.c_str());
} else { } else {
fprintf(stderr, "Config path was not specified and LB_CONFIG_PATH is not set.\n"); fprintf(stderr, "Config path was not specified and LB_CONFIG_PATH is not set.\n");
return 3; return "3";
} }
} }
@ -303,7 +294,7 @@ int LogosBlockchainModule::start(const std::string& config_path, const std::stri
fprintf(stderr, "Start node returned with value and error.\n"); fprintf(stderr, "Start node returned with value and error.\n");
if (!is_ok(&error)) { if (!is_ok(&error)) {
fprintf(stderr, "Failed to start the node. Error: %d\n", error); fprintf(stderr, "Failed to start the node. Error: %d\n", error);
return 4; return "4";
} }
node = value; node = value;
@ -311,23 +302,23 @@ int LogosBlockchainModule::start(const std::string& config_path, const std::stri
if (!node) { if (!node) {
fprintf(stderr, "Could not subscribe to block events: The node is not running.\n"); fprintf(stderr, "Could not subscribe to block events: The node is not running.\n");
return 4; return "4";
} }
s_instance = this; s_instance = this;
const OperationStatus subscribe_status = subscribe_to_new_blocks(node, on_new_block_callback); const OperationStatus subscribe_status = subscribe_to_new_blocks(node, on_new_block_callback);
if (!is_ok(&subscribe_status)) { if (!is_ok(&subscribe_status)) {
fprintf(stderr, "Failed to subscribe to new blocks. Error: %d\n", subscribe_status); fprintf(stderr, "Failed to subscribe to new blocks. Error: %d\n", subscribe_status);
return 5; return "5";
} }
return 0; return "0";
} }
int LogosBlockchainModule::stop() { std::string LogosBlockchainModule::stop() {
if (!node) { if (!node) {
fprintf(stderr, "Could not execute the operation: The node is not running.\n"); fprintf(stderr, "Could not execute the operation: The node is not running.\n");
return 1; return "1";
} }
s_instance = nullptr; s_instance = nullptr;
@ -340,36 +331,36 @@ int LogosBlockchainModule::stop() {
} }
node = nullptr; node = nullptr;
return 0; return "0";
} }
// Config management // Config management
int LogosBlockchainModule::update_user_config(const std::string& user_config_path, const std::string& keystore_path) { std::string LogosBlockchainModule::update_user_config(const std::string& user_config_path, const std::string& keystore_path) {
const std::string config = localPathFromFileUrl(user_config_path); const std::string config = localPathFromFileUrl(user_config_path);
const std::string keystore = localPathFromFileUrl(keystore_path); const std::string keystore = localPathFromFileUrl(keystore_path);
const OperationStatus status = ::update_user_config(config.c_str(), keystore.c_str()); const OperationStatus status = ::update_user_config(config.c_str(), keystore.c_str());
if (!is_ok(&status)) { if (!is_ok(&status)) {
fprintf(stderr, "Failed to update user config. Error: %d\n", status); fprintf(stderr, "Failed to update user config. Error: %d\n", status);
return 1; return "1";
} }
return 0; return "0";
} }
int LogosBlockchainModule::migrate_user_config(const std::string& output_path, const std::string& keystore_path) { std::string LogosBlockchainModule::migrate_user_config(const std::string& output_path, const std::string& keystore_path) {
const std::string output = localPathFromFileUrl(output_path); const std::string output = localPathFromFileUrl(output_path);
const std::string keystore = localPathFromFileUrl(keystore_path); const std::string keystore = localPathFromFileUrl(keystore_path);
const OperationStatus status = ::migrate_user_config(output.c_str(), keystore.c_str()); const OperationStatus status = ::migrate_user_config(output.c_str(), keystore.c_str());
if (!is_ok(&status)) { if (!is_ok(&status)) {
fprintf(stderr, "Failed to migrate user config. Error: %d\n", status); fprintf(stderr, "Failed to migrate user config. Error: %d\n", status);
return 1; return "1";
} }
return 0; return "0";
} }
int LogosBlockchainModule::migrate_user_config_0_1_2( std::string LogosBlockchainModule::migrate_user_config_0_1_2(
const std::string& new_config_path, const std::string& new_config_path,
const std::string& old_config_path, const std::string& old_config_path,
const std::string& keystore_path const std::string& keystore_path
@ -382,12 +373,12 @@ int LogosBlockchainModule::migrate_user_config_0_1_2(
::migrate_user_config_0_1_2(new_config.c_str(), old_config.c_str(), keystore.c_str()); ::migrate_user_config_0_1_2(new_config.c_str(), old_config.c_str(), keystore.c_str());
if (!is_ok(&status)) { if (!is_ok(&status)) {
fprintf(stderr, "Failed to migrate 0.1.2 config. Error: %d\n", status); fprintf(stderr, "Failed to migrate 0.1.2 config. Error: %d\n", status);
return 1; return "1";
} }
return 0; return "0";
} }
int LogosBlockchainModule::participate( std::string LogosBlockchainModule::participate(
const std::string& config_path, const std::string& config_path,
const std::string& keystore_path, const std::string& keystore_path,
const std::string& output_dir, const std::string& output_dir,
@ -402,9 +393,9 @@ int LogosBlockchainModule::participate(
::participate(config.c_str(), keystore.c_str(), output.c_str(), external_address_ptr); ::participate(config.c_str(), keystore.c_str(), output.c_str(), external_address_ptr);
if (!is_ok(&status)) { if (!is_ok(&status)) {
fprintf(stderr, "Failed to generate participation data. Error: %d\n", status); fprintf(stderr, "Failed to generate participation data. Error: %d\n", status);
return 1; return "1";
} }
return 0; return "0";
} }
// Keystore // Keystore
@ -438,7 +429,7 @@ std::string LogosBlockchainModule::generate_key(
return result; return result;
} }
int LogosBlockchainModule::add_key( std::string LogosBlockchainModule::add_key(
const std::string& user_config_path, const std::string& user_config_path,
const std::string& keystore_path, const std::string& keystore_path,
const std::string& key_type, const std::string& key_type,
@ -448,7 +439,7 @@ int LogosBlockchainModule::add_key(
KeyType type{}; KeyType type{};
if (!parse_key_type(key_type, type)) { if (!parse_key_type(key_type, type)) {
fprintf(stderr, "Invalid key_type (expected \"ed25519\" or \"zk\").\n"); fprintf(stderr, "Invalid key_type (expected \"ed25519\" or \"zk\").\n");
return 1; return "1";
} }
const std::string config = localPathFromFileUrl(user_config_path); const std::string config = localPathFromFileUrl(user_config_path);
@ -459,12 +450,12 @@ int LogosBlockchainModule::add_key(
::add_key(config.c_str(), keystore.c_str(), type, key_hex.c_str(), key_title_ptr); ::add_key(config.c_str(), keystore.c_str(), type, key_hex.c_str(), key_title_ptr);
if (!is_ok(&status)) { if (!is_ok(&status)) {
fprintf(stderr, "Failed to add key. Error: %d\n", status); fprintf(stderr, "Failed to add key. Error: %d\n", status);
return 1; return "1";
} }
return 0; return "0";
} }
int LogosBlockchainModule::remove_key( std::string LogosBlockchainModule::remove_key(
const std::string& user_config_path, const std::string& user_config_path,
const std::string& keystore_path, const std::string& keystore_path,
const std::string& key_title const std::string& key_title
@ -475,9 +466,9 @@ int LogosBlockchainModule::remove_key(
const OperationStatus status = ::remove_key(config.c_str(), keystore.c_str(), key_title.c_str()); const OperationStatus status = ::remove_key(config.c_str(), keystore.c_str(), key_title.c_str());
if (!is_ok(&status)) { if (!is_ok(&status)) {
fprintf(stderr, "Failed to remove key. Error: %d\n", status); fprintf(stderr, "Failed to remove key. Error: %d\n", status);
return 1; return "1";
} }
return 0; return "0";
} }
// Identity // Identity

View File

@ -22,19 +22,19 @@ public:
// ---- Node ---- // ---- Node ----
// Lifecycle // Lifecycle
int generate_user_config(const std::string& json_args); std::string generate_user_config(const std::string& json_args);
int start(const std::string& config_path, const std::string& deployment); std::string start(const std::string& config_path, const std::string& deployment);
int stop(); std::string stop();
// Config management // Config management
int update_user_config(const std::string& user_config_path, const std::string& keystore_path); std::string update_user_config(const std::string& user_config_path, const std::string& keystore_path);
int migrate_user_config(const std::string& output_path, const std::string& keystore_path); std::string migrate_user_config(const std::string& output_path, const std::string& keystore_path);
int migrate_user_config_0_1_2( std::string migrate_user_config_0_1_2(
const std::string& new_config_path, const std::string& new_config_path,
const std::string& old_config_path, const std::string& old_config_path,
const std::string& keystore_path const std::string& keystore_path
); );
int participate( std::string participate(
const std::string& config_path, const std::string& config_path,
const std::string& keystore_path, const std::string& keystore_path,
const std::string& output_dir, const std::string& output_dir,
@ -49,14 +49,14 @@ public:
const std::string& key_type, const std::string& key_type,
const std::string& key_title const std::string& key_title
); );
int add_key( std::string add_key(
const std::string& user_config_path, const std::string& user_config_path,
const std::string& keystore_path, const std::string& keystore_path,
const std::string& key_type, const std::string& key_type,
const std::string& key_hex, const std::string& key_hex,
const std::string& key_title const std::string& key_title
); );
int remove_key( std::string remove_key(
const std::string& user_config_path, const std::string& user_config_path,
const std::string& keystore_path, const std::string& keystore_path,
const std::string& key_title const std::string& key_title

View File

@ -23,23 +23,12 @@ typedef struct LogosBlockchainNode LogosBlockchainNode;
// Operation status (0 = OK) // Operation status (0 = OK)
typedef int OperationStatus; typedef int OperationStatus;
// Deployment enums
typedef enum { WellKnown, Custom } DeploymentType;
typedef enum { Devnet } WellKnownDeployment;
// Consensus state enum // Consensus state enum
typedef enum { Bootstrapping, Online } State; typedef enum { Bootstrapping, Online } State;
// Key type for generate_key / add_key // Key type for generate_key / add_key
typedef enum { Ed25519, Zk } KeyType; typedef enum { Ed25519, Zk } KeyType;
// Deployment configuration
typedef struct {
DeploymentType deployment_type;
WellKnownDeployment well_known_deployment;
const char* custom_deployment_config_path;
} Deployment;
// Arguments for generate_user_config // Arguments for generate_user_config
typedef struct { typedef struct {
const char** initial_peers; const char** initial_peers;
@ -49,9 +38,10 @@ typedef struct {
const uint16_t* blend_port; const uint16_t* blend_port;
const char* http_addr; const char* http_addr;
const char* external_address; const char* external_address;
const bool* no_public_ip_check;
const Deployment* deployment;
const char* state_path; const char* state_path;
const bool* ibd;
const char* log_filter;
const char* kms_file;
} GenerateConfigArgs; } GenerateConfigArgs;
// Arguments for transfer_funds // Arguments for transfer_funds

View File

@ -59,8 +59,8 @@ static LogosBlockchainModule* createStartedModule(LogosTestContext& t, TempDir&
t.mockCFunction("start_lb_node").returns(1); t.mockCFunction("start_lb_node").returns(1);
t.mockCFunction("subscribe_to_new_blocks").returns(0); t.mockCFunction("subscribe_to_new_blocks").returns(0);
int rc = module->start(tmpDir.filePath("config.json"), ""); std::string rc = module->start(tmpDir.filePath("config.json"), "");
if (rc != 0) { if (rc != "0") {
delete module; delete module;
return nullptr; return nullptr;
} }
@ -77,7 +77,7 @@ LOGOS_TEST(generate_user_config_returns_0_on_success) {
t.mockCFunction("generate_user_config").returns(0); t.mockCFunction("generate_user_config").returns(0);
LOGOS_ASSERT_EQ(module.generate_user_config(R"({"output":"/tmp/test-config.json"})"), 0); LOGOS_ASSERT_EQ(module.generate_user_config(R"({"output":"/tmp/test-config.json"})"), std::string("0"));
LOGOS_ASSERT(t.cFunctionCalled("generate_user_config")); LOGOS_ASSERT(t.cFunctionCalled("generate_user_config"));
} }
@ -87,7 +87,7 @@ LOGOS_TEST(generate_user_config_returns_1_on_failure) {
t.mockCFunction("generate_user_config").returns(1); t.mockCFunction("generate_user_config").returns(1);
LOGOS_ASSERT_EQ(module.generate_user_config("{}"), 1); LOGOS_ASSERT_EQ(module.generate_user_config("{}"), std::string("1"));
} }
LOGOS_TEST(generate_user_config_from_json_string) { LOGOS_TEST(generate_user_config_from_json_string) {
@ -96,7 +96,7 @@ LOGOS_TEST(generate_user_config_from_json_string) {
t.mockCFunction("generate_user_config").returns(0); t.mockCFunction("generate_user_config").returns(0);
LOGOS_ASSERT_EQ(module.generate_user_config(R"({"output":"/tmp/out.json"})"), 0); LOGOS_ASSERT_EQ(module.generate_user_config(R"({"output":"/tmp/out.json"})"), std::string("0"));
LOGOS_ASSERT(t.cFunctionCalled("generate_user_config")); LOGOS_ASSERT(t.cFunctionCalled("generate_user_config"));
} }
@ -113,12 +113,13 @@ LOGOS_TEST(generate_user_config_with_all_fields) {
"blend_port": 9001, "blend_port": 9001,
"http_addr": "0.0.0.0:8080", "http_addr": "0.0.0.0:8080",
"external_address": "1.2.3.4", "external_address": "1.2.3.4",
"no_public_ip_check": true, "state_path": "/tmp/state",
"deployment": { "well_known_deployment": "devnet" }, "ibd": true,
"state_path": "/tmp/state" "log_filter": "warn,logos_blockchain=debug",
"kms_file": "/tmp/kms.yaml"
})"; })";
LOGOS_ASSERT_EQ(module.generate_user_config(args), 0); LOGOS_ASSERT_EQ(module.generate_user_config(args), std::string("0"));
} }
// ============================================================================ // ============================================================================
@ -128,7 +129,7 @@ LOGOS_TEST(generate_user_config_with_all_fields) {
LOGOS_TEST(stop_without_node_returns_1) { LOGOS_TEST(stop_without_node_returns_1) {
auto t = LogosTestContext("blockchain_module"); auto t = LogosTestContext("blockchain_module");
LogosBlockchainModule module; LogosBlockchainModule module;
LOGOS_ASSERT_EQ(module.stop(), 1); LOGOS_ASSERT_EQ(module.stop(), std::string("1"));
} }
LOGOS_TEST(wallet_get_balance_without_node_returns_error) { LOGOS_TEST(wallet_get_balance_without_node_returns_error) {
@ -215,7 +216,7 @@ LOGOS_TEST(start_returns_1_when_already_running) {
auto* module = createStartedModule(t, tmpDir); auto* module = createStartedModule(t, tmpDir);
LOGOS_ASSERT_TRUE(module != nullptr); LOGOS_ASSERT_TRUE(module != nullptr);
LOGOS_ASSERT_EQ(module->start("/tmp/config.json", ""), 1); LOGOS_ASSERT_EQ(module->start("/tmp/config.json", ""), std::string("1"));
delete module; delete module;
} }
@ -225,7 +226,7 @@ LOGOS_TEST(stop_succeeds_with_running_node) {
auto* module = createStartedModule(t, tmpDir); auto* module = createStartedModule(t, tmpDir);
LOGOS_ASSERT_TRUE(module != nullptr); LOGOS_ASSERT_TRUE(module != nullptr);
LOGOS_ASSERT_EQ(module->stop(), 0); LOGOS_ASSERT_EQ(module->stop(), std::string("0"));
LOGOS_ASSERT(t.cFunctionCalled("stop_node")); LOGOS_ASSERT(t.cFunctionCalled("stop_node"));
delete module; delete module;
} }
@ -810,7 +811,7 @@ LOGOS_TEST(update_user_config_returns_0_on_success) {
t.mockCFunction("update_user_config").returns(0); t.mockCFunction("update_user_config").returns(0);
LOGOS_ASSERT_EQ(module.update_user_config("/tmp/config.yaml", "/tmp/keystore.yaml"), 0); LOGOS_ASSERT_EQ(module.update_user_config("/tmp/config.yaml", "/tmp/keystore.yaml"), std::string("0"));
LOGOS_ASSERT(t.cFunctionCalled("update_user_config")); LOGOS_ASSERT(t.cFunctionCalled("update_user_config"));
} }
@ -820,7 +821,7 @@ LOGOS_TEST(update_user_config_returns_1_on_failure) {
t.mockCFunction("update_user_config").returns(1); t.mockCFunction("update_user_config").returns(1);
LOGOS_ASSERT_EQ(module.update_user_config("/tmp/config.yaml", "/tmp/keystore.yaml"), 1); LOGOS_ASSERT_EQ(module.update_user_config("/tmp/config.yaml", "/tmp/keystore.yaml"), std::string("1"));
} }
LOGOS_TEST(migrate_user_config_returns_0_on_success) { LOGOS_TEST(migrate_user_config_returns_0_on_success) {
@ -829,7 +830,7 @@ LOGOS_TEST(migrate_user_config_returns_0_on_success) {
t.mockCFunction("migrate_user_config").returns(0); t.mockCFunction("migrate_user_config").returns(0);
LOGOS_ASSERT_EQ(module.migrate_user_config("/tmp/out.yaml", "/tmp/keystore.yaml"), 0); LOGOS_ASSERT_EQ(module.migrate_user_config("/tmp/out.yaml", "/tmp/keystore.yaml"), std::string("0"));
LOGOS_ASSERT(t.cFunctionCalled("migrate_user_config")); LOGOS_ASSERT(t.cFunctionCalled("migrate_user_config"));
} }
@ -839,7 +840,7 @@ LOGOS_TEST(migrate_user_config_returns_1_on_failure) {
t.mockCFunction("migrate_user_config").returns(1); t.mockCFunction("migrate_user_config").returns(1);
LOGOS_ASSERT_EQ(module.migrate_user_config("/tmp/out.yaml", "/tmp/keystore.yaml"), 1); LOGOS_ASSERT_EQ(module.migrate_user_config("/tmp/out.yaml", "/tmp/keystore.yaml"), std::string("1"));
} }
LOGOS_TEST(migrate_user_config_0_1_2_returns_0_on_success) { LOGOS_TEST(migrate_user_config_0_1_2_returns_0_on_success) {
@ -848,7 +849,7 @@ LOGOS_TEST(migrate_user_config_0_1_2_returns_0_on_success) {
t.mockCFunction("migrate_user_config_0_1_2").returns(0); t.mockCFunction("migrate_user_config_0_1_2").returns(0);
LOGOS_ASSERT_EQ(module.migrate_user_config_0_1_2("/tmp/new.yaml", "/tmp/old.yaml", "/tmp/keystore.yaml"), 0); LOGOS_ASSERT_EQ(module.migrate_user_config_0_1_2("/tmp/new.yaml", "/tmp/old.yaml", "/tmp/keystore.yaml"), std::string("0"));
LOGOS_ASSERT(t.cFunctionCalled("migrate_user_config_0_1_2")); LOGOS_ASSERT(t.cFunctionCalled("migrate_user_config_0_1_2"));
} }
@ -858,7 +859,7 @@ LOGOS_TEST(migrate_user_config_0_1_2_returns_1_on_failure) {
t.mockCFunction("migrate_user_config_0_1_2").returns(1); t.mockCFunction("migrate_user_config_0_1_2").returns(1);
LOGOS_ASSERT_EQ(module.migrate_user_config_0_1_2("/tmp/new.yaml", "/tmp/old.yaml", "/tmp/keystore.yaml"), 1); LOGOS_ASSERT_EQ(module.migrate_user_config_0_1_2("/tmp/new.yaml", "/tmp/old.yaml", "/tmp/keystore.yaml"), std::string("1"));
} }
LOGOS_TEST(participate_returns_0_on_success) { LOGOS_TEST(participate_returns_0_on_success) {
@ -867,7 +868,7 @@ LOGOS_TEST(participate_returns_0_on_success) {
t.mockCFunction("participate").returns(0); t.mockCFunction("participate").returns(0);
LOGOS_ASSERT_EQ(module.participate("/tmp/config.yaml", "/tmp/keystore.yaml", "/tmp/out", ""), 0); LOGOS_ASSERT_EQ(module.participate("/tmp/config.yaml", "/tmp/keystore.yaml", "/tmp/out", ""), std::string("0"));
LOGOS_ASSERT(t.cFunctionCalled("participate")); LOGOS_ASSERT(t.cFunctionCalled("participate"));
} }
@ -877,7 +878,7 @@ LOGOS_TEST(participate_returns_1_on_failure) {
t.mockCFunction("participate").returns(1); t.mockCFunction("participate").returns(1);
LOGOS_ASSERT_EQ(module.participate("/tmp/config.yaml", "/tmp/keystore.yaml", "/tmp/out", "1.2.3.4"), 1); LOGOS_ASSERT_EQ(module.participate("/tmp/config.yaml", "/tmp/keystore.yaml", "/tmp/out", "1.2.3.4"), std::string("1"));
} }
// ============================================================================ // ============================================================================
@ -934,7 +935,7 @@ LOGOS_TEST(add_key_returns_0_on_success) {
t.mockCFunction("add_key").returns(0); t.mockCFunction("add_key").returns(0);
LOGOS_ASSERT_EQ(module.add_key("/tmp/config.yaml", "/tmp/keystore.yaml", "ed25519", VALID_HEX, ""), 0); LOGOS_ASSERT_EQ(module.add_key("/tmp/config.yaml", "/tmp/keystore.yaml", "ed25519", VALID_HEX, ""), std::string("0"));
LOGOS_ASSERT(t.cFunctionCalled("add_key")); LOGOS_ASSERT(t.cFunctionCalled("add_key"));
} }
@ -942,7 +943,7 @@ LOGOS_TEST(add_key_rejects_invalid_key_type) {
auto t = LogosTestContext("blockchain_module"); auto t = LogosTestContext("blockchain_module");
LogosBlockchainModule module; LogosBlockchainModule module;
LOGOS_ASSERT_EQ(module.add_key("/tmp/config.yaml", "/tmp/keystore.yaml", "bogus", VALID_HEX, ""), 1); LOGOS_ASSERT_EQ(module.add_key("/tmp/config.yaml", "/tmp/keystore.yaml", "bogus", VALID_HEX, ""), std::string("1"));
LOGOS_ASSERT_FALSE(t.cFunctionCalled("add_key")); LOGOS_ASSERT_FALSE(t.cFunctionCalled("add_key"));
} }
@ -952,7 +953,7 @@ LOGOS_TEST(add_key_returns_1_on_failure) {
t.mockCFunction("add_key").returns(1); t.mockCFunction("add_key").returns(1);
LOGOS_ASSERT_EQ(module.add_key("/tmp/config.yaml", "/tmp/keystore.yaml", "zk", VALID_HEX, "title"), 1); LOGOS_ASSERT_EQ(module.add_key("/tmp/config.yaml", "/tmp/keystore.yaml", "zk", VALID_HEX, "title"), std::string("1"));
} }
LOGOS_TEST(remove_key_returns_0_on_success) { LOGOS_TEST(remove_key_returns_0_on_success) {
@ -961,7 +962,7 @@ LOGOS_TEST(remove_key_returns_0_on_success) {
t.mockCFunction("remove_key").returns(0); t.mockCFunction("remove_key").returns(0);
LOGOS_ASSERT_EQ(module.remove_key("/tmp/config.yaml", "/tmp/keystore.yaml", "my-key"), 0); LOGOS_ASSERT_EQ(module.remove_key("/tmp/config.yaml", "/tmp/keystore.yaml", "my-key"), std::string("0"));
LOGOS_ASSERT(t.cFunctionCalled("remove_key")); LOGOS_ASSERT(t.cFunctionCalled("remove_key"));
} }
@ -971,7 +972,7 @@ LOGOS_TEST(remove_key_returns_1_on_failure) {
t.mockCFunction("remove_key").returns(1); t.mockCFunction("remove_key").returns(1);
LOGOS_ASSERT_EQ(module.remove_key("/tmp/config.yaml", "/tmp/keystore.yaml", "my-key"), 1); LOGOS_ASSERT_EQ(module.remove_key("/tmp/config.yaml", "/tmp/keystore.yaml", "my-key"), std::string("1"));
} }
// ============================================================================ // ============================================================================