Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Benjamin Allred
crown-core
Commits
3b8cedb0
Commit
3b8cedb0
authored
12 years ago
by
Pieter Wuille
Browse files
Options
Download
Email Patches
Plain Diff
Expose CRPCTable via bitcoinrpc.h for testing
parent
c56cb1e1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/bitcoinrpc.cpp
+5
-26
src/bitcoinrpc.cpp
src/bitcoinrpc.h
+34
-0
src/bitcoinrpc.h
src/test/rpc_tests.cpp
+2
-7
src/test/rpc_tests.cpp
with
41 additions
and
33 deletions
+41
-33
src/bitcoinrpc.cpp
View file @
3b8cedb0
...
...
@@ -10,6 +10,7 @@
#include "net.h"
#include "init.h"
#include "ui_interface.h"
#include "bitcoinrpc.h"
#undef printf
#include <boost/asio.hpp>
...
...
@@ -22,9 +23,6 @@
#include <boost/filesystem/fstream.hpp>
typedef
boost
::
asio
::
ssl
::
stream
<
boost
::
asio
::
ip
::
tcp
::
socket
>
SSLStream
;
#include "json/json_spirit_reader_template.h"
#include "json/json_spirit_writer_template.h"
#include "json/json_spirit_utils.h"
#define printf OutputDebugStringF
// MinGW 3.4.5 gets "fatal error: had to relocate PCH" if the json headers are
// precompiled in headers.h. The problem might be when the pch file goes over
...
...
@@ -37,27 +35,6 @@ using namespace boost::asio;
using
namespace
json_spirit
;
void
ThreadRPCServer2
(
void
*
parg
);
typedef Value(*rpcfn_type)(const Array& params, bool fHelp);
class CRPCCommand
{
public:
string name;
rpcfn_type actor;
bool okSafeMode;
};
class CRPCTable
{
private:
map<string, const CRPCCommand*> mapCommands;
public:
CRPCTable();
const CRPCCommand* operator[](string name) const;
string help(string name) const;
};
const CRPCTable tableRPC;
static
std
::
string
strRPCUserColonPass
;
...
...
@@ -2028,7 +2005,7 @@ Value getblock(const Array& params, bool fHelp)
//
static CRPCCommand vRPCCommands[] =
static
const
CRPCCommand
vRPCCommands
[]
=
{
// name function safe mode?
// ------------------------ ----------------------- ----------
{
"help"
,
&
help
,
true
},
...
...
@@ -2084,7 +2061,7 @@ CRPCTable::CRPCTable()
unsigned
int
vcidx
;
for
(
vcidx
=
0
;
vcidx
<
(
sizeof
(
vRPCCommands
)
/
sizeof
(
vRPCCommands
[
0
]));
vcidx
++
)
{
CRPCCommand *pcmd;
const
CRPCCommand
*
pcmd
;
pcmd
=
&
vRPCCommands
[
vcidx
];
mapCommands
[
pcmd
->
name
]
=
pcmd
;
...
...
@@ -2785,3 +2762,5 @@ int main(int argc, char *argv[])
return
0
;
}
#endif
const
CRPCTable
tableRPC
;
This diff is collapsed.
Click to expand it.
src/bitcoinrpc.h
View file @
3b8cedb0
...
...
@@ -3,5 +3,39 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
#ifndef _BITCOINRPC_H_
#define _BITCOINRPC_H_ 1
#include <string>
#include <map>
#include "json/json_spirit_reader_template.h"
#include "json/json_spirit_writer_template.h"
#include "json/json_spirit_utils.h"
void
ThreadRPCServer
(
void
*
parg
);
int
CommandLineRPC
(
int
argc
,
char
*
argv
[]);
typedef
json_spirit
::
Value
(
*
rpcfn_type
)(
const
json_spirit
::
Array
&
params
,
bool
fHelp
);
class
CRPCCommand
{
public:
std
::
string
name
;
rpcfn_type
actor
;
bool
okSafeMode
;
};
class
CRPCTable
{
private:
std
::
map
<
std
::
string
,
const
CRPCCommand
*>
mapCommands
;
public:
CRPCTable
();
const
CRPCCommand
*
operator
[](
std
::
string
name
)
const
;
std
::
string
help
(
std
::
string
name
)
const
;
};
extern
const
CRPCTable
tableRPC
;
#endif
This diff is collapsed.
Click to expand it.
src/test/rpc_tests.cpp
View file @
3b8cedb0
...
...
@@ -3,16 +3,11 @@
#include "base58.h"
#include "util.h"
#include "json/json_spirit_reader_template.h"
#include "json/json_spirit_writer_template.h"
#include "json/json_spirit_utils.h"
#include "bitcoinrpc.h"
using
namespace
std
;
using
namespace
json_spirit
;
typedef
Value
(
*
rpcfn_type
)(
const
Array
&
params
,
bool
fHelp
);
extern
map
<
string
,
rpcfn_type
>
mapCallTable
;
BOOST_AUTO_TEST_SUITE
(
rpc_tests
)
static
Array
...
...
@@ -36,7 +31,7 @@ struct TestNetFixture
BOOST_FIXTURE_TEST_CASE
(
rpc_addmultisig
,
TestNetFixture
)
{
rpcfn_type
addmultisig
=
mapCallT
able
[
"addmultisigaddress"
];
rpcfn_type
addmultisig
=
t
able
RPC
[
"addmultisigaddress"
]
->
actor
;
// old, 65-byte-long:
const
char
*
address1Hex
=
"0434e3e09f49ea168c5bbf53f877ff4206923858aab7c7e1df25bc263978107c95e35065a27ef6f1b27222db0ec97e0e895eaca603d3ee0d4c060ce3d8a00286c8"
;
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help