Skip to content

Commit 6aad92b

Browse files
committed
Merge branch 'develop' into bugfix/CORE-629
2 parents c72447f + 7a75586 commit 6aad92b

File tree

215 files changed

+11057
-4229
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

215 files changed

+11057
-4229
lines changed

Java/CoreCrypto/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ android {
2828
minifyEnabled false
2929
}
3030
}
31+
32+
lintOptions {
33+
quiet false
34+
explainIssues true
35+
abortOnError true
36+
ignoreWarnings false
37+
checkReleaseBuilds false
38+
}
3139
}
3240

3341
dependencies {

Java/CoreCrypto/src/androidTest/java/com/breadwallet/corecrypto/AccountAIT.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ public void testAccountCreateFromPhrase() {
2626

2727
Account account = Account.createFromPhrase(phrase, timestamp, uids);
2828
assertEquals(timestamp.getTime(), account.getTimestamp().getTime());
29+
30+
// check the uids matches the one provided on creation
31+
assertEquals(uids, account.getUids());
2932
}
3033

3134
@Test
@@ -56,6 +59,9 @@ public void testAccountSerialization() {
5659
// check that validity is transitive
5760
accountFromPhrase.validate(serializationFromSerialization);
5861
accountFromSerialization.validate(serializationFromPhrase);
62+
63+
// check the uids matches the one provided on creation
64+
assertEquals(uids, accountFromSerialization.getUids());
5965
}
6066

6167
@Test

Java/CoreCrypto/src/androidTest/java/com/breadwallet/corecrypto/AmountAIT.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,29 @@ public void testAmountCreateEth() {
162162

163163
Amount a5 = Amount.create( "1.234567891234567891", false, ether_eth).get();
164164
assertEquals(new Double(1234567891234567891L), a5.doubleAmount(wei_eth).get());
165-
// TODO: The swift behaviour diverges here; how do we want to handle?
165+
// TODO(discuss): The swift behaviour diverges here; how do we want to handle?
166166
// assertEquals("wei1,234,567,891,234,570,000", a5.toStringAsUnit(wei_eth, null).get());
167167
assertEquals("1234567891234567891", a5.toStringWithBase(10, ""));
168168

169169
Amount a6 = Amount.create("1", false, ether_eth).get();
170170
assertEquals("1000000000000000000", a6.toStringWithBase(10, ""));
171171
assertEquals("0xDE0B6B3A7640000".toLowerCase(), a6.toStringWithBase(16, "0x"));
172+
173+
Amount a7 = Amount.create("123000000000000000000.0", false, wei_eth).get();
174+
assertEquals("wei123,000,000,000,000,000,000", a7.toStringAsUnit(wei_eth).get());
175+
176+
double a7Double = a7.doubleAmount(wei_eth).get();
177+
assertEquals(1.23e20, a7Double, 0.0);
178+
179+
Amount a8 = Amount.create("123456789012345678.0", false, wei_eth).get();
180+
assertEquals("123456789012345678", a8.toStringWithBase(10, ""));
181+
// TODO(discuss): The swift behaviour diverges here; how do we want to handle?
182+
// assertEquals("wei123,456,789,012,345,600", a8.toStringAsUnit(wei_eth).get());
183+
assertEquals("wei123,456,789,012,345,680", a8.toStringAsUnit(wei_eth).get());
184+
assertNotEquals("wei123,456,789,012,345,678", a8.toStringAsUnit(wei_eth).get());
185+
186+
double a8Double = a8.doubleAmount(wei_eth).get();
187+
assertEquals(1.2345678901234568e17, a8Double, 0.0);
172188
}
173189

174190
@Test

Java/CoreCrypto/src/androidTest/java/com/breadwallet/corecrypto/CurrencyAIT.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88
package com.breadwallet.corecrypto;
99

10-
import com.breadwallet.crypto.CryptoApi;
1110
import com.breadwallet.crypto.CurrencyPair;
1211
import com.google.common.base.Optional;
1312
import com.google.common.primitives.UnsignedInteger;
@@ -20,11 +19,7 @@ public class CurrencyAIT {
2019

2120
@Before
2221
public void setup() {
23-
try {
24-
CryptoApi.initialize(CryptoApiProvider.getInstance());
25-
} catch (IllegalStateException e) {
26-
// already initialized, ignore
27-
}
22+
HelpersAIT.registerCryptoApiProvider();
2823
}
2924

3025
@Test

Java/CoreCrypto/src/androidTest/java/com/breadwallet/corecrypto/HelpersAIT.java

Lines changed: 57 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
import android.content.Context;
1111
import android.support.test.InstrumentationRegistry;
1212

13+
import com.breadwallet.crypto.CryptoApi;
1314
import com.breadwallet.crypto.Network;
1415
import com.breadwallet.crypto.System;
1516
import com.breadwallet.crypto.Transfer;
1617
import com.breadwallet.crypto.Wallet;
1718
import com.breadwallet.crypto.WalletManager;
1819
import com.breadwallet.crypto.blockchaindb.BlockchainDb;
1920
import com.breadwallet.crypto.events.network.NetworkEvent;
21+
import com.breadwallet.crypto.events.system.DefaultSystemListener;
2022
import com.breadwallet.crypto.events.system.SystemEvent;
2123
import com.breadwallet.crypto.events.system.SystemListener;
2224
import com.breadwallet.crypto.events.system.SystemManagerAddedEvent;
@@ -78,13 +80,39 @@ static boolean deleteFile(File file) {
7880
return file.delete();
7981
}
8082

83+
// Module
84+
85+
/* package */
86+
static void registerCryptoApiProvider() {
87+
try {
88+
CryptoApi.initialize(CryptoApiProvider.getInstance());
89+
} catch (IllegalStateException e) {
90+
// already initialized, ignore
91+
}
92+
}
93+
8194
// System
8295

8396
/* package */
84-
static System createAndConfigureSystem(File dataDir, SystemListener listener) {
97+
static System createAndConfigureSystem(File dataDir) {
98+
String storagePath = dataDir.getAbsolutePath();
99+
Account account = HelpersAIT.createDefaultAccount();
100+
SystemListener listener = new DefaultSystemListener() {};
101+
BlockchainDb query = HelpersAIT.createDefaultBlockchainDbWithToken();
102+
ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
103+
com.breadwallet.corecrypto.System system = com.breadwallet.corecrypto.System.create(executor, listener, account, false, storagePath, query);
104+
105+
system.configure(Collections.emptyList());
106+
Uninterruptibles.sleepUninterruptibly(5, TimeUnit.SECONDS);
107+
108+
return system;
109+
}
110+
111+
/* package */
112+
static System createAndConfigureSystemWithListener(File dataDir, SystemListener listener) {
85113
String storagePath = dataDir.getAbsolutePath();
86114
Account account = HelpersAIT.createDefaultAccount();
87-
BlockchainDb query = HelpersAIT.createDefaultBlockchainDb();
115+
BlockchainDb query = HelpersAIT.createDefaultBlockchainDbWithToken();
88116
ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
89117
com.breadwallet.corecrypto.System system = com.breadwallet.corecrypto.System.create(executor, listener, account, false, storagePath, query);
90118

@@ -94,6 +122,20 @@ static System createAndConfigureSystem(File dataDir, SystemListener listener) {
94122
return system;
95123
}
96124

125+
/* package */
126+
static System createAndConfigureSystemWithBlockchainDbAndCurrencies(File dataDir, BlockchainDb query, List<com.breadwallet.crypto.blockchaindb.models.bdb.Currency> currencies) {
127+
String storagePath = dataDir.getAbsolutePath();
128+
Account account = HelpersAIT.createDefaultAccount();
129+
SystemListener listener = new DefaultSystemListener() {};
130+
ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
131+
com.breadwallet.corecrypto.System system = com.breadwallet.corecrypto.System.create(executor, listener, account, false, storagePath, query);
132+
133+
system.configure(currencies);
134+
Uninterruptibles.sleepUninterruptibly(5, TimeUnit.SECONDS);
135+
136+
return system;
137+
}
138+
97139
/* package */
98140
static Optional<Network> getNetworkByCurrencyCode(Collection<Network> networks, String code) {
99141
Network out = null;
@@ -146,18 +188,25 @@ static Account createDefaultAccount() {
146188

147189
// BlockchainDB
148190

149-
private static final OkHttpClient DEFAULT_HTTP_CLIENT = new OkHttpClient();
191+
/* package */
192+
static final OkHttpClient DEFAULT_HTTP_CLIENT = new OkHttpClient();
150193

151-
private static String DEFAULT_TOKEN = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9." +
152-
"eyJzdWIiOiJkZWI2M2UyOC0wMzQ1LTQ4ZjYtOWQxNy1jZTgwY2JkNjE3Y2IiLCJicmQ" +
153-
"6Y3QiOiJjbGkiLCJleHAiOjkyMjMzNzIwMzY4NTQ3NzUsImlhdCI6MTU2Njg2MzY0OX0." +
154-
"FvLLDUSk1p7iFLJfg2kA-vwhDWTDulVjdj8YpFgnlE62OBFCYt4b3KeTND_qAhLynLKbGJ1UDpMMihsxtfvA0A";
194+
private static String DEFAULT_TOKEN = "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9." +
195+
"eyJzdWIiOiJjNzQ5NTA2ZS02MWUzLTRjM2UtYWNiNS00OTY5NTM2ZmRhMTAiLCJpYXQiOjE1N" +
196+
"zI1NDY1MDAuODg3LCJleHAiOjE4ODAxMzA1MDAuODg3LCJicmQ6Y3QiOiJ1c3IiLCJicmQ6Y2" +
197+
"xpIjoiZGViNjNlMjgtMDM0NS00OGY2LTlkMTctY2U4MGNiZDYxN2NiIn0." +
198+
"460_GdAWbONxqOhWL5TEbQ7uEZi3fSNrl0E_Zg7MAg570CVcgO7rSMJvAPwaQtvIx1XFK_QZjcoNULmB8EtOdg";
155199

156200
/* package */
157-
static BlockchainDb createDefaultBlockchainDb() {
201+
static BlockchainDb createDefaultBlockchainDbWithToken() {
158202
return BlockchainDb.createForTest(DEFAULT_HTTP_CLIENT, DEFAULT_TOKEN);
159203
}
160204

205+
/* package */
206+
static BlockchainDb createDefaultBlockchainDbWithoutToken() {
207+
return new BlockchainDb(DEFAULT_HTTP_CLIENT);
208+
}
209+
161210
// Listeners
162211

163212
/* package */

0 commit comments

Comments
 (0)