#include <boost/format.hpp>
#include <boost/filesystem.hpp>
+#include <univalue.h>
+
using namespace std;
-using namespace json_spirit;
-extern Array createArgs(int nRequired, const char* address1 = NULL, const char* address2 = NULL);
-extern Value CallRPC(string args);
+extern UniValue createArgs(int nRequired, const char* address1 = NULL, const char* address2 = NULL);
+extern UniValue CallRPC(string args);
extern CWallet* pwalletMain;
-bool find_error(const Object& objError, const std::string& expected) {
+bool find_error(const UniValue& objError, const std::string& expected) {
return find_value(objError, "message").get_str().find(expected) != string::npos;
}
// new, compressed:
const char address2Hex[] = "0388c2037017c62240b6b72ac1a2a5f94da790596ebd06177c8572752922165cb4";
- Value v;
+ UniValue v;
CBitcoinAddress address;
BOOST_CHECK_NO_THROW(v = addmultisig(createArgs(1, address1Hex), false));
address.SetString(v.get_str());
BOOST_AUTO_TEST_CASE(rpc_wallet)
{
// Test RPC calls for various wallet statistics
- Value r;
+ UniValue r;
LOCK2(cs_main, pwalletMain->cs_wallet);
CPubKey demoPubkey = pwalletMain->GenerateNewKey();
CBitcoinAddress demoAddress = CBitcoinAddress(CTxDestination(demoPubkey.GetID()));
- Value retValue;
+ UniValue retValue;
string strAccount = "";
string strPurpose = "receive";
BOOST_CHECK_NO_THROW({ /*Initialize Wallet with an account */
*********************************/
BOOST_CHECK_THROW(CallRPC("getaddressesbyaccount"), runtime_error);
BOOST_CHECK_NO_THROW(retValue = CallRPC("getaddressesbyaccount " + strAccount));
- Array arr = retValue.get_array();
+ UniValue arr = retValue.get_array();
BOOST_CHECK_EQUAL(4, arr.size());
bool notFound = true;
- for (auto a : arr) {
+ for (auto a : arr.getValues()) {
notFound &= CBitcoinAddress(a.get_str()).Get() != demoAddress.Get();
}
BOOST_CHECK(!notFound);
+ /*********************************
+ * fundrawtransaction
+ *********************************/
+ BOOST_CHECK_THROW(CallRPC("fundrawtransaction 28z"), runtime_error);
+ BOOST_CHECK_THROW(CallRPC("fundrawtransaction 01000000000180969800000000001976a91450ce0a4b0ee0ddeb633da85199728b940ac3fe9488ac00000000"), runtime_error);
+
/*
* getblocksubsidy
*/
BOOST_CHECK_THROW(CallRPC("getblocksubsidy too many args"), runtime_error);
BOOST_CHECK_THROW(CallRPC("getblocksubsidy -1"), runtime_error);
BOOST_CHECK_NO_THROW(retValue = CallRPC("getblocksubsidy 50000"));
- Object obj = retValue.get_obj();
- BOOST_CHECK(find_value(obj, "miner") == 10.0);
- BOOST_CHECK(find_value(obj, "founders") == 2.5);
+ UniValue obj = retValue.get_obj();
+ BOOST_CHECK_EQUAL(find_value(obj, "miner").get_real(), 10.0);
+ BOOST_CHECK_EQUAL(find_value(obj, "founders").get_real(), 2.5);
BOOST_CHECK_NO_THROW(retValue = CallRPC("getblocksubsidy 1000000"));
obj = retValue.get_obj();
- BOOST_CHECK(find_value(obj, "miner") == 6.25);
- BOOST_CHECK(find_value(obj, "founders") == 0.0);
+ BOOST_CHECK_EQUAL(find_value(obj, "miner").get_real(), 6.25);
+ BOOST_CHECK_EQUAL(find_value(obj, "founders").get_real(), 0.0);
BOOST_CHECK_NO_THROW(retValue = CallRPC("getblocksubsidy 2000000"));
obj = retValue.get_obj();
- BOOST_CHECK(find_value(obj, "miner") == 3.125);
- BOOST_CHECK(find_value(obj, "founders") == 0.0);
+ BOOST_CHECK_EQUAL(find_value(obj, "miner").get_real(), 3.125);
+ BOOST_CHECK_EQUAL(find_value(obj, "founders").get_real(), 0.0);
}
BOOST_AUTO_TEST_CASE(rpc_wallet_getbalance)
BOOST_CHECK_THROW(CallRPC("z_listreceivedbyaddress tnRZ8bPq2pff3xBWhTJhNkVUkm2uhzksDeW5PvEa7aFKGT9Qi3YgTALZfjaY4jU3HLVKBtHdSXxoPoLA3naMPcHBcY88FcF 1"), runtime_error);
}
+/**
+ * This test covers RPC command z_validateaddress
+ */
+BOOST_AUTO_TEST_CASE(rpc_wallet_z_validateaddress)
+{
+ SelectParams(CBaseChainParams::MAIN);
+
+ LOCK2(cs_main, pwalletMain->cs_wallet);
+
+ UniValue retValue;
+
+ // Check number of args
+ BOOST_CHECK_THROW(CallRPC("z_validateaddress"), runtime_error);
+ BOOST_CHECK_THROW(CallRPC("z_validateaddress toomany args"), runtime_error);
+
+ // Wallet should be empty
+ std::set<libzcash::PaymentAddress> addrs;
+ pwalletMain->GetPaymentAddresses(addrs);
+ BOOST_CHECK(addrs.size()==0);
+
+ // This address is not valid, it belongs to another network
+ BOOST_CHECK_NO_THROW(retValue = CallRPC("z_validateaddress ztaaga95QAPyp1kSQ1hD2kguCpzyMHjxWZqaYDEkzbvo7uYQYAw2S8X4Kx98AvhhofMtQL8PAXKHuZsmhRcanavKRKmdCzk"));
+ UniValue resultObj = retValue.get_obj();
+ bool b = find_value(resultObj, "isvalid").get_bool();
+ BOOST_CHECK_EQUAL(b, false);
+
+ // This address is valid, but the spending key is not in this wallet
+ BOOST_CHECK_NO_THROW(retValue = CallRPC("z_validateaddress zcfA19SDAKRYHLoRDoShcoz4nPohqWxuHcqg8WAxsiB2jFrrs6k7oSvst3UZvMYqpMNSRBkxBsnyjjngX5L55FxMzLKach8"));
+ resultObj = retValue.get_obj();
+ b = find_value(resultObj, "isvalid").get_bool();
+ BOOST_CHECK_EQUAL(b, true);
+ b = find_value(resultObj, "ismine").get_bool();
+ BOOST_CHECK_EQUAL(b, false);
+
+ // Let's import a spending key to the wallet and validate its payment address
+ BOOST_CHECK_NO_THROW(CallRPC("z_importkey SKxoWv77WGwFnUJitQKNEcD636bL4X5Gd6wWmgaA4Q9x8jZBPJXT"));
+ BOOST_CHECK_NO_THROW(retValue = CallRPC("z_validateaddress zcWsmqT4X2V4jgxbgiCzyrAfRT1vi1F4sn7M5Pkh66izzw8Uk7LBGAH3DtcSMJeUb2pi3W4SQF8LMKkU2cUuVP68yAGcomL"));
+ resultObj = retValue.get_obj();
+ b = find_value(resultObj, "isvalid").get_bool();
+ BOOST_CHECK_EQUAL(b, true);
+ b = find_value(resultObj, "ismine").get_bool();
+ BOOST_CHECK_EQUAL(b, true);
+ BOOST_CHECK_EQUAL(find_value(resultObj, "payingkey").get_str(), "f5bb3c888ccc9831e3f6ba06e7528e26a312eec3acc1823be8918b6a3a5e20ad");
+ BOOST_CHECK_EQUAL(find_value(resultObj, "transmissionkey").get_str(), "7a58c7132446564e6b810cf895c20537b3528357dc00150a8e201f491efa9c1a");
+}
+
/*
* This test covers RPC command z_exportwallet
*/
BOOST_AUTO_TEST_CASE(rpc_wallet_z_exportwallet)
{
LOCK2(cs_main, pwalletMain->cs_wallet);
-
+
// wallet should be empty
std::set<libzcash::PaymentAddress> addrs;
pwalletMain->GetPaymentAddresses(addrs);
pwalletMain->GetPaymentAddresses(addrs);
BOOST_CHECK(addrs.size()==1);
+ // Set up paths
+ boost::filesystem::path tmppath = boost::filesystem::temp_directory_path();
+ boost::filesystem::path tmpfilename = boost::filesystem::unique_path("%%%%%%%%");
+ boost::filesystem::path exportfilepath = tmppath / tmpfilename;
+
+ // export will fail since exportdir is not set
+ BOOST_CHECK_THROW(CallRPC(string("z_exportwallet ") + tmpfilename.string()), runtime_error);
+
+ // set exportdir
+ mapArgs["-exportdir"] = tmppath.native();
+
+ // run some tests
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();
- const std::string path = temp.native();
+ BOOST_CHECK_THROW(CallRPC(string("z_exportwallet invalid!*/_chars.txt")), runtime_error);
+
+ BOOST_CHECK_NO_THROW(CallRPC(string("z_exportwallet ") + tmpfilename.string()));
- BOOST_CHECK_NO_THROW(CallRPC(string("z_exportwallet ") + path));
auto addr = paymentAddress.Get();
libzcash::SpendingKey key;
EnsureWalletIsUnlocked();
ifstream file;
- file.open(path.c_str(), std::ios::in | std::ios::ate);
+ file.open(exportfilepath.string().c_str(), std::ios::in | std::ios::ate);
BOOST_CHECK(file.is_open());
bool fVerified = false;
int64_t nFilesize = std::max((int64_t)1, (int64_t)file.tellg());
BOOST_AUTO_TEST_CASE(rpc_wallet_z_importexport)
{
LOCK2(cs_main, pwalletMain->cs_wallet);
- Value retValue;
+ UniValue retValue;
int n1 = 1000; // number of times to import/export
int n2 = 1000; // number of addresses to create and list
// Verify we can list the keys imported
BOOST_CHECK_NO_THROW(retValue = CallRPC("z_listaddresses"));
- Array arr = retValue.get_array();
+ UniValue arr = retValue.get_array();
BOOST_CHECK(arr.size() == n1);
// Put addresses into a set
std::unordered_set<std::string> myaddrs;
- for (Value element : arr) {
+ for (UniValue element : arr.getValues()) {
myaddrs.insert(element.get_str());
}
// Create a set from them
std::unordered_set<std::string> listaddrs;
- for (Value element : arr) {
+ for (UniValue element : arr.getValues()) {
listaddrs.insert(element.get_str());
}
start_execution_clock();
std::this_thread::sleep_for(std::chrono::milliseconds(naptime));
stop_execution_clock();
- set_result(Value("done"));
+ set_result(UniValue(UniValue::VSTR, "done"));
set_state(OperationStatus::SUCCESS);
}
};
BOOST_CHECK_EQUAL(op1->isReady(), false);
BOOST_CHECK_EQUAL(op1->isFailed(), false);
BOOST_CHECK_EQUAL(op1->isSuccess(), true);
- BOOST_CHECK(op1->getError() == Value::null );
- BOOST_CHECK(op1->getResult().is_null() == false );
+ BOOST_CHECK_EQUAL(op1->getError().isNull(), true);
+ BOOST_CHECK_EQUAL(op1->getResult().isNull(), false);
BOOST_CHECK_EQUAL(op1->getStateAsString(), "success");
BOOST_CHECK_NE(op1->getStateAsString(), "executing");
// Check if too many args
BOOST_CHECK_THROW(CallRPC("z_listoperationids toomany args"), runtime_error);
- Value retValue;
+ UniValue retValue;
BOOST_CHECK_NO_THROW(retValue = CallRPC("z_listoperationids"));
BOOST_CHECK(retValue.get_array().size() == 2);
BOOST_CHECK_NO_THROW(retValue = CallRPC("z_getoperationstatus"));
- Array array = retValue.get_array();
+ UniValue array = retValue.get_array();
BOOST_CHECK(array.size() == 2);
// idempotent
array = retValue.get_array();
BOOST_CHECK(array.size() == 2);
- for (Value v : array) {
- Object obj = v.get_obj();
- Value id = find_value(obj, "id");
+ for (UniValue v : array.getValues()) {
+ UniValue obj = v.get_obj();
+ UniValue id = find_value(obj, "id");
- Value result;
+ UniValue result;
// removes result from internal storage
BOOST_CHECK_NO_THROW(result = CallRPC("z_getoperationresult [\"" + id.get_str() + "\"]"));
- Array resultArray = result.get_array();
+ UniValue resultArray = result.get_array();
BOOST_CHECK(resultArray.size() == 1);
- Object resultObj = resultArray.front().get_obj();
- Value resultId = find_value(resultObj, "id");
+ UniValue resultObj = resultArray[0].get_obj();
+ UniValue resultId = find_value(resultObj, "id");
BOOST_CHECK_EQUAL(id.get_str(), resultId.get_str());
// verify the operation has been removed
BOOST_CHECK_THROW(CallRPC("z_sendmany"), runtime_error);
BOOST_CHECK_THROW(CallRPC("z_sendmany toofewargs"), runtime_error);
- BOOST_CHECK_THROW(CallRPC("z_sendmany too many args here"), runtime_error);
+ BOOST_CHECK_THROW(CallRPC("z_sendmany just too many args here"), runtime_error);
// bad from address
BOOST_CHECK_THROW(CallRPC("z_sendmany "
" {\"address\":\"tmQP9L3s31cLsghVYf2Jb5MhKj1jRBPoeQn\", \"amount\":12.0} ]"
), runtime_error);
+ // invalid fee amount, cannot be negative
+ BOOST_CHECK_THROW(CallRPC("z_sendmany "
+ "tmRr6yJonqGK23UVhrKuyvTpF8qxQQjKigJ "
+ "[{\"address\":\"tmQP9L3s31cLsghVYf2Jb5MhKj1jRBPoeQn\", \"amount\":50.0}] "
+ "1 -0.0001"
+ ), runtime_error);
+
+ // invalid fee amount, bigger than MAX_MONEY
+ BOOST_CHECK_THROW(CallRPC("z_sendmany "
+ "tmRr6yJonqGK23UVhrKuyvTpF8qxQQjKigJ "
+ "[{\"address\":\"tmQP9L3s31cLsghVYf2Jb5MhKj1jRBPoeQn\", \"amount\":50.0}] "
+ "1 21000001"
+ ), runtime_error);
+
+ // fee amount is bigger than sum of outputs
+ BOOST_CHECK_THROW(CallRPC("z_sendmany "
+ "tmRr6yJonqGK23UVhrKuyvTpF8qxQQjKigJ "
+ "[{\"address\":\"tmQP9L3s31cLsghVYf2Jb5MhKj1jRBPoeQn\", \"amount\":50.0}] "
+ "1 50.00000001"
+ ), runtime_error);
+
// memo bigger than allowed length of ZC_MEMO_SIZE
std::vector<char> v (2 * (ZC_MEMO_SIZE+1)); // x2 for hexadecimal string format
std::fill(v.begin(),v.end(), 'A');
// Test constructor of AsyncRPCOperation_sendmany
try {
std::shared_ptr<AsyncRPCOperation> operation(new AsyncRPCOperation_sendmany("",{}, {}, -1));
- } catch (const Object& objError) {
+ } catch (const UniValue& objError) {
BOOST_CHECK( find_error(objError, "Minconf cannot be negative"));
}
try {
std::shared_ptr<AsyncRPCOperation> operation(new AsyncRPCOperation_sendmany("",{}, {}, 1));
- } catch (const Object& objError) {
+ } catch (const UniValue& objError) {
BOOST_CHECK( find_error(objError, "From address parameter missing"));
}
try {
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_sendmany("tmRr6yJonqGK23UVhrKuyvTpF8qxQQjKigJ", {}, {}, 1) );
- } catch (const Object& objError) {
+ } catch (const UniValue& objError) {
BOOST_CHECK( find_error(objError, "No recipients"));
}
try {
std::vector<SendManyRecipient> recipients = { SendManyRecipient("dummy",1.0, "") };
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_sendmany("INVALID", recipients, {}, 1) );
- } catch (const Object& objError) {
+ } catch (const UniValue& objError) {
BOOST_CHECK( find_error(objError, "payment address is invalid"));
}
try {
std::vector<SendManyRecipient> recipients = { SendManyRecipient("dummy",1.0, "") };
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_sendmany("zcMuhvq8sEkHALuSU2i4NbNQxshSAYrpCExec45ZjtivYPbuiFPwk6WHy4SvsbeZ4siy1WheuRGjtaJmoD1J8bFqNXhsG6U", recipients, {}, 1) );
- } catch (const Object& objError) {
+ } catch (const UniValue& objError) {
BOOST_CHECK( find_error(objError, "payment address is for wrong network type"));
}
try {
std::vector<SendManyRecipient> recipients = { SendManyRecipient("dummy",1.0, "") };
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_sendmany("ztjiDe569DPNbyTE6TSdJTaSDhoXEHLGvYoUnBU1wfVNU52TEyT6berYtySkd21njAeEoh8fFJUT42kua9r8EnhBaEKqCpP", recipients, {}, 1) );
- } catch (const Object& objError) {
+ } catch (const UniValue& objError) {
BOOST_CHECK( find_error(objError, "no spending key found for zaddr"));
}
}
LOCK(pwalletMain->cs_wallet);
- Value retValue;
+ UniValue retValue;
// add keys manually
BOOST_CHECK_NO_THROW(retValue = CallRPC("getnewaddress"));
try {
proxy.get_memo_from_hex_string(bigmemo);
- } catch (const Object& objError) {
+ } catch (const UniValue& objError) {
BOOST_CHECK( find_error(objError, "too big"));
}
try {
proxy.get_memo_from_hex_string(badmemo);
- } catch (const Object& objError) {
+ } catch (const UniValue& objError) {
BOOST_CHECK( find_error(objError, "hexadecimal format"));
}
std::string oddmemo(v.begin(), v.end());
try {
proxy.get_memo_from_hex_string(oddmemo);
- } catch (const Object& objError) {
+ } catch (const UniValue& objError) {
BOOST_CHECK( find_error(objError, "hexadecimal format"));
}
}
// Raw joinsplit is a zaddr->zaddr
{
std::string raw = "020000000000000000000100000000000000001027000000000000183a0d4c46c369078705e39bcfebee59a978dbd210ce8de3efc9555a03fbabfd3cea16693d730c63850d7e48ccde79854c19adcb7e9dcd7b7d18805ee09083f6b16e1860729d2d4a90e2f2acd009cf78b5eb0f4a6ee4bdb64b1262d7ce9eb910c460b02022991e968d0c50ee44908e4ccccbc591d0053bcca154dd6d6fc400a29fa686af4682339832ccea362a62aeb9df0d5aa74f86a1e75ac0f48a8ccc41e0a940643c6c33e1d09223b0a46eaf47a1bb4407cfc12b1dcf83a29c0cef51e45c7876ca5b9e5bae86d92976eb3ef68f29cd29386a8be8451b50f82bf9da10c04651868655194da8f6ed3d241bb5b5ff93a3e2bbe44644544d88bcde5cc35978032ee92699c7a61fcbb395e7583f47e698c4d53ede54f956629400bf510fb5e22d03158cc10bdcaaf29e418ef18eb6480dd9c8b9e2a377809f9f32a556ef872febd0021d4ad013aa9f0b7255e98e408d302abefd33a71180b720271835b487ab309e160b06dfe51932120fb84a7ede16b20c53599a11071592109e10260f265ee60d48c62bfe24074020e9b586ce9e9356e68f2ad1a9538258234afe4b83a209f178f45202270eaeaeecaf2ce3100b2c5a714f75f35777a9ebff5ebf47059d2bbf6f3726190216468f2b152673b766225b093f3a2f827c86d6b48b42117fec1d0ac38dd7af700308dcfb02eba821612b16a2c164c47715b9b0c93900893b1aba2ea03765c94d87022db5be06ab338d1912e0936dfe87586d0a8ee49144a6cd2e306abdcb652faa3e0222739deb23154d778b50de75069a4a2cce1208cd1ced3cb4744c9888ce1c2fcd2e66dc31e62d3aa9e423d7275882525e9981f92e84ac85975b8660739407efbe1e34c2249420fde7e17db3096d5b22e83d051d01f0e6e7690dca7d168db338aadf0897fedac10de310db2b1bff762d322935dddbb60c2efb8b15d231fa17b84630371cb275c209f0c4c7d0c68b150ea5cd514122215e3f7fcfb351d69514788d67c2f3c8922581946e3a04bdf1f07f15696ca76eb95b10698bf1188fd882945c57657515889d042a6fc45d38cbc943540c4f0f6d1c45a1574c81f3e42d1eb8702328b729909adee8a5cfed7c79d54627d1fd389af941d878376f7927b9830ca659bf9ab18c5ca5192d52d02723008728d03701b8ab3e1c4a3109409ec0b13df334c7deec3523eeef4c97b5603e643de3a647b873f4c1b47fbfc6586ba66724f112e51fc93839648005043620aa3ce458e246d77977b19c53d98e3e812de006afc1a79744df236582943631d04cc02941ac4be500e4ed9fb9e3e7cc187b1c4050fad1d9d09d5fd70d5d01d615b439d8c0015d2eb10398bcdbf8c4b2bd559dbe4c288a186aed3f86f608da4d582e120c4a896e015e2241900d1daeccd05db968852677c71d752bec46de9962174b46f980e8cc603654daf8b98a3ee92dac066033954164a89568b70b1780c2ce2410b2f816dbeddb2cd463e0c8f21a52cf6427d9647a6fd4bafa8fb4cd4d47ac057b0160bee86c6b2fb8adce214c2bcdda277512200adf0eaa5d2114a2c077b009836a68ec254bfe56f51d147b9afe2ddd9cb917c0c2de19d81b7b8fd9f4574f51fa1207630dc13976f4d7587c962f761af267de71f3909a576e6bedaf6311633910d291ac292c467cc8331ef577aef7646a5d949322fa0367a49f20597a13def53136ee31610395e3e48d291fd8f58504374031fe9dcfba5e06086ebcf01a9106f6a4d6e16e19e4c5bb893f7da79419c94eca31a384be6fa1747284dee0fc3bbc8b1b860172c10b29c1594bb8c747d7fe05827358ff2160f49050001625ffe2e880bd7fc26cd0ffd89750745379a8e862816e08a5a2008043921ab6a4976064ac18f7ee37b6628bc0127d8d5ebd3548e41d8881a082d86f20b32e33094f15a0e6ea6074b08c6cd28142de94713451640a55985051f5577eb54572699d838cb34a79c8939e981c0c277d06a6e2ce69ccb74f8a691ff08f81d8b99e6a86223d29a2b7c8e7b041aba44ea678ae654277f7e91cbfa79158b989164a3d549d9f4feb0cc43169699c13e321fe3f4b94258c75d198ff9184269cd6986c55409e07528c93f64942c6c283ce3917b4bf4c3be2fe3173c8c38cccb35f1fbda0ca88b35a599c0678cb22aa8eabea8249dbd2e4f849fffe69803d299e435ebcd7df95854003d8eda17a74d98b4be0e62d45d7fe48c06a6f464a14f8e0570077cc631279092802a89823f031eef5e1028a6d6fdbd502869a731ee7d28b4d6c71b419462a30d31442d3ee444ffbcbd16d558c9000c97e949c2b1f9d6f6d8db7b9131ebd963620d3fc8595278d6f8fdf49084325373196d53e64142fa5a23eccd6ef908c4d80b8b3e6cc334b7f7012103a3682e4678e9b518163d262a39a2c1a69bf88514c52b7ccd7cc8dc80e71f7c2ec0701cff982573eb0c2c4daeb47fa0b586f4451c10d1da2e5d182b03dd067a5e971b3a6138ca6667aaf853d2ac03b80a1d5870905f2cfb6c78ec3c3719c02f973d638a0f973424a2b0f2b0023f136d60092fe15fba4bc180b9176bd0ff576e053f1af6939fe9ca256203ffaeb3e569f09774d2a6cbf91873e56651f4d6ff77e0b5374b0a1a201d7e523604e0247644544cc571d48c458a4f96f45580b";
- Object obj;
+ UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("rawtxn", raw));
// we have the spending key for the dummy recipient zaddr1
// Verify test mode is returning output (since no input taddrs, signed and unsigned are the same).
BOOST_CHECK_NO_THROW( proxy.sign_send_raw_transaction(obj) );
- Value result = operation->getResult();
- BOOST_CHECK(!result.is_null());
- Object resultObj = result.get_obj();
+ UniValue result = operation->getResult();
+ BOOST_CHECK(!result.isNull());
+ UniValue resultObj = result.get_obj();
std::string hex = find_value(resultObj, "hex").get_str();
BOOST_CHECK_EQUAL(hex, raw);
}
BOOST_AUTO_TEST_CASE(rpc_wallet_encrypted_wallet_zkeys)
{
LOCK2(cs_main, pwalletMain->cs_wallet);
- Value retValue;
+ UniValue retValue;
int n = 100;
// wallet should currently be empty
// Verify we can list the keys imported
BOOST_CHECK_NO_THROW(retValue = CallRPC("z_listaddresses"));
- Array arr = retValue.get_array();
+ UniValue arr = retValue.get_array();
BOOST_CHECK(arr.size() == n);
+ // Verify that the wallet encryption RPC is disabled
+ BOOST_CHECK_THROW(CallRPC("encryptwallet passphrase"), runtime_error);
+
// Encrypt the wallet (we can't call RPC encryptwallet as that shuts down node)
SecureString strWalletPass;
strWalletPass.reserve(100);