Last active
August 29, 2015 14:17
-
-
Save dexX7/32accc4b04cb2e7dd496 to your computer and use it in GitHub Desktop.
fatal error in "rpc_flex_table": memory access violation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static const CRPCCommand vRPCTestCommands[] = | |
| { // category name actor (function) okSafeMode reqWallet | |
| // --------------------- ------------------------ ----------------------- ---------- --------- | |
| { "network", "testcmd", &ping_overwrite_tests, true, false }, | |
| }; | |
| // still unsafe | |
| void addTestCommand() | |
| { | |
| unsigned int vcidx; | |
| for (vcidx = 0; vcidx < (sizeof(vRPCTestCommands) / sizeof(vRPCTestCommands[0])); vcidx++) | |
| { | |
| tableRPC.AddOrReplaceCommand(vRPCTestCommands[vcidx]); | |
| } | |
| } | |
| BOOST_AUTO_TEST_CASE(rpc_flex_table) | |
| { | |
| Value r = CallRPC(string("ping")); | |
| BOOST_CHECK(r.is_null()); | |
| addTestCommand(); | |
| BOOST_CHECK_NO_THROW(r = CallRPC(string("testcmd"))); | |
| BOOST_CHECK_EQUAL(find_value(r.get_obj(), "Test").get_str(), "123"); | |
| const CRPCCommand newPingCmd = { "network", "ping", &ping_overwrite_tests, true, false }; | |
| tableRPC.AddOrReplaceCommand(newPingCmd); | |
| BOOST_CHECK_NO_THROW(r = CallRPC(string("ping"))); | |
| BOOST_CHECK_EQUAL(find_value(r.get_obj(), "Test").get_str(), "123"); | |
| } | |
| // safe | |
| void addTestConversions() | |
| { | |
| RPCAddConversion("testcommand", 1); | |
| RPCAddConversion("testcommand", 2); | |
| } | |
| BOOST_AUTO_TEST_CASE(rpc_add_conversion) | |
| { | |
| addTestConversions(); | |
| std::vector<std::string> vstrParams; | |
| vstrParams.push_back("1234"); | |
| vstrParams.push_back("false"); | |
| vstrParams.push_back("481516"); | |
| Array params = RPCConvertValues("testcommand", vstrParams); | |
| BOOST_CHECK_NO_THROW(params[0].get_str()); | |
| BOOST_CHECK_NO_THROW(params[1].get_bool()); | |
| BOOST_CHECK_NO_THROW(params[2].get_int()); | |
| BOOST_CHECK_THROW(params[0].get_int(), std::runtime_error); | |
| BOOST_CHECK_EQUAL(params[0].get_str(), "1234"); | |
| BOOST_CHECK_EQUAL(params[1].get_bool(), false); | |
| BOOST_CHECK_EQUAL(params[2].get_int(), 481516); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment