Skip to content

Commit

Permalink
Techdebt/test refactor cruft removal (#250)
Browse files Browse the repository at this point in the history
* Removed non english seed words

-Refactor tests
- Reset AnalyticsTests

Signed-off-by: kcw-grunt <mrkerrywashington@icloud.com>

* Rename Bitcoinletter to Litecoinletters

-added tests
testLitecoinSymbolConstants
testAppExternalURLConstants
testFirebaseAnalyticsConstants

Signed-off-by: kcw-grunt <mrkerrywashington@icloud.com>

---------

Signed-off-by: kcw-grunt <mrkerrywashington@icloud.com>
  • Loading branch information
kcw-grunt authored Nov 1, 2024
1 parent d37be6e commit 7baf2b3
Show file tree
Hide file tree
Showing 21 changed files with 118 additions and 8,317 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.breadwallet;
package com.litewallet;

import android.util.Log;

import com.breadwallet.tools.util.Bip39Reader;
import com.breadwallet.wallet.BRWalletManager;

import org.apache.commons.io.IOUtils;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.io.IOException;
import java.io.InputStream;
Expand All @@ -18,43 +20,32 @@
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;

public class PaperKeyTests {

private static final String TAG = PaperKeyTests.class.getName();
public static final String PAPER_KEY_JAP = "こせき ぎじにってい けっこん せつぞく うんどう ふこう にっすう こせい きさま なまみ たきび はかい";//japanese
public static final String PAPER_KEY_ENG = "stick sword keen afraid smile sting huge relax nominee arena area gift ";//english
public static final String PAPER_KEY_FRE = "vocation triage capsule marchand onduler tibia illicite entier fureur minorer amateur lubie";//french
public static final String PAPER_KEY_SPA = "zorro turismo mezcla nicho morir chico blanco pájaro alba esencia roer repetir";//spanish
public static final String PAPER_KEY_CHI = "怨 贪 旁 扎 吹 音 决 廷 十 助 畜 怒";//chinese
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;

@RunWith(AndroidJUnit4.class)
@LargeTest

// @Test
// public void testWordsValid() {
//
// List<String> list = getAllWords();
// assertThat(list.size(), is(10240));
//
// assertThat(isValid(PAPER_KEY_JAP, list), is(true));
// assertThat(isValid(PAPER_KEY_ENG, list), is(true));
// assertThat(isValid(PAPER_KEY_FRE, list), is(true));
// assertThat(isValid(PAPER_KEY_SPA, list), is(true));
// assertThat(isValid(PAPER_KEY_CHI, list), is(true));
// }
public class PaperKeyTests {
private static final String TAG = PaperKeyTests.class.getName();
public static final List<String> PAPER_KEY_ENG = Arrays.asList("stick","sword","keen","afraid","smile","sting","huge","relax","nominee","arena","area","gift");

@Test
public void testWordsValid() {
List<String> wordList = getAllWords();
Assert.assertEquals(wordList.size(), 2048);
Assert.assertSame(PAPER_KEY_ENG.containsAll(wordList),true);
}
@Test
public void testPaperKeyValidation() {
List<String> list = getAllWords();
assertThat(list.size(), is(10240));
assertThat(list.size(), is(2048));
}

private List<String> getAllWords() {
List<String> result = new ArrayList<>();
List<String> names = new ArrayList<>();
names.add("en-BIP39Words.txt");
names.add("es-BIP39Words.txt");
names.add("fr-BIP39Words.txt");
names.add("ja-BIP39Words.txt");
names.add("zh-BIP39Words.txt");

for (String fileName : names) {
InputStream in = null;
Expand All @@ -78,7 +69,7 @@ private List<String> getAllWords() {
String cleanWord = Bip39Reader.cleanWord(s);
cleanList.add(cleanWord);
}
assertThat(cleanList.size(), is(10240));
assertThat(cleanList.size(), is(2048));
return cleanList;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package com.litewallet.analytics;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import android.util.Log;
import androidx.test.ext.junit.rules.ActivityScenarioRule;

import com.breadwallet.presenter.activities.intro.IntroActivity;
import com.breadwallet.tools.util.BRConstants;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.net.URI;

@RunWith(AndroidJUnit4.class)
public class ConstantsTests {
public static final String TAG = ConstantsTests.class.getName();
@Rule
public ActivityScenarioRule<IntroActivity> mActivityRule = new ActivityScenarioRule<>(IntroActivity.class);
@Before
public void setUp() {
Log.e(TAG, "setUp: ");
}

@After
public void tearDown() {
}
@Test
public void testLitecoinSymbolConstants() {
Assert.assertSame(BRConstants.litecoinLowercase,"ł");
Assert.assertSame(BRConstants.litecoinUppercase,"Ł");
}
@Test
public void testAppExternalURLConstants() {
Assert.assertSame(BRConstants.TWITTER_LINK,"https://twitter.com/Litewallet_App");
Assert.assertSame(BRConstants.INSTAGRAM_LINK,"https://www.instagram.com/litewallet.app");
Assert.assertSame(BRConstants.WEB_LINK,"https://litewallet.io");
Assert.assertSame(BRConstants.TOS_LINK,"https://litewallet.io/privacy");
Assert.assertSame(BRConstants.CUSTOMER_SUPPORT_LINK,"https://support.litewallet.io/hc/en-us/requests/new");
Assert.assertSame(BRConstants.BITREFILL_AFFILIATE_LINK,"https://www.bitrefill.com/");
}
@Test
public void testFirebaseAnalyticsConstants() {
Assert.assertSame(BRConstants._20191105_AL,"app_launched");
Assert.assertSame(BRConstants._20191105_VSC,"visit_send_controller");
Assert.assertSame(BRConstants._20202116_VRC,"visit_receive_controller");
Assert.assertSame(BRConstants._20191105_DSL,"did_send_ltc");
Assert.assertSame(BRConstants._20191105_DTBT,"did_tap_buy_tab");
Assert.assertSame(BRConstants._20200111_RNI,"rate_not_initialized");
Assert.assertSame(BRConstants._20200111_FNI,"feeperkb_not_initialized");
Assert.assertSame(BRConstants._20200111_TNI,"transaction_not_initialized");
Assert.assertSame(BRConstants._20200111_WNI,"wallet_not_initialized");
Assert.assertSame(BRConstants._20200111_PNI,"phrase_not_initialized");
Assert.assertSame(BRConstants._20200111_UTST,"unable_to_sign_transaction");
Assert.assertSame(BRConstants._20200112_ERR,"error");
Assert.assertSame(BRConstants._20200112_DSR,"did_start_resync");
Assert.assertSame(BRConstants._20200125_DSRR,"did_show_review_request");
Assert.assertSame(BRConstants._20201118_DTGS,"did_tap_get_support");
Assert.assertSame(BRConstants._20200217_DUWP,"did_unlock_with_pin");
Assert.assertSame(BRConstants._20200217_DUWB,"did_unlock_with_biometrics");
Assert.assertSame(BRConstants._20200223_DD,"did_donate");
Assert.assertSame(BRConstants._20200225_DCD,"did_cancel_donate");
Assert.assertSame(BRConstants._20200301_DUDFPK,"did_use_default_fee_per_kb");
Assert.assertSame(BRConstants._20201121_SIL,"started_IFPS_lookup");
Assert.assertSame(BRConstants._20201121_DRIA,"did_resolve_IPFS_address");
Assert.assertSame(BRConstants._20201121_FRIA,"failed_resolve_IPFS_address");
Assert.assertSame(BRConstants._20200207_DTHB,"did_tap_header_balance");
Assert.assertSame(BRConstants._20210427_HCIEEH,"heartbeat_check_if_event_even_happens");
Assert.assertSame(BRConstants._20220822_UTOU,"user_tapped_on_ud");
Assert.assertSame(BRConstants._20230131_NENR,"no_error_nominal_response");
Assert.assertSame(BRConstants._20230407_DCS,"did_complete_sync");
Assert.assertSame(BRConstants._20240123_RAGI,"registered_android_general_interest");
Assert.assertSame(BRConstants._20231225_UAP,"user_accepted_push");
Assert.assertSame(BRConstants._20240101_US,"user_signup");
Assert.assertSame(BRConstants._20241006_DRR,"did_request_rating");
Assert.assertSame(BRConstants._20241006_UCR,"user_completed_rating");
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.breadwallet.database;
package com.litewallet.database;

import androidx.test.filters.LargeTest;
import androidx.test.rule.ActivityTestRule;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.breadwallet.platform;
package com.litewallet.platform;

import androidx.test.filters.LargeTest;
import androidx.test.rule.ActivityTestRule;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.breadwallet.platform;
package com.litewallet.platform;

import androidx.test.rule.ActivityTestRule;
import androidx.test.ext.junit.runners.AndroidJUnit4;
Expand All @@ -8,11 +8,8 @@
import com.breadwallet.presenter.activities.BreadActivity;
import com.breadwallet.tools.util.BRCompressor;
import com.breadwallet.tools.util.BRConstants;
import com.breadwallet.tools.util.Utils;
import com.jniwrappers.BRKey;
import com.platform.APIClient;

import org.apache.commons.io.IOUtils;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.breadwallet.security;
package com.litewallet.security;

import android.security.keystore.UserNotAuthenticatedException;
import androidx.test.rule.ActivityTestRule;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.breadwallet.security;
package com.litewallet.security;

import android.app.Activity;
import android.security.keystore.UserNotAuthenticatedException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.breadwallet.wallet;
package com.litewallet.wallet;

import com.breadwallet.presenter.entities.RequestObject;
import com.breadwallet.tools.security.BitcoinUrlHandler;
import com.breadwallet.tools.util.BRConstants;
import com.breadwallet.tools.util.Utils;


import org.junit.Assert;
import org.junit.Test;

import java.math.BigDecimal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void run() {
long minAmount = BRWalletManager.getInstance().getMinOutputAmountRequested();
errTitle[0] = app.getString(R.string.Alerts_sendFailure);
errMessage[0] = String.format(Locale.getDefault(), app.getString(R.string.PaymentProtocol_Errors_smallPayment),
BRConstants.bitcoinLowercase + new BigDecimal(minAmount).divide(new BigDecimal(100), BRConstants.ROUNDING_MODE));
BRConstants.litecoinLowercase + new BigDecimal(minAmount).divide(new BigDecimal(100), BRConstants.ROUNDING_MODE));
} catch (SpendingNotAllowed spendingNotAllowed) {
showSpendNotAllowed(app);
return;
Expand Down Expand Up @@ -254,7 +254,7 @@ private void confirmPay(final Context ctx, final TransactionItem transactionItem
//amount can't be less than the min
if (transactionItem.sendAmount < minOutput) {
final String bitcoinMinMessage = String.format(Locale.getDefault(), ctx.getString(R.string.PaymentProtocol_Errors_smallTransaction),
BRConstants.bitcoinLowercase + new BigDecimal(minOutput).divide(new BigDecimal("100")));
BRConstants.litecoinLowercase + new BigDecimal(minOutput).divide(new BigDecimal("100")));

((Activity) ctx).runOnUiThread(new Runnable() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public void run() {
double minOutput = BRWalletManager.getInstance().getMinOutputAmount();
if (paymentRequest.amount < minOutput) {
final String bitcoinMinMessage = String.format(Locale.getDefault(), app.getString(R.string.PaymentProtocol_Errors_smallTransaction),
BRConstants.bitcoinLowercase + new BigDecimal(minOutput).divide(new BigDecimal("100")));
BRConstants.litecoinLowercase + new BigDecimal(minOutput).divide(new BigDecimal("100")));
app.runOnUiThread(new Runnable() {
@Override
public void run() {
Expand Down
6 changes: 2 additions & 4 deletions app/src/main/java/com/breadwallet/tools/util/BRConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ private BRConstants() {
public static final int CURRENT_UNIT_LITES = 1; // formerly CURRENT_UNIT_MBITS
public static final int CURRENT_UNIT_LITECOINS = 2;

public static final String bitcoinLowercase = "\u0142";
public static final String bitcoinUppercase = "\u0141";
public static final String litecoinLowercase = "\u0142";
public static final String litecoinUppercase = "\u0141";

public static boolean PLATFORM_ON = true;
public static final RoundingMode ROUNDING_MODE = RoundingMode.HALF_EVEN;
Expand All @@ -98,9 +98,7 @@ private BRConstants() {
*/

public static final String TWITTER_LINK = "https://twitter.com/Litewallet_App";

public static final String INSTAGRAM_LINK = "https://www.instagram.com/litewallet.app";

public static final String WEB_LINK = "https://litewallet.io";
public static final String TOS_LINK = "https://litewallet.io/privacy";
public static String CUSTOMER_SUPPORT_LINK = "https://support.litewallet.io/hc/en-us/requests/new";
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/com/breadwallet/tools/util/BRCurrency.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ public static String getFormattedCurrencyString(Context app, String isoCurrencyC
public static String getSymbolByIso(Context app, String iso) {
String symbol;
if (Objects.equals(iso, "LTC")) {
String currencySymbolString = BRConstants.bitcoinLowercase;
String currencySymbolString = BRConstants.litecoinLowercase;
if (app != null) {
int unit = BRSharedPrefs.getCurrencyUnit(app);
switch (unit) {
case CURRENT_UNIT_PHOTONS:
currencySymbolString = BRConstants.bitcoinLowercase;
currencySymbolString = BRConstants.litecoinLowercase;
break;
case BRConstants.CURRENT_UNIT_LITES:
currencySymbolString = "m" + BRConstants.bitcoinUppercase;
currencySymbolString = "m" + BRConstants.litecoinUppercase;
break;
case BRConstants.CURRENT_UNIT_LITECOINS:
currencySymbolString = BRConstants.bitcoinUppercase;
currencySymbolString = BRConstants.litecoinUppercase;
break;
}
}
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/com/breadwallet/tools/util/BRExchange.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,18 @@ public static BigDecimal getAmountFromLitoshis(Context app, String iso, BigDecim
}

public static String getLitecoinSymbol(Context app) {
String currencySymbolString = BRConstants.bitcoinLowercase;
String currencySymbolString = BRConstants.litecoinLowercase;
if (app != null) {
int unit = BRSharedPrefs.getCurrencyUnit(app);
switch (unit) {
case CURRENT_UNIT_PHOTONS:
currencySymbolString = "m" + BRConstants.bitcoinLowercase;
currencySymbolString = "m" + BRConstants.litecoinLowercase;
break;
case BRConstants.CURRENT_UNIT_LITES:
currencySymbolString = BRConstants.bitcoinLowercase;
currencySymbolString = BRConstants.litecoinLowercase;
break;
case BRConstants.CURRENT_UNIT_LITECOINS:
currencySymbolString = BRConstants.bitcoinUppercase;
currencySymbolString = BRConstants.litecoinUppercase;
break;
}
}
Expand Down
Loading

0 comments on commit 7baf2b3

Please sign in to comment.