Browse Source

Merge pull request #1658 from TheBlueMatt/qttest

Fix several issues in the Qt unit tests.
0.8
Jeff Garzik 12 years ago
parent
commit
2c006b0b3e
  1. 7
      src/makefile.linux-mingw
  2. 6
      src/qt/guiutil.cpp
  3. 4
      src/qt/sendcoinsdialog.cpp
  4. 7
      src/qt/test/test_main.cpp
  5. 2
      src/qt/test/uritests.cpp

7
src/makefile.linux-mingw

@ -7,11 +7,12 @@ DEPSDIR:=/usr/i586-mingw32msvc
USE_UPNP:=0 USE_UPNP:=0
INCLUDEPATHS= \ INCLUDEPATHS= \
-I"$(CURDIR)" \
-I"$(CURDIR)"/obj \
-I"$(DEPSDIR)/boost_1_49_0" \ -I"$(DEPSDIR)/boost_1_49_0" \
-I"$(DEPSDIR)/db-4.8.30.NC/build_unix" \ -I"$(DEPSDIR)/db-4.8.30.NC/build_unix" \
-I"$(DEPSDIR)/openssl-1.0.1b/include" \ -I"$(DEPSDIR)/openssl-1.0.1b/include" \
-I"$(DEPSDIR)" \ -I"$(DEPSDIR)"
-I"$(CURDIR)"/obj \
LIBPATHS= \ LIBPATHS= \
-L"$(DEPSDIR)/boost_1_49_0/stage/lib" \ -L"$(DEPSDIR)/boost_1_49_0/stage/lib" \
@ -88,7 +89,7 @@ obj-test/%.o: test/%.cpp $(HEADERS)
i586-mingw32msvc-g++ -c $(TESTDEFS) $(CFLAGS) -o $@ $< i586-mingw32msvc-g++ -c $(TESTDEFS) $(CFLAGS) -o $@ $<
test_bitcoin.exe: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%)) test_bitcoin.exe: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%))
i586-mingw32msvc-g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ -lboost_unit_test_framework $(LIBS) i586-mingw32msvc-g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ -lboost_unit_test_framework-mt-s $(LIBS)
clean: clean:

6
src/qt/guiutil.cpp

@ -4,7 +4,6 @@
#include "bitcoinunits.h" #include "bitcoinunits.h"
#include "util.h" #include "util.h"
#include "init.h" #include "init.h"
#include "base58.h"
#include <QString> #include <QString>
#include <QDateTime> #include <QDateTime>
@ -81,11 +80,6 @@ bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out)
if(uri.scheme() != QString("bitcoin")) if(uri.scheme() != QString("bitcoin"))
return false; return false;
// check if the address is valid
CBitcoinAddress addressFromUri(uri.path().toStdString());
if (!addressFromUri.IsValid())
return false;
SendCoinsRecipient rv; SendCoinsRecipient rv;
rv.address = uri.path(); rv.address = uri.path();
rv.amount = 0; rv.amount = 0;

4
src/qt/sendcoinsdialog.cpp

@ -7,6 +7,7 @@
#include "sendcoinsentry.h" #include "sendcoinsentry.h"
#include "guiutil.h" #include "guiutil.h"
#include "askpassphrasedialog.h" #include "askpassphrasedialog.h"
#include "base58.h"
#include <QMessageBox> #include <QMessageBox>
#include <QLocale> #include <QLocale>
@ -273,6 +274,9 @@ bool SendCoinsDialog::handleURI(const QString &uri)
// URI has to be valid // URI has to be valid
if (GUIUtil::parseBitcoinURI(uri, &rv)) if (GUIUtil::parseBitcoinURI(uri, &rv))
{ {
CBitcoinAddress address(rv.address.toStdString());
if (!address.IsValid())
return false;
pasteEntry(rv); pasteEntry(rv);
return true; return true;
} }

7
src/qt/test/test_main.cpp

@ -6,6 +6,11 @@
// This is all you need to run all the tests // This is all you need to run all the tests
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
bool fInvalid = false;
URITests test1; URITests test1;
QTest::qExec(&test1); if (QTest::qExec(&test1) != 0)
fInvalid = true;
return fInvalid;
} }

2
src/qt/test/uritests.cpp

@ -47,7 +47,7 @@ void URITests::uriTests()
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=100&label=Wikipedia Example")); uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=100&label=Wikipedia Example"));
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
QVERIFY(rv.amount == 10000000000); QVERIFY(rv.amount == 10000000000LL);
QVERIFY(rv.label == QString("Wikipedia Example")); QVERIFY(rv.label == QString("Wikipedia Example"));
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Example Address")); uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Example Address"));

Loading…
Cancel
Save