diff --git a/include/svm/enhanced_engine.h b/include/svm/enhanced_engine.h index 7e2c2075..4e908531 100644 --- a/include/svm/enhanced_engine.h +++ b/include/svm/enhanced_engine.h @@ -67,7 +67,7 @@ class EnhancedExecutionEngine : public ExecutionEngine { ~ThreadPool(); template - auto enqueue(F&& f) -> std::future::type>; + auto enqueue(F&& f) -> std::future>; void shutdown(); diff --git a/src/svm/enhanced_engine.cpp b/src/svm/enhanced_engine.cpp index fdcfb096..47764fb4 100644 --- a/src/svm/enhanced_engine.cpp +++ b/src/svm/enhanced_engine.cpp @@ -308,9 +308,9 @@ EnhancedExecutionEngine::ThreadPool::~ThreadPool() { template auto EnhancedExecutionEngine::ThreadPool::enqueue(F&& f) - -> std::future::type> { + -> std::future> { - using return_type = typename std::result_of::type; + using return_type = typename std::invoke_result_t; auto task = std::make_shared>( std::forward(f) diff --git a/src/svm/spl_programs.cpp b/src/svm/spl_programs.cpp index 9e185dda..f2eb812d 100644 --- a/src/svm/spl_programs.cpp +++ b/src/svm/spl_programs.cpp @@ -300,7 +300,7 @@ ExecutionOutcome ExtendedSystemProgram::handle_initialize_nonce( ProgramAccount& nonce_account = context.accounts[nonce_account_key]; nonce_account.program_id = EXTENDED_SYSTEM_PROGRAM_ID; nonce_account.executable = false; - nonce_account.lamports = std::max(nonce_account.lamports, 1447680UL); // Rent-exempt + nonce_account.lamports = std::max(nonce_account.lamports, static_cast(1447680UL)); // Rent-exempt nonce_account.rent_epoch = context.current_epoch; // Initialize nonce account data diff --git a/test_rpc_simple.cpp b/test_rpc_simple.cpp deleted file mode 100644 index 138120d8..00000000 --- a/test_rpc_simple.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "network/rpc_server.h" -#include -#include - -int main() { - slonana::common::ValidatorConfig config; - config.rpc_bind_address = "127.0.0.1:18899"; - - slonana::network::SolanaRpcServer rpc_server(config); - rpc_server.start(); - - // Test basic RPC methods - std::vector test_requests = { - R"({"jsonrpc":"2.0","method":"getHealth","params":"","id":"1"})", - R"({"jsonrpc":"2.0","method":"getSlot","params":"","id":"2"})", - R"({"jsonrpc":"2.0","method":"getVersion","params":"","id":"3"})", - R"({"jsonrpc":"2.0","method":"getAccountInfo","params":["11111111111111111111111111111112"],"id":"4"})", - R"({"jsonrpc":"2.0","method":"getBalance","params":["11111111111111111111111111111112"],"id":"5"})", - R"({"jsonrpc":"2.0","method":"getBlock","params":[1],"id":"6"})", - R"({"jsonrpc":"2.0","method":"getTransaction","params":["signature123"],"id":"7"})", - R"({"jsonrpc":"2.0","method":"unknown_method","params":"","id":"8"})" - }; - - std::cout << "Testing Solana RPC API Implementation:\n\n"; - - for (const auto& request : test_requests) { - std::cout << "Request: " << request << "\n"; - std::string response = rpc_server.handle_request(request); - std::cout << "Response: " << response << "\n\n"; - } - - rpc_server.stop(); - return 0; -} \ No newline at end of file diff --git a/test_solana_mcp.cpp b/test_solana_mcp.cpp deleted file mode 100644 index f398e5fc..00000000 --- a/test_solana_mcp.cpp +++ /dev/null @@ -1,251 +0,0 @@ -#include "network/rpc_server.h" -#include -#include -#include -#include - -class SolanaRpcTester { -private: - slonana::network::SolanaRpcServer* rpc_server_; - -public: - SolanaRpcTester(slonana::network::SolanaRpcServer* server) : rpc_server_(server) {} - - void test_method(const std::string& method_name, const std::string& request, const std::string& expected_fields = "") { - std::cout << "\nšŸ”¹ Testing " << method_name << "\n"; - std::cout << "Request: " << request << "\n"; - - std::string response = rpc_server_->handle_request(request); - std::cout << "Response: " << response << "\n"; - - // Basic validation - bool valid = true; - std::vector errors; - - if (response.find("\"jsonrpc\":\"2.0\"") == std::string::npos) { - valid = false; - errors.push_back("Missing JSON-RPC 2.0 field"); - } - - if (response.find("\"id\":") == std::string::npos) { - valid = false; - errors.push_back("Missing ID field"); - } - - bool has_result = response.find("\"result\":") != std::string::npos; - bool has_error = response.find("\"error\":") != std::string::npos; - - if (!has_result && !has_error) { - valid = false; - errors.push_back("Missing both result and error fields"); - } - - if (has_result && has_error) { - valid = false; - errors.push_back("Both result and error fields present"); - } - - // Check expected fields if provided - if (!expected_fields.empty() && has_result) { - if (response.find(expected_fields) == std::string::npos) { - valid = false; - errors.push_back("Missing expected field: " + expected_fields); - } - } - - if (valid) { - std::cout << "āœ… PASS\n"; - } else { - std::cout << "āŒ FAIL: "; - for (const auto& error : errors) { - std::cout << error << "; "; - } - std::cout << "\n"; - } - } - - void run_comprehensive_test() { - std::cout << "šŸš€ Solana RPC API Comprehensive Test Suite\n"; - std::cout << "==========================================\n"; - - // Account Methods - std::cout << "\nšŸ“ Account Methods\n"; - test_method("getAccountInfo", - R"({"jsonrpc":"2.0","method":"getAccountInfo","params":["11111111111111111111111111111112"],"id":"1"})", - "\"context\""); - - test_method("getBalance", - R"({"jsonrpc":"2.0","method":"getBalance","params":["11111111111111111111111111111112"],"id":"2"})", - "\"value\""); - - test_method("getProgramAccounts", - R"({"jsonrpc":"2.0","method":"getProgramAccounts","params":["11111111111111111111111111111112"],"id":"3"})", - ""); - - test_method("getMultipleAccounts", - R"({"jsonrpc":"2.0","method":"getMultipleAccounts","params":[["11111111111111111111111111111112","11111111111111111111111111111113"]],"id":"4"})", - ""); - - test_method("getLargestAccounts", - R"({"jsonrpc":"2.0","method":"getLargestAccounts","params":[],"id":"5"})", - ""); - - test_method("getMinimumBalanceForRentExemption", - R"({"jsonrpc":"2.0","method":"getMinimumBalanceForRentExemption","params":[0],"id":"6"})", - ""); - - // Block Methods - std::cout << "\nšŸ”— Block Methods\n"; - test_method("getSlot", - R"({"jsonrpc":"2.0","method":"getSlot","params":[],"id":"7"})", - ""); - - test_method("getBlock", - R"({"jsonrpc":"2.0","method":"getBlock","params":[1],"id":"8"})", - "\"blockHash\""); - - test_method("getBlockHeight", - R"({"jsonrpc":"2.0","method":"getBlockHeight","params":[],"id":"9"})", - ""); - - test_method("getBlocks", - R"({"jsonrpc":"2.0","method":"getBlocks","params":[0,10],"id":"10"})", - ""); - - test_method("getFirstAvailableBlock", - R"({"jsonrpc":"2.0","method":"getFirstAvailableBlock","params":[],"id":"11"})", - ""); - - test_method("getGenesisHash", - R"({"jsonrpc":"2.0","method":"getGenesisHash","params":[],"id":"12"})", - ""); - - test_method("getSlotLeaders", - R"({"jsonrpc":"2.0","method":"getSlotLeaders","params":[0,10],"id":"13"})", - ""); - - test_method("getBlockProduction", - R"({"jsonrpc":"2.0","method":"getBlockProduction","params":[],"id":"14"})", - ""); - - // Transaction Methods - std::cout << "\nšŸ’ø Transaction Methods\n"; - test_method("getTransaction", - R"({"jsonrpc":"2.0","method":"getTransaction","params":["signature123"],"id":"15"})", - ""); - - test_method("sendTransaction", - R"({"jsonrpc":"2.0","method":"sendTransaction","params":["base64encodedtransaction"],"id":"16"})", - ""); - - test_method("simulateTransaction", - R"({"jsonrpc":"2.0","method":"simulateTransaction","params":["base64encodedtransaction"],"id":"17"})", - ""); - - test_method("getSignatureStatuses", - R"({"jsonrpc":"2.0","method":"getSignatureStatuses","params":[["signature1","signature2"]],"id":"18"})", - ""); - - test_method("getConfirmedSignaturesForAddress2", - R"({"jsonrpc":"2.0","method":"getConfirmedSignaturesForAddress2","params":["11111111111111111111111111111112"],"id":"19"})", - ""); - - // Network Methods - std::cout << "\n🌐 Network Methods\n"; - test_method("getClusterNodes", - R"({"jsonrpc":"2.0","method":"getClusterNodes","params":[],"id":"20"})", - ""); - - test_method("getVersion", - R"({"jsonrpc":"2.0","method":"getVersion","params":[],"id":"21"})", - "\"solana-core\""); - - test_method("getHealth", - R"({"jsonrpc":"2.0","method":"getHealth","params":[],"id":"22"})", - "\"ok\""); - - test_method("getIdentity", - R"({"jsonrpc":"2.0","method":"getIdentity","params":[],"id":"23"})", - ""); - - // Validator Methods - std::cout << "\nšŸ›ļø Validator Methods\n"; - test_method("getVoteAccounts", - R"({"jsonrpc":"2.0","method":"getVoteAccounts","params":[],"id":"24"})", - ""); - - test_method("getLeaderSchedule", - R"({"jsonrpc":"2.0","method":"getLeaderSchedule","params":[],"id":"25"})", - ""); - - test_method("getEpochInfo", - R"({"jsonrpc":"2.0","method":"getEpochInfo","params":[],"id":"26"})", - ""); - - test_method("getEpochSchedule", - R"({"jsonrpc":"2.0","method":"getEpochSchedule","params":[],"id":"27"})", - ""); - - // Staking Methods - std::cout << "\nšŸ’° Staking Methods\n"; - test_method("getStakeActivation", - R"({"jsonrpc":"2.0","method":"getStakeActivation","params":["11111111111111111111111111111112"],"id":"28"})", - ""); - - test_method("getInflationGovernor", - R"({"jsonrpc":"2.0","method":"getInflationGovernor","params":[],"id":"29"})", - ""); - - test_method("getInflationRate", - R"({"jsonrpc":"2.0","method":"getInflationRate","params":[],"id":"30"})", - ""); - - test_method("getInflationReward", - R"({"jsonrpc":"2.0","method":"getInflationReward","params":[["11111111111111111111111111111112"]],"id":"31"})", - ""); - - // Utility Methods - std::cout << "\nšŸ”§ Utility Methods\n"; - test_method("getRecentBlockhash", - R"({"jsonrpc":"2.0","method":"getRecentBlockhash","params":[],"id":"32"})", - ""); - - test_method("getFeeForMessage", - R"({"jsonrpc":"2.0","method":"getFeeForMessage","params":["base64message"],"id":"33"})", - ""); - - test_method("getLatestBlockhash", - R"({"jsonrpc":"2.0","method":"getLatestBlockhash","params":[],"id":"34"})", - "\"blockhash\""); - - test_method("isBlockhashValid", - R"({"jsonrpc":"2.0","method":"isBlockhashValid","params":["11111111111111111111111111111112"],"id":"35"})", - ""); - - // Error Cases - std::cout << "\nā— Error Cases\n"; - test_method("unknown_method", - R"({"jsonrpc":"2.0","method":"unknown_method","params":[],"id":"36"})", - ""); - - test_method("invalid_json", - R"({"invalid":"json})", - ""); - - std::cout << "\nšŸ Test Suite Complete!\n"; - } -}; - -int main() { - slonana::common::ValidatorConfig config; - config.rpc_bind_address = "127.0.0.1:18899"; - - slonana::network::SolanaRpcServer rpc_server(config); - rpc_server.start(); - - SolanaRpcTester tester(&rpc_server); - tester.run_comprehensive_test(); - - rpc_server.stop(); - return 0; -} \ No newline at end of file