Auto merge of #1513 - bitcartel:master_1491_fix_help_message_rpc_z_importkey, r=daira

Fixes #1491 by updating help message for rpc call z_importkey
This commit is contained in:
zkbot 2016-10-13 19:05:08 -04:00
commit 8eb672251b
3 changed files with 20 additions and 7 deletions

View File

@ -312,7 +312,9 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_z_exportwallet)
BOOST_CHECK(addrs.size()==1);
BOOST_CHECK_THROW(CallRPC("z_exportwallet"), runtime_error);
BOOST_CHECK_THROW(CallRPC("z_exportwallet toomany args"), runtime_error);
boost::filesystem::path temp = boost::filesystem::temp_directory_path() /
boost::filesystem::unique_path();
@ -362,6 +364,9 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_z_importwallet)
// error if no args
BOOST_CHECK_THROW(CallRPC("z_importwallet"), runtime_error);
// error if too many args
BOOST_CHECK_THROW(CallRPC("z_importwallet toomany args"), runtime_error);
// create a random key locally
auto testSpendingKey = libzcash::SpendingKey::random();
auto testPaymentAddress = testSpendingKey.address();
@ -430,6 +435,10 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_z_importexport)
BOOST_CHECK_THROW(CallRPC("z_importkey"), runtime_error);
BOOST_CHECK_THROW(CallRPC("z_exportkey"), runtime_error);
// error if too many args
BOOST_CHECK_THROW(CallRPC("z_importkey too many args"), runtime_error);
BOOST_CHECK_THROW(CallRPC("z_exportkey toomany args"), runtime_error);
// wallet should currently be empty
std::set<libzcash::PaymentAddress> addrs;
pwalletMain->GetPaymentAddresses(addrs);
@ -490,6 +499,9 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_z_importexport)
CZCPaymentAddress pa(newaddress);
auto newAddr = pa.Get();
BOOST_CHECK(pwalletMain->HaveSpendingKey(newAddr));
// Check if too many args
BOOST_CHECK_THROW(CallRPC("z_getnewaddress toomanyargs"), runtime_error);
}
@ -709,6 +721,9 @@ BOOST_AUTO_TEST_CASE(rpc_z_getoperations)
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
BOOST_CHECK(q->getOperationCount() == 0);
// Check if too many args
BOOST_CHECK_THROW(CallRPC("z_listoperationids toomany args"), runtime_error);
Value retValue;
BOOST_CHECK_NO_THROW(retValue = CallRPC("z_listoperationids"));
BOOST_CHECK(retValue.get_array().size() == 2);

View File

@ -532,9 +532,9 @@ Value z_importkey(const Array& params, bool fHelp)
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() < 1 || params.size() > 3)
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
"z_importkey \"zkey\" ( \"label\" rescan )\n"
"z_importkey \"zkey\" ( rescan )\n"
"\nAdds a zkey (as returned by z_exportkey) to your wallet.\n"
"\nArguments:\n"
"1. \"zkey\" (string, required) The zkey (see z_exportkey)\n"
@ -545,10 +545,8 @@ Value z_importkey(const Array& params, bool fHelp)
+ HelpExampleCli("z_exportkey", "\"myaddress\"") +
"\nImport the zkey with rescan\n"
+ HelpExampleCli("z_importkey", "\"mykey\"") +
"\nImport using a label and without rescan\n"
+ HelpExampleCli("z_importkey", "\"mykey\" \"testing\" false") +
"\nAs a JSON-RPC call\n"
+ HelpExampleRpc("z_importkey", "\"mykey\", \"testing\", false")
+ HelpExampleRpc("z_importkey", "\"mykey\", false")
);
LOCK2(cs_main, pwalletMain->cs_wallet);

View File

@ -2792,7 +2792,7 @@ Value z_getnewaddress(const Array& params, bool fHelp)
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() > 1)
if (fHelp || params.size() > 0)
throw runtime_error(
"z_getnewaddress\n"
"\nReturns a new zaddr for receiving payments.\n"