mirror of https://github.com/lukechilds/komodo.git
Browse Source
try5094f8d
Split off rpc_wallet_tests (Wladimir J. van der Laan)829c920
Move CCryptoKeyStore to crypter.cpp (Wladimir J. van der Laan)ae6ea5a
Update build-unix.md to mention --disable-wallet (Wladimir J. van der Laan)4f9e993
Add --disable-wallet option to build system (Wladimir J. van der Laan)d004d72
Move CAddrDB frrom db to net (Wladimir J. van der Laan)48ba56c
Delimit code with #ifdef ENABLE_WALLET (Wladimir J. van der Laan)991685d
Move getinfo to rpcnet.cpp (Wladimir J. van der Laan)bbb0936
Move HelpExample* from rpcwallet to rpcserver (Wladimir J. van der Laan)
Wladimir J. van der Laan
11 years ago
23 changed files with 687 additions and 537 deletions
@ -0,0 +1,82 @@ |
|||||
|
#include "rpcserver.h" |
||||
|
#include "rpcclient.h" |
||||
|
|
||||
|
#include "base58.h" |
||||
|
|
||||
|
#include <boost/algorithm/string.hpp> |
||||
|
#include <boost/test/unit_test.hpp> |
||||
|
|
||||
|
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); |
||||
|
|
||||
|
BOOST_AUTO_TEST_SUITE(rpc_wallet_tests) |
||||
|
|
||||
|
BOOST_AUTO_TEST_CASE(rpc_addmultisig) |
||||
|
{ |
||||
|
rpcfn_type addmultisig = tableRPC["addmultisigaddress"]->actor; |
||||
|
|
||||
|
// old, 65-byte-long:
|
||||
|
const char address1Hex[] = "0434e3e09f49ea168c5bbf53f877ff4206923858aab7c7e1df25bc263978107c95e35065a27ef6f1b27222db0ec97e0e895eaca603d3ee0d4c060ce3d8a00286c8"; |
||||
|
// new, compressed:
|
||||
|
const char address2Hex[] = "0388c2037017c62240b6b72ac1a2a5f94da790596ebd06177c8572752922165cb4"; |
||||
|
|
||||
|
Value v; |
||||
|
CBitcoinAddress address; |
||||
|
BOOST_CHECK_NO_THROW(v = addmultisig(createArgs(1, address1Hex), false)); |
||||
|
address.SetString(v.get_str()); |
||||
|
BOOST_CHECK(address.IsValid() && address.IsScript()); |
||||
|
|
||||
|
BOOST_CHECK_NO_THROW(v = addmultisig(createArgs(1, address1Hex, address2Hex), false)); |
||||
|
address.SetString(v.get_str()); |
||||
|
BOOST_CHECK(address.IsValid() && address.IsScript()); |
||||
|
|
||||
|
BOOST_CHECK_NO_THROW(v = addmultisig(createArgs(2, address1Hex, address2Hex), false)); |
||||
|
address.SetString(v.get_str()); |
||||
|
BOOST_CHECK(address.IsValid() && address.IsScript()); |
||||
|
|
||||
|
BOOST_CHECK_THROW(addmultisig(createArgs(0), false), runtime_error); |
||||
|
BOOST_CHECK_THROW(addmultisig(createArgs(1), false), runtime_error); |
||||
|
BOOST_CHECK_THROW(addmultisig(createArgs(2, address1Hex), false), runtime_error); |
||||
|
|
||||
|
BOOST_CHECK_THROW(addmultisig(createArgs(1, ""), false), runtime_error); |
||||
|
BOOST_CHECK_THROW(addmultisig(createArgs(1, "NotAValidPubkey"), false), runtime_error); |
||||
|
|
||||
|
string short1(address1Hex, address1Hex+sizeof(address1Hex)-2); // last byte missing
|
||||
|
BOOST_CHECK_THROW(addmultisig(createArgs(2, short1.c_str()), false), runtime_error); |
||||
|
|
||||
|
string short2(address1Hex+1, address1Hex+sizeof(address1Hex)); // first byte missing
|
||||
|
BOOST_CHECK_THROW(addmultisig(createArgs(2, short2.c_str()), false), runtime_error); |
||||
|
} |
||||
|
|
||||
|
BOOST_AUTO_TEST_CASE(rpc_wallet) |
||||
|
{ |
||||
|
// Test RPC calls for various wallet statistics
|
||||
|
Value r; |
||||
|
|
||||
|
BOOST_CHECK_NO_THROW(CallRPC("listunspent")); |
||||
|
BOOST_CHECK_THROW(CallRPC("listunspent string"), runtime_error); |
||||
|
BOOST_CHECK_THROW(CallRPC("listunspent 0 string"), runtime_error); |
||||
|
BOOST_CHECK_THROW(CallRPC("listunspent 0 1 not_array"), runtime_error); |
||||
|
BOOST_CHECK_THROW(CallRPC("listunspent 0 1 [] extra"), runtime_error); |
||||
|
BOOST_CHECK_NO_THROW(r=CallRPC("listunspent 0 1 []")); |
||||
|
BOOST_CHECK(r.get_array().empty()); |
||||
|
|
||||
|
BOOST_CHECK_NO_THROW(CallRPC("listreceivedbyaddress")); |
||||
|
BOOST_CHECK_NO_THROW(CallRPC("listreceivedbyaddress 0")); |
||||
|
BOOST_CHECK_THROW(CallRPC("listreceivedbyaddress not_int"), runtime_error); |
||||
|
BOOST_CHECK_THROW(CallRPC("listreceivedbyaddress 0 not_bool"), runtime_error); |
||||
|
BOOST_CHECK_NO_THROW(CallRPC("listreceivedbyaddress 0 true")); |
||||
|
BOOST_CHECK_THROW(CallRPC("listreceivedbyaddress 0 true extra"), runtime_error); |
||||
|
|
||||
|
BOOST_CHECK_NO_THROW(CallRPC("listreceivedbyaccount")); |
||||
|
BOOST_CHECK_NO_THROW(CallRPC("listreceivedbyaccount 0")); |
||||
|
BOOST_CHECK_THROW(CallRPC("listreceivedbyaccount not_int"), runtime_error); |
||||
|
BOOST_CHECK_THROW(CallRPC("listreceivedbyaccount 0 not_bool"), runtime_error); |
||||
|
BOOST_CHECK_NO_THROW(CallRPC("listreceivedbyaccount 0 true")); |
||||
|
BOOST_CHECK_THROW(CallRPC("listreceivedbyaccount 0 true extra"), runtime_error); |
||||
|
} |
||||
|
|
||||
|
BOOST_AUTO_TEST_SUITE_END() |
Loading…
Reference in new issue