Skip to content

Commit

Permalink
Merge pull request #1428 from brave/summary-load-60
Browse files Browse the repository at this point in the history
Summary is not loaded correctly
  • Loading branch information
NejcZdovc authored Jan 23, 2019
2 parents 01d3dbe + a43ad91 commit 5d39c58
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ test("brave_unit_tests") {
if (brave_rewards_enabled) {
sources += [
"//brave/vendor/bat-native-ledger/src/bat_get_media_unittest.cc",
"//brave/vendor/bat-native-ledger/src/bat_helper_unittest.cc",
"//brave/vendor/bat-native-ledger/src/test/niceware_partial_unittest.cc",
"//brave/components/brave_rewards/browser/publisher_info_database_unittest.cc",
"//brave/vendor/bat-native-usermodel/test/usermodel_unittest.cc",
Expand Down
2 changes: 1 addition & 1 deletion vendor/bat-native-ledger/src/bat_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static bool ignore_ = false;
}

// checks if probi only contains numbers
return std::regex_match(probi, std::regex("^[0-9]*$"));
return std::regex_match(probi, std::regex("^-?[0-9]*$"));
}

REQUEST_CREDENTIALS_ST::REQUEST_CREDENTIALS_ST() {}
Expand Down
36 changes: 36 additions & 0 deletions vendor/bat-native-ledger/src/bat_helper_unittest.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "brave/vendor/bat-native-ledger/include/bat/ledger/ledger.h"
#include "brave/vendor/bat-native-ledger/src/bat_helper.h"
#include "testing/gtest/include/gtest/gtest.h"

// npm run test -- brave_unit_tests --filter=BatHelperTest.*

TEST(BatHelperTest, isProbiValid) {
// zero probi
bool result = braveledger_bat_helper::isProbiValid("0");
ASSERT_EQ(result, true);

// 1 BAT
result = braveledger_bat_helper::isProbiValid("1000000000000000000");
ASSERT_EQ(result, true);

// -1 BAT
result = braveledger_bat_helper::isProbiValid("-1000000000000000000");
ASSERT_EQ(result, true);

// not correct probi
result = braveledger_bat_helper::isProbiValid("10-00000000000000000");
ASSERT_EQ(result, false);

// not correct probi
result = braveledger_bat_helper::isProbiValid("fds000000000");
ASSERT_EQ(result, false);

// not correct probi
result = braveledger_bat_helper::isProbiValid(
"100000000000000000010000000000000000001000000000000000000");
ASSERT_EQ(result, false);
}

0 comments on commit 5d39c58

Please sign in to comment.