aboutsummaryrefslogtreecommitdiff
path: root/src/qt/test
diff options
context:
space:
mode:
authorPhilip Kaufmann <phil.kaufmann@t-online.de>2014-12-05 09:39:23 +0100
committerPhilip Kaufmann <phil.kaufmann@t-online.de>2014-12-08 16:09:01 +0100
commit4333e26c8e89e3d02cfb4d3464108b1a15175e2b (patch)
tree276eb63f3dfbf3b865f38be5a376ed5bb6fd6031 /src/qt/test
parent31f84944a5f6f1aa07e36e7700e9ab16be88aa42 (diff)
[Qt] add BIP70 DoS protection test
- this test required to make readPaymentRequestFromFile() public in order to be able to is it in paymentservertests.cpp
Diffstat (limited to 'src/qt/test')
-rw-r--r--src/qt/test/paymentservertests.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/qt/test/paymentservertests.cpp b/src/qt/test/paymentservertests.cpp
index 84cab01c50..8f49cb9464 100644
--- a/src/qt/test/paymentservertests.cpp
+++ b/src/qt/test/paymentservertests.cpp
@@ -7,6 +7,7 @@
#include "optionsmodel.h"
#include "paymentrequestdata.h"
+#include "random.h"
#include "util.h"
#include "utilstrencodings.h"
@@ -108,6 +109,17 @@ void PaymentServerTests::paymentServerTests()
r.paymentRequest.getMerchant(caStore, merchant);
QCOMPARE(merchant, QString(""));
+ // Just get some random data big enough to trigger BIP70 DoS protection
+ unsigned char randData[BIP70_MAX_PAYMENTREQUEST_SIZE + 1];
+ GetRandBytes(randData, sizeof(randData));
+ // Write data to a temp file:
+ QTemporaryFile tempFile;
+ tempFile.open();
+ tempFile.write((const char*)randData, sizeof(randData));
+ tempFile.close();
+ // Trigger BIP70 DoS protection
+ QCOMPARE(PaymentServer::readPaymentRequestFromFile(tempFile.fileName(), r.paymentRequest), false);
+
delete server;
}