Changeset View
Changeset View
Standalone View
Standalone View
src/test/rpc_tests.cpp
// Copyright (c) 2012-2016 The Bitcoin Core developers | // Copyright (c) 2012-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <rpc/client.h> | #include <rpc/client.h> | ||||
#include <rpc/server.h> | #include <rpc/server.h> | ||||
#include <rpc/util.h> | |||||
#include <config.h> | #include <config.h> | ||||
#include <core_io.h> | #include <core_io.h> | ||||
#include <init.h> | |||||
#include <interfaces/chain.h> | |||||
#include <key_io.h> | #include <key_io.h> | ||||
#include <netbase.h> | #include <netbase.h> | ||||
#include <test/test_bitcoin.h> | #include <test/test_bitcoin.h> | ||||
#include <boost/algorithm/string.hpp> | #include <boost/algorithm/string.hpp> | ||||
#include <boost/test/unit_test.hpp> | #include <boost/test/unit_test.hpp> | ||||
▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | std::string prevout = "[{\"txid\":" | ||||
"fca5b94d6df834e77e108f68e66f126044c052ae\"}]"; | "fca5b94d6df834e77e108f68e66f126044c052ae\"}]"; | ||||
r = CallRPC(std::string("createrawtransaction ") + prevout + " " + | r = CallRPC(std::string("createrawtransaction ") + prevout + " " + | ||||
"{\"3HqAe9LtNBjnsfM4CyYaWTnvCaUYT7v4oZ\":11}"); | "{\"3HqAe9LtNBjnsfM4CyYaWTnvCaUYT7v4oZ\":11}"); | ||||
std::string notsigned = r.get_str(); | std::string notsigned = r.get_str(); | ||||
std::string privkey1 = | std::string privkey1 = | ||||
"\"KzsXybp9jX64P5ekX1KUxRQ79Jht9uzW7LorgwE65i5rWACL6LQe\""; | "\"KzsXybp9jX64P5ekX1KUxRQ79Jht9uzW7LorgwE65i5rWACL6LQe\""; | ||||
std::string privkey2 = | std::string privkey2 = | ||||
"\"Kyhdf5LuKTRx4ge69ybABsiUAWjVRK4XGxAKk2FQLp2HjGMy87Z4\""; | "\"Kyhdf5LuKTRx4ge69ybABsiUAWjVRK4XGxAKk2FQLp2HjGMy87Z4\""; | ||||
InitInterfaces interfaces; | |||||
interfaces.chain = interfaces::MakeChain(); | |||||
g_rpc_interfaces = &interfaces; | |||||
r = CallRPC(std::string("signrawtransactionwithkey ") + notsigned + " [] " + | r = CallRPC(std::string("signrawtransactionwithkey ") + notsigned + " [] " + | ||||
prevout); | prevout); | ||||
BOOST_CHECK(find_value(r.get_obj(), "complete").get_bool() == false); | BOOST_CHECK(find_value(r.get_obj(), "complete").get_bool() == false); | ||||
r = CallRPC(std::string("signrawtransactionwithkey ") + notsigned + " [" + | r = CallRPC(std::string("signrawtransactionwithkey ") + notsigned + " [" + | ||||
privkey1 + "," + privkey2 + "] " + prevout); | privkey1 + "," + privkey2 + "] " + prevout); | ||||
BOOST_CHECK(find_value(r.get_obj(), "complete").get_bool() == true); | BOOST_CHECK(find_value(r.get_obj(), "complete").get_bool() == true); | ||||
g_rpc_interfaces = nullptr; | |||||
} | } | ||||
BOOST_AUTO_TEST_CASE(rpc_rawsign_missing_amount) { | BOOST_AUTO_TEST_CASE(rpc_rawsign_missing_amount) { | ||||
// Old format, missing amount parameter for prevout should generate | // Old format, missing amount parameter for prevout should generate | ||||
// an RPC error. This is because of new replay-protected tx's require | // an RPC error. This is because of new replay-protected tx's require | ||||
// nonzero amount present in signed tx. | // nonzero amount present in signed tx. | ||||
// See: https://github.com/Bitcoin-ABC/bitcoin-abc/issues/63 | // See: https://github.com/Bitcoin-ABC/bitcoin-abc/issues/63 | ||||
// (We will re-use the tx + keys from the above rpc_rawsign test for | // (We will re-use the tx + keys from the above rpc_rawsign test for | ||||
▲ Show 20 Lines • Show All 358 Lines • Show Last 20 Lines |