Changeset View
Changeset View
Standalone View
Standalone View
src/qt/test/paymentservertests.cpp
// Copyright (c) 2009-2015 The Bitcoin Core developers | // Copyright (c) 2009-2015 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 "paymentservertests.h" | #include "paymentservertests.h" | ||||
#include "optionsmodel.h" | #include "optionsmodel.h" | ||||
#include "paymentrequestdata.h" | #include "paymentrequestdata.h" | ||||
#include "amount.h" | #include "amount.h" | ||||
#include "interface/node.h" | |||||
#include "random.h" | #include "random.h" | ||||
#include "script/script.h" | #include "script/script.h" | ||||
#include "script/standard.h" | #include "script/standard.h" | ||||
#include "util.h" | #include "util.h" | ||||
#include "utilstrencodings.h" | #include "utilstrencodings.h" | ||||
#include <openssl/x509.h> | #include <openssl/x509.h> | ||||
#include <openssl/x509_vfy.h> | #include <openssl/x509_vfy.h> | ||||
Show All 40 Lines | QObject::disconnect(server, | ||||
&sigCatcher, SLOT(getRecipient(SendCoinsRecipient))); | &sigCatcher, SLOT(getRecipient(SendCoinsRecipient))); | ||||
// Return results from sigCatcher | // Return results from sigCatcher | ||||
return sigCatcher.recipient; | return sigCatcher.recipient; | ||||
} | } | ||||
void PaymentServerTests::paymentServerTests() { | void PaymentServerTests::paymentServerTests() { | ||||
SelectParams(CBaseChainParams::MAIN); | SelectParams(CBaseChainParams::MAIN); | ||||
OptionsModel optionsModel; | auto node = interface::MakeNode(); | ||||
OptionsModel optionsModel(*node); | |||||
PaymentServer *server = new PaymentServer(nullptr, false); | PaymentServer *server = new PaymentServer(nullptr, false); | ||||
X509_STORE *caStore = X509_STORE_new(); | X509_STORE *caStore = X509_STORE_new(); | ||||
X509_STORE_add_cert(caStore, parse_b64der_cert(caCert1_BASE64)); | X509_STORE_add_cert(caStore, parse_b64der_cert(caCert1_BASE64)); | ||||
PaymentServer::LoadRootCAs(caStore); | PaymentServer::LoadRootCAs(caStore); | ||||
server->setOptionsModel(&optionsModel); | server->setOptionsModel(&optionsModel); | ||||
server->uiReady(); | server->uiReady(); | ||||
std::vector<uint8_t> data; | std::vector<uint8_t> data; | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | void PaymentServerTests::paymentServerTests() { | ||||
// Contains a testnet paytoaddress, so payment request network doesn't match | // Contains a testnet paytoaddress, so payment request network doesn't match | ||||
// client network: | // client network: | ||||
data = DecodeBase64(paymentrequest1_cert2_BASE64); | data = DecodeBase64(paymentrequest1_cert2_BASE64); | ||||
byteArray = QByteArray((const char *)&data[0], data.size()); | byteArray = QByteArray((const char *)&data[0], data.size()); | ||||
r.paymentRequest.parse(byteArray); | r.paymentRequest.parse(byteArray); | ||||
// Ensure the request is initialized, because network "main" is default, | // Ensure the request is initialized, because network "main" is default, | ||||
// even for uninizialized payment requests and that will fail our test here. | // even for uninizialized payment requests and that will fail our test here. | ||||
QVERIFY(r.paymentRequest.IsInitialized()); | QVERIFY(r.paymentRequest.IsInitialized()); | ||||
QCOMPARE(PaymentServer::verifyNetwork(r.paymentRequest.getDetails()), | QCOMPARE(PaymentServer::verifyNetwork(*node, r.paymentRequest.getDetails()), | ||||
false); | false); | ||||
// Expired payment request (expires is set to 1 = 1970-01-01 00:00:01): | // Expired payment request (expires is set to 1 = 1970-01-01 00:00:01): | ||||
data = DecodeBase64(paymentrequest2_cert2_BASE64); | data = DecodeBase64(paymentrequest2_cert2_BASE64); | ||||
byteArray = QByteArray((const char *)&data[0], data.size()); | byteArray = QByteArray((const char *)&data[0], data.size()); | ||||
r.paymentRequest.parse(byteArray); | r.paymentRequest.parse(byteArray); | ||||
// Ensure the request is initialized | // Ensure the request is initialized | ||||
QVERIFY(r.paymentRequest.IsInitialized()); | QVERIFY(r.paymentRequest.IsInitialized()); | ||||
▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines |