[#1066] Detekt enhancement

* [#1083] Detekt Compose 0.1.10

* [#1066] Detekt - MaxLineLength rule turn on

* Remove default values

As we keep only those that differ from the default in the latest Detekt update.

* [#1086] Improve TODO inline occurrence pattern
This commit is contained in:
Honza Rychnovský 2023-06-20 11:26:38 +02:00 committed by GitHub
parent 2ff884b38b
commit 53f5550bf4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
42 changed files with 294 additions and 93 deletions

View File

@ -10,7 +10,8 @@ class RustDerivationToolTest {
companion object { companion object {
private const val SEED_PHRASE = private const val SEED_PHRASE =
"kitchen renew wide common vague fold vacuum tilt amazing pear square gossip jewel month tree shock scan alpha just spot fluid toilet view dinner" "kitchen renew wide common vague fold vacuum tilt amazing pear square gossip jewel month tree shock scan" +
" alpha just spot fluid toilet view dinner"
} }
@Test @Test

View File

@ -1,3 +1,5 @@
@file:Suppress("MaxLineLength")
package cash.z.ecc.android.sdk.darkside // package cash.z.ecc.android.sdk.integration package cash.z.ecc.android.sdk.darkside // package cash.z.ecc.android.sdk.integration
// //
// import cash.z.ecc.android.sdk.test.ScopedTest // import cash.z.ecc.android.sdk.test.ScopedTest

View File

@ -1,3 +1,5 @@
@file:Suppress("MaxLineLength")
package cash.z.ecc.android.sdk.darkside package cash.z.ecc.android.sdk.darkside
// import cash.z.ecc.android.sdk.SdkSynchronizer // import cash.z.ecc.android.sdk.SdkSynchronizer

View File

@ -1,3 +1,5 @@
@file:Suppress("MaxLineLength")
package cash.z.ecc.android.sdk.darkside // package cash.z.ecc.android.sdk.integration package cash.z.ecc.android.sdk.darkside // package cash.z.ecc.android.sdk.integration
// //
// import cash.z.ecc.android.sdk.test.ScopedTest // import cash.z.ecc.android.sdk.test.ScopedTest

View File

@ -1,3 +1,5 @@
@file:Suppress("MaxLineLength")
package cash.z.ecc.android.sdk.darkside // package cash.z.ecc.android.sdk.integration package cash.z.ecc.android.sdk.darkside // package cash.z.ecc.android.sdk.integration
// //
// import cash.z.ecc.android.sdk.test.ScopedTest // import cash.z.ecc.android.sdk.test.ScopedTest

View File

@ -43,6 +43,7 @@ class InboundTxTests : ScopedTest() {
.applyTipHeight(targetHeight) .applyTipHeight(targetHeight)
} }
@Suppress("MaxLineLength")
companion object { companion object {
private const val blocksUrl = "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/basic-reorg/before-reorg.txt" private const val blocksUrl = "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/basic-reorg/before-reorg.txt"
private const val tx663174 = "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/recv/0821a89be7f2fc1311792c3fa1dd2171a8cdfb2effd98590cbd5ebcdcfcf491f.txt" private const val tx663174 = "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/recv/0821a89be7f2fc1311792c3fa1dd2171a8cdfb2effd98590cbd5ebcdcfcf491f.txt"

View File

@ -1,3 +1,5 @@
@file:Suppress("MaxLineLength")
package cash.z.ecc.android.sdk.darkside.reorgs // package cash.z.ecc.android.sdk.integration package cash.z.ecc.android.sdk.darkside.reorgs // package cash.z.ecc.android.sdk.integration
// //
// import cash.z.ecc.android.sdk.test.ScopedTest // import cash.z.ecc.android.sdk.test.ScopedTest

View File

@ -1,3 +1,5 @@
@file:Suppress("MaxLineLength")
package cash.z.ecc.android.sdk.darkside.reorgs // package cash.z.ecc.android.sdk.integration package cash.z.ecc.android.sdk.darkside.reorgs // package cash.z.ecc.android.sdk.integration
// //
// import androidx.test.platform.app.InstrumentationRegistry // import androidx.test.platform.app.InstrumentationRegistry

View File

@ -38,7 +38,8 @@ class SetupTest : ScopedTest() {
@Test @Test
@Ignore("This test is broken") @Ignore("This test is broken")
fun tempTest() { fun tempTest() {
val phrase = "still champion voice habit trend flight survey between bitter process artefact blind carbon truly provide dizzy crush flush breeze blouse charge solid fish spread" val phrase = "still champion voice habit trend flight survey between bitter process artefact blind" +
" carbon truly provide dizzy crush flush breeze blouse charge solid fish spread"
val result = SimpleMnemonics().toSeed(phrase.toCharArray()).toHex() val result = SimpleMnemonics().toSeed(phrase.toCharArray()).toHex()
assertEquals("abc", result) assertEquals("abc", result)
} }
@ -54,6 +55,7 @@ class SetupTest : ScopedTest() {
} }
companion object { companion object {
@Suppress("MaxLineLength")
private const val blocksUrl = "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/basic-reorg/before-reorg.txt" private const val blocksUrl = "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/basic-reorg/before-reorg.txt"
private const val firstBlock = 663150 private const val firstBlock = 663150
private const val lastBlock = 663200 private const val lastBlock = 663200

View File

@ -55,8 +55,8 @@ class DarksideTestCoordinator(val wallet: TestWallet) {
// verify that we are on the darkside // verify that we are on the darkside
try { try {
initiate() initiate()
// In the future, we may want to have the SDK internally verify being on the darkside by matching the
// In the future, we may want to have the SDK internally verify being on the darkside by matching the network type // network type
// synchronizer.getServerInfo().apply { // synchronizer.getServerInfo().apply {
// assertTrue( // assertTrue(
@ -263,6 +263,7 @@ class DarksideTestCoordinator(val wallet: TestWallet) {
* The chain starts at block 663150 and ends at block 663250 * The chain starts at block 663150 and ends at block 663250
*/ */
fun makeSimpleChain() { fun makeSimpleChain() {
@Suppress("MaxLineLength")
darkside darkside
.reset(BlockHeightUnsafe(DEFAULT_START_HEIGHT.value)) .reset(BlockHeightUnsafe(DEFAULT_START_HEIGHT.value))
.stageBlocks("https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/tx-incoming/blocks.txt") .stageBlocks("https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/tx-incoming/blocks.txt")
@ -285,6 +286,7 @@ class DarksideTestCoordinator(val wallet: TestWallet) {
} }
} }
@Suppress("MaxLineLength")
companion object { companion object {
/** /**
* This is a special localhost value on the Android emulator, which allows it to contact * This is a special localhost value on the Android emulator, which allows it to contact

View File

@ -139,10 +139,11 @@ class TestWallet(
} }
enum class Backups(val seedPhrase: String, val testnetBirthday: BlockHeight, val mainnetBirthday: BlockHeight) { enum class Backups(val seedPhrase: String, val testnetBirthday: BlockHeight, val mainnetBirthday: BlockHeight) {
// TODO: [#902] Get the proper birthday values for test wallets // TODO [#902]: Get the proper birthday values for test wallets
// TODO: [#902] https://github.com/zcash/zcash-android-wallet-sdk/issues/902 // TODO [#902]: https://github.com/zcash/zcash-android-wallet-sdk/issues/902
DEFAULT( DEFAULT(
"column rhythm acoustic gym cost fit keen maze fence seed mail medal shrimp tell relief clip cannon foster soldier shallow refuse lunar parrot banana", "column rhythm acoustic gym cost fit keen maze fence seed mail medal shrimp tell relief clip" +
" cannon foster soldier shallow refuse lunar parrot banana",
BlockHeight.new( BlockHeight.new(
ZcashNetwork.Testnet, ZcashNetwork.Testnet,
1_355_928 1_355_928
@ -150,7 +151,8 @@ class TestWallet(
BlockHeight.new(ZcashNetwork.Mainnet, 1_000_000) BlockHeight.new(ZcashNetwork.Mainnet, 1_000_000)
), ),
SAMPLE_WALLET( SAMPLE_WALLET(
"input frown warm senior anxiety abuse yard prefer churn reject people glimpse govern glory crumble swallow verb laptop switch trophy inform friend permit purpose", "input frown warm senior anxiety abuse yard prefer churn reject people glimpse govern glory" +
" crumble swallow verb laptop switch trophy inform friend permit purpose",
BlockHeight.new( BlockHeight.new(
ZcashNetwork.Testnet, ZcashNetwork.Testnet,
1_330_190 1_330_190
@ -158,7 +160,8 @@ class TestWallet(
BlockHeight.new(ZcashNetwork.Mainnet, 1_000_000) BlockHeight.new(ZcashNetwork.Mainnet, 1_000_000)
), ),
DEV_WALLET( DEV_WALLET(
"still champion voice habit trend flight survey between bitter process artefact blind carbon truly provide dizzy crush flush breeze blouse charge solid fish spread", "still champion voice habit trend flight survey between bitter process artefact blind carbon" +
" truly provide dizzy crush flush breeze blouse charge solid fish spread",
BlockHeight.new( BlockHeight.new(
ZcashNetwork.Testnet, ZcashNetwork.Testnet,
1_000_000 1_000_000
@ -166,7 +169,8 @@ class TestWallet(
BlockHeight.new(ZcashNetwork.Mainnet, 991645) BlockHeight.new(ZcashNetwork.Mainnet, 991645)
), ),
ALICE( ALICE(
"quantum whisper lion route fury lunar pelican image job client hundred sauce chimney barely life cliff spirit admit weekend message recipe trumpet impact kitten", "quantum whisper lion route fury lunar pelican image job client hundred sauce chimney barely" +
" life cliff spirit admit weekend message recipe trumpet impact kitten",
BlockHeight.new( BlockHeight.new(
ZcashNetwork.Testnet, ZcashNetwork.Testnet,
1_330_190 1_330_190
@ -174,7 +178,8 @@ class TestWallet(
BlockHeight.new(ZcashNetwork.Mainnet, 1_000_000) BlockHeight.new(ZcashNetwork.Mainnet, 1_000_000)
), ),
BOB( BOB(
"canvas wine sugar acquire garment spy tongue odor hole cage year habit bullet make label human unit option top calm neutral try vocal arena", "canvas wine sugar acquire garment spy tongue odor hole cage year habit bullet make label" +
" human unit option top calm neutral try vocal arena",
BlockHeight.new( BlockHeight.new(
ZcashNetwork.Testnet, ZcashNetwork.Testnet,
1_330_190 1_330_190

View File

@ -178,7 +178,11 @@ class SampleCodeTest {
val amount = 0.123.convertZecToZatoshi() val amount = 0.123.convertZecToZatoshi()
val address = "ztestsapling1tklsjr0wyw0d58f3p7wufvrj2cyfv6q6caumyueadq8qvqt8lda6v6tpx474rfru9y6u75u7qnw" val address = "ztestsapling1tklsjr0wyw0d58f3p7wufvrj2cyfv6q6caumyueadq8qvqt8lda6v6tpx474rfru9y6u75u7qnw"
val memo = "Test Transaction" val memo = "Test Transaction"
val spendingKey = DerivationTool.getInstance().deriveUnifiedSpendingKey(seed, ZcashNetwork.Mainnet, Account.DEFAULT) val spendingKey = DerivationTool.getInstance().deriveUnifiedSpendingKey(
seed,
ZcashNetwork.Mainnet,
Account.DEFAULT
)
synchronizer.sendToAddress(spendingKey, amount, address, memo) synchronizer.sendToAddress(spendingKey, amount, address, memo)
} }

View File

@ -30,14 +30,18 @@ class BooleanPreferenceDefaultTest {
@Test @Test
fun value_from_config_false() = runTest { fun value_from_config_false() = runTest {
val entry = BooleanPreferenceDefaultFixture.newTrue() val entry = BooleanPreferenceDefaultFixture.newTrue()
val mockPreferenceProvider = MockPreferenceProvider { mutableMapOf(BooleanPreferenceDefaultFixture.KEY.key to false.toString()) } val mockPreferenceProvider = MockPreferenceProvider {
mutableMapOf(BooleanPreferenceDefaultFixture.KEY.key to false.toString())
}
assertFalse(entry.getValue(mockPreferenceProvider)) assertFalse(entry.getValue(mockPreferenceProvider))
} }
@Test @Test
fun value_from_config_true() = runTest { fun value_from_config_true() = runTest {
val entry = BooleanPreferenceDefaultFixture.newTrue() val entry = BooleanPreferenceDefaultFixture.newTrue()
val mockPreferenceProvider = MockPreferenceProvider { mutableMapOf(BooleanPreferenceDefaultFixture.KEY.key to true.toString()) } val mockPreferenceProvider = MockPreferenceProvider {
mutableMapOf(BooleanPreferenceDefaultFixture.KEY.key to true.toString())
}
assertTrue(entry.getValue(mockPreferenceProvider)) assertTrue(entry.getValue(mockPreferenceProvider))
} }
} }

View File

@ -25,7 +25,9 @@ class IntegerPreferenceDefaultTest {
val expected = IntegerPreferenceDefaultFixture.DEFAULT_VALUE + 5 val expected = IntegerPreferenceDefaultFixture.DEFAULT_VALUE + 5
val entry = IntegerPreferenceDefaultFixture.new() val entry = IntegerPreferenceDefaultFixture.new()
val mockPreferenceProvider = MockPreferenceProvider { mutableMapOf(StringDefaultPreferenceFixture.KEY.key to expected.toString()) } val mockPreferenceProvider = MockPreferenceProvider {
mutableMapOf(StringDefaultPreferenceFixture.KEY.key to expected.toString())
}
assertEquals(expected, entry.getValue(mockPreferenceProvider)) assertEquals(expected, entry.getValue(mockPreferenceProvider))
} }

View File

@ -23,7 +23,9 @@ class StringPreferenceDefaultTest {
fun value_override() = runTest { fun value_override() = runTest {
val entry = StringDefaultPreferenceFixture.new() val entry = StringDefaultPreferenceFixture.new()
val mockPreferenceProvider = MockPreferenceProvider { mutableMapOf(StringDefaultPreferenceFixture.KEY.key to "override") } val mockPreferenceProvider = MockPreferenceProvider {
mutableMapOf(StringDefaultPreferenceFixture.KEY.key to "override")
}
assertEquals("override", entry.getValue(mockPreferenceProvider)) assertEquals("override", entry.getValue(mockPreferenceProvider))
} }

View File

@ -9,6 +9,7 @@ import java.util.Locale
fun getStringResource(@StringRes resId: Int) = ApplicationProvider.getApplicationContext<Context>().getString(resId) fun getStringResource(@StringRes resId: Int) = ApplicationProvider.getApplicationContext<Context>().getString(resId)
fun getStringResourceWithArgs(@StringRes resId: Int, formatArgs: Array<Any>) = ApplicationProvider.getApplicationContext<Context>().getString(resId, *formatArgs) fun getStringResourceWithArgs(@StringRes resId: Int, formatArgs: Array<Any>) =
ApplicationProvider.getApplicationContext<Context>().getString(resId, *formatArgs)
fun isLocaleRTL(locale: Locale) = TextUtils.getLayoutDirectionFromLocale(locale) == View.LAYOUT_DIRECTION_RTL fun isLocaleRTL(locale: Locale) = TextUtils.getLayoutDirectionFromLocale(locale) == View.LAYOUT_DIRECTION_RTL

View File

@ -12,7 +12,8 @@ data class BooleanPreferenceDefault(
try { try {
it.toBooleanStrict() it.toBooleanStrict()
} catch (e: IllegalArgumentException) { } catch (e: IllegalArgumentException) {
// [TODO #32]: Log coercion failure instead of just silently returning default // TODO [#32]: Log coercion failure instead of just silently returning default
// TODO [#32]: https://github.com/zcash/zcash-android-wallet-sdk/issues/32
defaultValue defaultValue
} }
} ?: defaultValue } ?: defaultValue

View File

@ -11,7 +11,8 @@ data class IntegerPreferenceDefault(
try { try {
it.toInt() it.toInt()
} catch (e: NumberFormatException) { } catch (e: NumberFormatException) {
// [TODO #32]: Log coercion failure instead of just silently returning default // TODO [#32]: Log coercion failure instead of just silently returning default
// TODO [#32]: https://github.com/zcash/zcash-android-wallet-sdk/issues/32
defaultValue defaultValue
} }
} ?: defaultValue } ?: defaultValue

View File

@ -31,9 +31,9 @@ import cash.z.ecc.android.sdk.demoapp.fixture.WalletSnapshotFixture
import cash.z.ecc.android.sdk.demoapp.ui.common.DisableScreenTimeout import cash.z.ecc.android.sdk.demoapp.ui.common.DisableScreenTimeout
import cash.z.ecc.android.sdk.demoapp.ui.screen.home.viewmodel.WalletSnapshot import cash.z.ecc.android.sdk.demoapp.ui.screen.home.viewmodel.WalletSnapshot
@Preview @Preview(name = "Home")
@Composable @Composable
fun ComposablePreviewHome() { private fun ComposablePreviewHome() {
MaterialTheme { MaterialTheme {
Home( Home(
WalletSnapshotFixture.new(), WalletSnapshotFixture.new(),
@ -48,7 +48,6 @@ fun ComposablePreviewHome() {
} }
} }
@OptIn(ExperimentalMaterial3Api::class)
@Suppress("LongParameterList") @Suppress("LongParameterList")
@Composable @Composable
fun Home( fun Home(

View File

@ -263,7 +263,8 @@ sealed class SendState {
/** /**
* Represents all kind of Synchronizer errors * Represents all kind of Synchronizer errors
*/ */
// TODO [#529] https://github.com/zcash/secant-android-wallet/issues/529 // TODO [#529]: Localize Synchronizer Errors
// TODO [#529]: https://github.com/zcash/secant-android-wallet/issues/529
sealed class SynchronizerError { sealed class SynchronizerError {
abstract fun getCauseMessage(): String? abstract fun getCauseMessage(): String?

View File

@ -21,9 +21,9 @@ import cash.z.ecc.android.sdk.model.PersistableWallet
import cash.z.ecc.android.sdk.model.SeedPhrase import cash.z.ecc.android.sdk.model.SeedPhrase
import cash.z.ecc.android.sdk.model.ZcashNetwork import cash.z.ecc.android.sdk.model.ZcashNetwork
@Preview @Preview(name = "Seed")
@Composable @Composable
fun ComposablePreview() { private fun ComposablePreview() {
MaterialTheme { MaterialTheme {
Seed( Seed(
ZcashNetwork.Mainnet, ZcashNetwork.Mainnet,

View File

@ -85,7 +85,7 @@ ANDROID_NDK_VERSION=22.1.7171670
ANDROID_GRADLE_PLUGIN_VERSION=8.0.2 ANDROID_GRADLE_PLUGIN_VERSION=8.0.2
DETEKT_VERSION=1.23.0 DETEKT_VERSION=1.23.0
DETEKT_COMPOSE_RULES_VERSION=0.1.6 DETEKT_COMPOSE_RULES_VERSION=0.1.10
DOKKA_VERSION=1.8.10 DOKKA_VERSION=1.8.10
EMULATOR_WTF_GRADLE_PLUGIN_VERSION=0.12.2 EMULATOR_WTF_GRADLE_PLUGIN_VERSION=0.12.2
FLANK_VERSION=23.04.0 FLANK_VERSION=23.04.0

View File

@ -9,6 +9,7 @@ import java.util.Locale
fun getStringResource(@StringRes resId: Int) = ApplicationProvider.getApplicationContext<Context>().getString(resId) fun getStringResource(@StringRes resId: Int) = ApplicationProvider.getApplicationContext<Context>().getString(resId)
fun getStringResourceWithArgs(@StringRes resId: Int, formatArgs: Array<Any>) = ApplicationProvider.getApplicationContext<Context>().getString(resId, *formatArgs) fun getStringResourceWithArgs(@StringRes resId: Int, formatArgs: Array<Any>) =
ApplicationProvider.getApplicationContext<Context>().getString(resId, *formatArgs)
fun isLocaleRTL(locale: Locale) = TextUtils.getLayoutDirectionFromLocale(locale) == View.LAYOUT_DIRECTION_RTL fun isLocaleRTL(locale: Locale) = TextUtils.getLayoutDirectionFromLocale(locale) == View.LAYOUT_DIRECTION_RTL

View File

@ -23,7 +23,12 @@ class FiatCurrencyConversionRateStateTest {
val currencyConversion = CurrencyConversionFixture.new() val currencyConversion = CurrencyConversionFixture.new()
val result = zatoshi.toFiatCurrencyState(currencyConversion, LocaleFixture.new(), MonetarySeparatorsFixture.new(), frozenClock) val result = zatoshi.toFiatCurrencyState(
currencyConversion,
LocaleFixture.new(),
MonetarySeparatorsFixture.new(),
frozenClock
)
assertIs<FiatCurrencyConversionRateState.Current>(result) assertIs<FiatCurrencyConversionRateState.Current>(result)
} }
@ -34,12 +39,19 @@ class FiatCurrencyConversionRateStateTest {
val zatoshi = ZatoshiFixture.new() val zatoshi = ZatoshiFixture.new()
val frozenClock = FrozenClock( val frozenClock = FrozenClock(
CurrencyConversionFixture.TIMESTAMP - FiatCurrencyConversionRateState.FUTURE_CUTOFF_AGE_INCLUSIVE - 1.seconds CurrencyConversionFixture.TIMESTAMP -
FiatCurrencyConversionRateState.FUTURE_CUTOFF_AGE_INCLUSIVE -
1.seconds
) )
val currencyConversion = CurrencyConversionFixture.new() val currencyConversion = CurrencyConversionFixture.new()
val result = zatoshi.toFiatCurrencyState(currencyConversion, LocaleFixture.new(), MonetarySeparatorsFixture.new(), frozenClock) val result = zatoshi.toFiatCurrencyState(
currencyConversion,
LocaleFixture.new(),
MonetarySeparatorsFixture.new(),
frozenClock
)
assertIs<FiatCurrencyConversionRateState.Unavailable>(result) assertIs<FiatCurrencyConversionRateState.Unavailable>(result)
} }
@ -55,7 +67,12 @@ class FiatCurrencyConversionRateStateTest {
timestamp = CurrencyConversionFixture.TIMESTAMP - 1.seconds timestamp = CurrencyConversionFixture.TIMESTAMP - 1.seconds
) )
val result = zatoshi.toFiatCurrencyState(currencyConversion, LocaleFixture.new(), MonetarySeparatorsFixture.new(), frozenClock) val result = zatoshi.toFiatCurrencyState(
currencyConversion,
LocaleFixture.new(),
MonetarySeparatorsFixture.new(),
frozenClock
)
assertIs<FiatCurrencyConversionRateState.Current>(result) assertIs<FiatCurrencyConversionRateState.Current>(result)
} }
@ -68,10 +85,17 @@ class FiatCurrencyConversionRateStateTest {
val frozenClock = FrozenClock(CurrencyConversionFixture.TIMESTAMP) val frozenClock = FrozenClock(CurrencyConversionFixture.TIMESTAMP)
val currencyConversion = CurrencyConversionFixture.new( val currencyConversion = CurrencyConversionFixture.new(
timestamp = CurrencyConversionFixture.TIMESTAMP - FiatCurrencyConversionRateState.CURRENT_CUTOFF_AGE_INCLUSIVE - 1.seconds timestamp = CurrencyConversionFixture.TIMESTAMP -
FiatCurrencyConversionRateState.CURRENT_CUTOFF_AGE_INCLUSIVE -
1.seconds
) )
val result = zatoshi.toFiatCurrencyState(currencyConversion, LocaleFixture.new(), MonetarySeparatorsFixture.new(), frozenClock) val result = zatoshi.toFiatCurrencyState(
currencyConversion,
LocaleFixture.new(),
MonetarySeparatorsFixture.new(),
frozenClock
)
assertIs<FiatCurrencyConversionRateState.Stale>(result) assertIs<FiatCurrencyConversionRateState.Stale>(result)
} }
@ -84,10 +108,17 @@ class FiatCurrencyConversionRateStateTest {
val frozenClock = FrozenClock(CurrencyConversionFixture.TIMESTAMP) val frozenClock = FrozenClock(CurrencyConversionFixture.TIMESTAMP)
val currencyConversion = CurrencyConversionFixture.new( val currencyConversion = CurrencyConversionFixture.new(
timestamp = CurrencyConversionFixture.TIMESTAMP - FiatCurrencyConversionRateState.STALE_CUTOFF_AGE_INCLUSIVE - 1.seconds timestamp = CurrencyConversionFixture.TIMESTAMP -
FiatCurrencyConversionRateState.STALE_CUTOFF_AGE_INCLUSIVE -
1.seconds
) )
val result = zatoshi.toFiatCurrencyState(currencyConversion, LocaleFixture.new(), MonetarySeparatorsFixture.new(), frozenClock) val result = zatoshi.toFiatCurrencyState(
currencyConversion,
LocaleFixture.new(),
MonetarySeparatorsFixture.new(),
frozenClock
)
assertIs<FiatCurrencyConversionRateState.Unavailable>(result) assertIs<FiatCurrencyConversionRateState.Unavailable>(result)
} }
@ -97,7 +128,11 @@ class FiatCurrencyConversionRateStateTest {
fun null_conversion_rate() { fun null_conversion_rate() {
val zatoshi = ZatoshiFixture.new() val zatoshi = ZatoshiFixture.new()
val result = zatoshi.toFiatCurrencyState(null, LocaleFixture.new(), MonetarySeparatorsFixture.new()) val result = zatoshi.toFiatCurrencyState(
null,
LocaleFixture.new(),
MonetarySeparatorsFixture.new()
)
assertIs<FiatCurrencyConversionRateState.Unavailable>(result) assertIs<FiatCurrencyConversionRateState.Unavailable>(result)
} }

View File

@ -24,7 +24,10 @@ class PersistableWalletTest {
assertEquals(1, jsonObject.getInt(PersistableWallet.KEY_VERSION)) assertEquals(1, jsonObject.getInt(PersistableWallet.KEY_VERSION))
assertEquals(ZcashNetwork.Testnet.id, jsonObject.getInt(PersistableWallet.KEY_NETWORK_ID)) assertEquals(ZcashNetwork.Testnet.id, jsonObject.getInt(PersistableWallet.KEY_NETWORK_ID))
assertEquals(PersistableWalletFixture.SEED_PHRASE.joinToString(), jsonObject.getString(PersistableWallet.KEY_SEED_PHRASE)) assertEquals(
PersistableWalletFixture.SEED_PHRASE.joinToString(),
jsonObject.getString(PersistableWallet.KEY_SEED_PHRASE)
)
// Birthday serialization is tested in a separate file // Birthday serialization is tested in a separate file
} }

View File

@ -89,7 +89,11 @@ class ZecStringExtTest {
assertTrue(it.matches("123${EN_US_SEPARATORS.decimal}456")) assertTrue(it.matches("123${EN_US_SEPARATORS.decimal}456"))
assertTrue(it.matches("123${EN_US_SEPARATORS.grouping}456${EN_US_SEPARATORS.decimal}")) assertTrue(it.matches("123${EN_US_SEPARATORS.grouping}456${EN_US_SEPARATORS.decimal}"))
assertTrue(it.matches("123${EN_US_SEPARATORS.grouping}456${EN_US_SEPARATORS.decimal}789")) assertTrue(it.matches("123${EN_US_SEPARATORS.grouping}456${EN_US_SEPARATORS.decimal}789"))
assertTrue(it.matches("1${EN_US_SEPARATORS.grouping}234${EN_US_SEPARATORS.grouping}567${EN_US_SEPARATORS.decimal}00")) assertTrue(
it.matches(
"1${EN_US_SEPARATORS.grouping}234${EN_US_SEPARATORS.grouping}567${EN_US_SEPARATORS.decimal}00"
)
)
} }
} }
@ -152,17 +156,52 @@ class ZecStringExtTest {
fun check_digits_between_grouping_separators_valid_test() { fun check_digits_between_grouping_separators_valid_test() {
assertTrue(ZecStringExt.checkFor3Digits(EN_US_SEPARATORS, "123")) assertTrue(ZecStringExt.checkFor3Digits(EN_US_SEPARATORS, "123"))
assertTrue(ZecStringExt.checkFor3Digits(EN_US_SEPARATORS, "1${EN_US_SEPARATORS.grouping}234")) assertTrue(ZecStringExt.checkFor3Digits(EN_US_SEPARATORS, "1${EN_US_SEPARATORS.grouping}234"))
assertTrue(ZecStringExt.checkFor3Digits(EN_US_SEPARATORS, "1${EN_US_SEPARATORS.grouping}234${EN_US_SEPARATORS.grouping}")) assertTrue(
assertTrue(ZecStringExt.checkFor3Digits(EN_US_SEPARATORS, "1${EN_US_SEPARATORS.grouping}234${EN_US_SEPARATORS.grouping}5")) ZecStringExt.checkFor3Digits(
assertTrue(ZecStringExt.checkFor3Digits(EN_US_SEPARATORS, "1${EN_US_SEPARATORS.grouping}234${EN_US_SEPARATORS.grouping}567${EN_US_SEPARATORS.grouping}8")) EN_US_SEPARATORS,
"1${EN_US_SEPARATORS.grouping}234${EN_US_SEPARATORS.grouping}"
)
)
assertTrue(
ZecStringExt.checkFor3Digits(
EN_US_SEPARATORS,
"1${EN_US_SEPARATORS.grouping}234${EN_US_SEPARATORS.grouping}5"
)
)
assertTrue(
ZecStringExt.checkFor3Digits(
EN_US_SEPARATORS,
"1${EN_US_SEPARATORS.grouping}234${EN_US_SEPARATORS.grouping}567${EN_US_SEPARATORS.grouping}8"
)
)
} }
@Test @Test
@SmallTest @SmallTest
fun check_digits_between_grouping_separators_invalid_test() { fun check_digits_between_grouping_separators_invalid_test() {
assertFalse(ZecStringExt.checkFor3Digits(EN_US_SEPARATORS, "1${EN_US_SEPARATORS.grouping}1${EN_US_SEPARATORS.grouping}2")) assertFalse(
assertFalse(ZecStringExt.checkFor3Digits(EN_US_SEPARATORS, "1${EN_US_SEPARATORS.grouping}12${EN_US_SEPARATORS.grouping}3")) ZecStringExt.checkFor3Digits(
assertFalse(ZecStringExt.checkFor3Digits(EN_US_SEPARATORS, "1${EN_US_SEPARATORS.grouping}1234${EN_US_SEPARATORS.grouping}")) EN_US_SEPARATORS,
assertFalse(ZecStringExt.checkFor3Digits(EN_US_SEPARATORS, "1${EN_US_SEPARATORS.grouping}123${EN_US_SEPARATORS.grouping}4${EN_US_SEPARATORS.grouping}")) "1${EN_US_SEPARATORS.grouping}1${EN_US_SEPARATORS.grouping}2"
)
)
assertFalse(
ZecStringExt.checkFor3Digits(
EN_US_SEPARATORS,
"1${EN_US_SEPARATORS.grouping}12${EN_US_SEPARATORS.grouping}3"
)
)
assertFalse(
ZecStringExt.checkFor3Digits(
EN_US_SEPARATORS,
"1${EN_US_SEPARATORS.grouping}1234${EN_US_SEPARATORS.grouping}"
)
)
assertFalse(
ZecStringExt.checkFor3Digits(
EN_US_SEPARATORS,
"1${EN_US_SEPARATORS.grouping}123${EN_US_SEPARATORS.grouping}4${EN_US_SEPARATORS.grouping}"
)
)
} }
} }

View File

@ -29,7 +29,7 @@ data class FiatCurrency(val code: String) {
init { init {
require(code.length == 3) { "Fiat currency code must be 3 characters long." } require(code.length == 3) { "Fiat currency code must be 3 characters long." }
// TODO [#532] https://github.com/zcash/secant-android-wallet/issues/532 // TODO [#532]: Add another check to make sure the code is in the known ISO currency code list.
// Add another check to make sure the code is in the known ISO currency code list. // TODO [#532]: https://github.com/zcash/secant-android-wallet/issues/532
} }
} }

View File

@ -16,7 +16,8 @@ enum class TestPurpose {
COMMIT, COMMIT,
/** /**
* These tests require a running instance of [darksidewalletd](https://github.com/zcash/lightwalletd/blob/master/docs/darksidewalletd.md). * These tests require a running instance of
* [darksidewalletd](https://github.com/zcash/lightwalletd/blob/master/docs/darksidewalletd.md).
*/ */
DARKSIDE DARKSIDE
} }

View File

@ -20,6 +20,7 @@ object BlockExplorer {
} }
object Transactions { object Transactions {
@Suppress("MaxLineLength")
val outbound = arrayOf( val outbound = arrayOf(
"https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/t-shielded-spend.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/t-shielded-spend.txt",
"https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/sent/c9e35e6ff444b071d63bf9bab6480409d6361760445c8a28d24179adb35c2495.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/sent/c9e35e6ff444b071d63bf9bab6480409d6361760445c8a28d24179adb35c2495.txt",
@ -32,6 +33,7 @@ object Transactions {
"https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/sent/73c5edf8ffba774d99155121ccf07e67fbcf14284458f7e732751fea60d3bcbc.txt" "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/sent/73c5edf8ffba774d99155121ccf07e67fbcf14284458f7e732751fea60d3bcbc.txt"
) )
@Suppress("MaxLineLength")
val inbound = arrayOf( val inbound = arrayOf(
"https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/recv/8f064d23c66dc36e32445e5f3b50e0f32ac3ddb78cff21fb521eb6c19c07c99a.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/recv/8f064d23c66dc36e32445e5f3b50e0f32ac3ddb78cff21fb521eb6c19c07c99a.txt",
"https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/recv/15a677b6770c5505fb47439361d3d3a7c21238ee1a6874fdedad18ae96850590.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/recv/15a677b6770c5505fb47439361d3d3a7c21238ee1a6874fdedad18ae96850590.txt",

View File

@ -8,8 +8,8 @@ import cash.z.ecc.android.sdk.model.ZcashNetwork
object WalletFixture { object WalletFixture {
val NETWORK = ZcashNetwork.Mainnet val NETWORK = ZcashNetwork.Mainnet
const val SEED_PHRASE = const val SEED_PHRASE = "kitchen renew wide common vague fold vacuum tilt amazing pear square gossip jewel month" +
"kitchen renew wide common vague fold vacuum tilt amazing pear square gossip jewel month tree shock scan alpha just spot fluid toilet view dinner" " tree shock scan alpha just spot fluid toilet view dinner"
suspend fun getUnifiedSpendingKey( suspend fun getUnifiedSpendingKey(
seed: String = SEED_PHRASE, seed: String = SEED_PHRASE,

View File

@ -19,7 +19,6 @@ import co.electriccoin.lightwallet.client.model.BlockHeightUnsafe
import co.electriccoin.lightwallet.client.model.LightWalletEndpoint import co.electriccoin.lightwallet.client.model.LightWalletEndpoint
import co.electriccoin.lightwallet.client.model.Response import co.electriccoin.lightwallet.client.model.Response
import co.electriccoin.lightwallet.client.new import co.electriccoin.lightwallet.client.new
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.filterNotNull
@ -41,7 +40,6 @@ class TestnetIntegrationTest : ScopedTest() {
@Test @Test
@Ignore("This test is broken") @Ignore("This test is broken")
@OptIn(ExperimentalCoroutinesApi::class)
fun testLatestBlockTest() = runTest { fun testLatestBlockTest() = runTest {
val service = LightWalletClient.new( val service = LightWalletClient.new(
context, context,
@ -101,7 +99,11 @@ class TestnetIntegrationTest : ScopedTest() {
} }
private suspend fun sendFunds(): Boolean { private suspend fun sendFunds(): Boolean {
val spendingKey = DerivationTool.getInstance().deriveUnifiedSpendingKey(seed, synchronizer.network, Account.DEFAULT) val spendingKey = DerivationTool.getInstance().deriveUnifiedSpendingKey(
seed,
synchronizer.network,
Account.DEFAULT
)
log("sending to address") log("sending to address")
synchronizer.sendToAddress( synchronizer.sendToAddress(
spendingKey, spendingKey,
@ -121,8 +123,8 @@ class TestnetIntegrationTest : ScopedTest() {
val lightWalletEndpoint = LightWalletEndpoint("lightwalletd.testnet.z.cash", 9087, true) val lightWalletEndpoint = LightWalletEndpoint("lightwalletd.testnet.z.cash", 9087, true)
private const val birthdayHeight = 963150L private const val birthdayHeight = 963150L
private const val targetHeight = 663250 private const val targetHeight = 663250
private const val seedPhrase = private const val seedPhrase = "still champion voice habit trend flight survey between bitter process" +
"still champion voice habit trend flight survey between bitter process artefact blind carbon truly provide dizzy crush flush breeze blouse charge solid fish spread" " artefact blind carbon truly provide dizzy crush flush breeze blouse charge solid fish spread"
val seed = "cash.z.ecc.android.sdk.integration.IntegrationTest.seed.value.64bytes".toByteArray() val seed = "cash.z.ecc.android.sdk.integration.IntegrationTest.seed.value.64bytes".toByteArray()
val address = "zs1m30y59wxut4zk9w24d6ujrdnfnl42hpy0ugvhgyhr8s0guszutqhdj05c7j472dndjstulph74m" val address = "zs1m30y59wxut4zk9w24d6ujrdnfnl42hpy0ugvhgyhr8s0guszutqhdj05c7j472dndjstulph74m"
val toAddress = "zs1vp7kvlqr4n9gpehztr76lcn6skkss9p8keqs3nv8avkdtjrcctrvmk9a7u494kluv756jeee5k0" val toAddress = "zs1vp7kvlqr4n9gpehztr76lcn6skkss9p8keqs3nv8avkdtjrcctrvmk9a7u494kluv756jeee5k0"

View File

@ -250,7 +250,9 @@ class FileCompactBlockRepositoryTest {
val tempFile = block.createTemporaryFile(blocksDir) val tempFile = block.createTemporaryFile(blocksDir)
val finalizedFile = File(tempFile.absolutePath.dropLast(FileCompactBlockRepository.TEMPORARY_FILENAME_SUFFIX.length)) val finalizedFile = File(
tempFile.absolutePath.dropLast(FileCompactBlockRepository.TEMPORARY_FILENAME_SUFFIX.length)
)
assertFalse { finalizedFile.existsSuspend() } assertFalse { finalizedFile.existsSuspend() }
tempFile.finalizeFile() tempFile.finalizeFile()

View File

@ -32,19 +32,28 @@ class BranchIdTest internal constructor(
fun testBranchId_Hex() { fun testBranchId_Hex() {
val branchId = rustBackend.getBranchIdForHeight(height) val branchId = rustBackend.getBranchIdForHeight(height)
val clientBranch = "%x".format(branchId) val clientBranch = "%x".format(branchId)
assertEquals("Invalid branch Id Hex value for $networkName at height $height on ${rustBackend.network.networkName}", branchHex, clientBranch) assertEquals(
"Invalid branch Id Hex value for $networkName at height $height on ${rustBackend.network.networkName}",
branchHex,
clientBranch
)
} }
@Test @Test
fun testBranchId_Numeric() { fun testBranchId_Numeric() {
val actual = rustBackend.getBranchIdForHeight(height) val actual = rustBackend.getBranchIdForHeight(height)
assertEquals("Invalid branch ID for $networkName at height $height on ${rustBackend.network.networkName}", branchId, actual) assertEquals(
"Invalid branch ID for $networkName at height $height on ${rustBackend.network.networkName}",
branchId,
actual
)
} }
companion object { companion object {
@JvmStatic @JvmStatic
@Parameterized.Parameters @Parameterized.Parameters
@Suppress("LongMethod")
fun wallets(): List<Array<Any>> { fun wallets(): List<Array<Any>> {
// init values don't matter for this test because we're just checking branchIds, which // init values don't matter for this test because we're just checking branchIds, which
// is an abnormal use of the SDK because this really should run at the rust level // is an abnormal use of the SDK because this really should run at the rust level
@ -70,16 +79,64 @@ class BranchIdTest internal constructor(
} }
return listOf( return listOf(
// Mainnet Cases // Mainnet Cases
arrayOf("Sapling", BlockHeight.new(ZcashNetwork.Mainnet, 419_200), 1991772603L, "76b809bb", mainnetBackend), arrayOf(
arrayOf("Blossom", BlockHeight.new(ZcashNetwork.Mainnet, 653_600), 733220448L, "2bb40e60", mainnetBackend), "Sapling",
arrayOf("Heartwood", BlockHeight.new(ZcashNetwork.Mainnet, 903_000), 4122551051L, "f5b9230b", mainnetBackend), BlockHeight.new(ZcashNetwork.Mainnet, 419_200),
arrayOf("Canopy", BlockHeight.new(ZcashNetwork.Mainnet, 1_046_400), 3925833126L, "e9ff75a6", mainnetBackend), 1991772603L,
"76b809bb",
mainnetBackend
),
arrayOf(
"Blossom",
BlockHeight.new(ZcashNetwork.Mainnet, 653_600),
733220448L,
"2bb40e60",
mainnetBackend
),
arrayOf(
"Heartwood",
BlockHeight.new(ZcashNetwork.Mainnet, 903_000),
4122551051L,
"f5b9230b",
mainnetBackend
),
arrayOf(
"Canopy",
BlockHeight.new(ZcashNetwork.Mainnet, 1_046_400),
3925833126L,
"e9ff75a6",
mainnetBackend
),
// Testnet Cases // Testnet Cases
arrayOf("Sapling", BlockHeight.new(ZcashNetwork.Testnet, 280_000), 1991772603L, "76b809bb", testnetBackend), arrayOf(
arrayOf("Blossom", BlockHeight.new(ZcashNetwork.Testnet, 584_000), 733220448L, "2bb40e60", testnetBackend), "Sapling",
arrayOf("Heartwood", BlockHeight.new(ZcashNetwork.Testnet, 903_800), 4122551051L, "f5b9230b", testnetBackend), BlockHeight.new(ZcashNetwork.Testnet, 280_000),
arrayOf("Canopy", BlockHeight.new(ZcashNetwork.Testnet, 1_028_500), 3925833126L, "e9ff75a6", testnetBackend) 1991772603L,
"76b809bb",
testnetBackend
),
arrayOf(
"Blossom",
BlockHeight.new(ZcashNetwork.Testnet, 584_000),
733220448L,
"2bb40e60",
testnetBackend
),
arrayOf(
"Heartwood",
BlockHeight.new(ZcashNetwork.Testnet, 903_800),
4122551051L,
"f5b9230b",
testnetBackend
),
arrayOf(
"Canopy",
BlockHeight.new(ZcashNetwork.Testnet, 1_028_500),
3925833126L,
"e9ff75a6",
testnetBackend
)
) )
} }
} }

View File

@ -39,10 +39,12 @@ class TransparentTest(val expected: Expected, val network: ZcashNetwork) {
} }
companion object { companion object {
const val PHRASE = "deputy visa gentle among clean scout farm drive comfort patch skin salt ranch cool ramp warrior drink narrow normal lunch behind salt deal person" const val PHRASE = "deputy visa gentle among clean scout farm drive comfort patch skin salt ranch cool ramp" +
" warrior drink narrow normal lunch behind salt deal person"
val MNEMONIC = MnemonicCode(PHRASE) val MNEMONIC = MnemonicCode(PHRASE)
val SEED = MNEMONIC.toSeed() val SEED = MNEMONIC.toSeed()
@Suppress("MaxLineLength")
object ExpectedMainnet : Expected { object ExpectedMainnet : Expected {
override val tAddr = "t1PKtYdJJHhc3Pxowmznkg7vdTwnhEsCvR4" override val tAddr = "t1PKtYdJJHhc3Pxowmznkg7vdTwnhEsCvR4"
override val zAddr = "zs1yc4sgtfwwzz6xfsy2xsradzr6m4aypgxhfw2vcn3hatrh5ryqsr08sgpemlg39vdh9kfupx20py" override val zAddr = "zs1yc4sgtfwwzz6xfsy2xsradzr6m4aypgxhfw2vcn3hatrh5ryqsr08sgpemlg39vdh9kfupx20py"
@ -52,6 +54,7 @@ class TransparentTest(val expected: Expected, val network: ZcashNetwork) {
override val tpk = "03b1d7fb28d17c125b504d06b1530097e0a3c76ada184237e3bc0925041230a5af" override val tpk = "03b1d7fb28d17c125b504d06b1530097e0a3c76ada184237e3bc0925041230a5af"
} }
@Suppress("MaxLineLength")
object ExpectedTestnet : Expected { object ExpectedTestnet : Expected {
override val tAddr = "tm9v3KTsjXK8XWSqiwFjic6Vda6eHY9Mjjq" override val tAddr = "tm9v3KTsjXK8XWSqiwFjic6Vda6eHY9Mjjq"
override val zAddr = "ztestsapling1wn3tw9w5rs55x5yl586gtk72e8hcfdq8zsnjzcu8p7ghm8lrx54axc74mvm335q7lmy3g0sqje6" override val zAddr = "ztestsapling1wn3tw9w5rs55x5yl586gtk72e8hcfdq8zsnjzcu8p7ghm8lrx54axc74mvm335q7lmy3g0sqje6"

View File

@ -13,7 +13,10 @@ import org.junit.Test
*/ */
class ShieldFundsSample { class ShieldFundsSample {
val SEED_PHRASE = "still champion voice habit trend flight survey between bitter process artefact blind carbon truly provide dizzy crush flush breeze blouse charge solid fish spread" // \"//\"deputy visa gentle among clean scout farm drive comfort patch skin salt ranch cool ramp warrior drink narrow normal lunch behind salt deal person"//"deputy visa gentle among clean scout farm drive comfort patch skin salt ranch cool ramp warrior drink narrow normal lunch behind salt deal person" val SEED_PHRASE = "still champion voice habit trend flight survey between bitter process artefact blind carbon" +
" truly provide dizzy crush flush breeze blouse charge solid fish spread"
// "deputy visa gentle among clean scout farm drive comfort patch skin salt ranch cool ramp warrior drink narrow
// normal lunch behind salt deal person"
/** /**
* This test will construct a t2z transaction. It is safe to run this repeatedly, because * This test will construct a t2z transaction. It is safe to run this repeatedly, because

View File

@ -1,3 +1,5 @@
@file:Suppress("MaxLineLength")
package cash.z.ecc.android.sdk.sample package cash.z.ecc.android.sdk.sample
import androidx.test.filters.LargeTest import androidx.test.filters.LargeTest
@ -55,7 +57,11 @@ class TransparentRestoreSample {
val tbalance = wallet.transparentBalance() val tbalance = wallet.transparentBalance()
val address = wallet.transparentAddress val address = wallet.transparentAddress
Assert.assertTrue("Not enough funds to run sample. Expected some Zatoshi but found ${tbalance.available}. Try adding funds to $address", tbalance.available.value > 0) Assert.assertTrue(
"Not enough funds to run sample. Expected some Zatoshi but found ${tbalance.available}. " +
"Try adding funds to $address",
tbalance.available.value > 0
)
// wallet.shieldFunds() // wallet.shieldFunds()
} }

View File

@ -145,10 +145,11 @@ class TestWallet(
} }
enum class Backups(val seedPhrase: String, val testnetBirthday: BlockHeight, val mainnetBirthday: BlockHeight) { enum class Backups(val seedPhrase: String, val testnetBirthday: BlockHeight, val mainnetBirthday: BlockHeight) {
// TODO: [#902] Get the proper birthday values for test wallets // TODO [#902]: Get the proper birthday values for test wallets
// TODO: [#902] https://github.com/zcash/zcash-android-wallet-sdk/issues/902 // TODO [#902]: https://github.com/zcash/zcash-android-wallet-sdk/issues/902
DEFAULT( DEFAULT(
"column rhythm acoustic gym cost fit keen maze fence seed mail medal shrimp tell relief clip cannon foster soldier shallow refuse lunar parrot banana", "column rhythm acoustic gym cost fit keen maze fence seed mail medal shrimp tell relief clip" +
" cannon foster soldier shallow refuse lunar parrot banana",
BlockHeight.new( BlockHeight.new(
ZcashNetwork.Testnet, ZcashNetwork.Testnet,
1_355_928 1_355_928
@ -156,7 +157,8 @@ class TestWallet(
BlockHeight.new(ZcashNetwork.Mainnet, 1_000_000) BlockHeight.new(ZcashNetwork.Mainnet, 1_000_000)
), ),
SAMPLE_WALLET( SAMPLE_WALLET(
"input frown warm senior anxiety abuse yard prefer churn reject people glimpse govern glory crumble swallow verb laptop switch trophy inform friend permit purpose", "input frown warm senior anxiety abuse yard prefer churn reject people glimpse govern glory" +
" crumble swallow verb laptop switch trophy inform friend permit purpose",
BlockHeight.new( BlockHeight.new(
ZcashNetwork.Testnet, ZcashNetwork.Testnet,
1_330_190 1_330_190
@ -164,7 +166,8 @@ class TestWallet(
BlockHeight.new(ZcashNetwork.Mainnet, 1_000_000) BlockHeight.new(ZcashNetwork.Mainnet, 1_000_000)
), ),
DEV_WALLET( DEV_WALLET(
"still champion voice habit trend flight survey between bitter process artefact blind carbon truly provide dizzy crush flush breeze blouse charge solid fish spread", "still champion voice habit trend flight survey between bitter process artefact blind carbon" +
" truly provide dizzy crush flush breeze blouse charge solid fish spread",
BlockHeight.new( BlockHeight.new(
ZcashNetwork.Testnet, ZcashNetwork.Testnet,
1_000_000 1_000_000
@ -172,7 +175,8 @@ class TestWallet(
BlockHeight.new(ZcashNetwork.Mainnet, 991645) BlockHeight.new(ZcashNetwork.Mainnet, 991645)
), ),
ALICE( ALICE(
"quantum whisper lion route fury lunar pelican image job client hundred sauce chimney barely life cliff spirit admit weekend message recipe trumpet impact kitten", "quantum whisper lion route fury lunar pelican image job client hundred sauce chimney barely" +
" life cliff spirit admit weekend message recipe trumpet impact kitten",
BlockHeight.new( BlockHeight.new(
ZcashNetwork.Testnet, ZcashNetwork.Testnet,
1_330_190 1_330_190
@ -180,7 +184,8 @@ class TestWallet(
BlockHeight.new(ZcashNetwork.Mainnet, 1_000_000) BlockHeight.new(ZcashNetwork.Mainnet, 1_000_000)
), ),
BOB( BOB(
"canvas wine sugar acquire garment spy tongue odor hole cage year habit bullet make label human unit option top calm neutral try vocal arena", "canvas wine sugar acquire garment spy tongue odor hole cage year habit bullet make label human" +
" unit option top calm neutral try vocal arena",
BlockHeight.new( BlockHeight.new(
ZcashNetwork.Testnet, ZcashNetwork.Testnet,
1_330_190 1_330_190

View File

@ -186,7 +186,7 @@ interface Synchronizer {
/** /**
* Returns true when the given address is a valid z-addr. Invalid addresses will throw an * Returns true when the given address is a valid z-addr. Invalid addresses will throw an
* exception. Valid z-addresses have these characteristics: //TODO copy info from related ZIP * exception. See valid z-addresses characteristics in related ZIP.
* *
* @param address the address to validate. * @param address the address to validate.
* *
@ -198,7 +198,7 @@ interface Synchronizer {
/** /**
* Returns true when the given address is a valid t-addr. Invalid addresses will throw an * Returns true when the given address is a valid t-addr. Invalid addresses will throw an
* exception. Valid t-addresses have these characteristics: //TODO copy info from related ZIP * exception. See valid t-addresses characteristics in related ZIP.
* *
* @param address the address to validate. * @param address the address to validate.
* *

View File

@ -480,7 +480,7 @@ class CompactBlockProcessor internal constructor(
runCatching { info.blockHeightUnsafe.toBlockHeight(network) }.getOrNull() runCatching { info.blockHeightUnsafe.toBlockHeight(network) }.getOrNull()
if (null == serverBlockHeight) { if (null == serverBlockHeight) {
// TODO Better signal network connection issue // Note: we could better signal network connection issue
CompactBlockProcessorException.BadBlockHeight(info.blockHeightUnsafe) CompactBlockProcessorException.BadBlockHeight(info.blockHeightUnsafe)
} else { } else {
val clientBranch = "%x".format( val clientBranch = "%x".format(
@ -534,7 +534,7 @@ class CompactBlockProcessor internal constructor(
internal suspend fun refreshUtxos(account: Account, startHeight: BlockHeight): Int { internal suspend fun refreshUtxos(account: Account, startHeight: BlockHeight): Int {
Twig.debug { "Checking for UTXOs above height $startHeight" } Twig.debug { "Checking for UTXOs above height $startHeight" }
var count = 0 var count = 0
// TODO [683]: cleanup the way that we prevent this from running excessively // TODO [#683]: cleanup the way that we prevent this from running excessively
// For now, try for about 3 blocks per app launch. If the service fails it is // For now, try for about 3 blocks per app launch. If the service fails it is
// probably disabled on ligthtwalletd, so then stop trying until the next app launch. // probably disabled on ligthtwalletd, so then stop trying until the next app launch.
// TODO [#683]: https://github.com/zcash/zcash-android-wallet-sdk/issues/683 // TODO [#683]: https://github.com/zcash/zcash-android-wallet-sdk/issues/683
@ -606,7 +606,7 @@ class CompactBlockProcessor internal constructor(
* @return True in case of the UTXO processed successfully, false otherwise * @return True in case of the UTXO processed successfully, false otherwise
*/ */
internal suspend fun processUtxoResult(utxo: GetAddressUtxosReplyUnsafe): Boolean { internal suspend fun processUtxoResult(utxo: GetAddressUtxosReplyUnsafe): Boolean {
// TODO(str4d): We no longer clear UTXOs here, as rustBackend.putUtxo now uses an upsert instead of an insert. // Note (str4d): We no longer clear UTXOs here, as rustBackend.putUtxo now uses an upsert instead of an insert.
// This means that now-spent UTXOs would previously have been deleted, but now are left in the database (like // This means that now-spent UTXOs would previously have been deleted, but now are left in the database (like
// shielded notes). Due to the fact that the lightwalletd query only returns _current_ UTXOs, we don't learn // shielded notes). Due to the fact that the lightwalletd query only returns _current_ UTXOs, we don't learn
// about recently-spent UTXOs here, so the transparent balance does not get updated here. Instead, when a // about recently-spent UTXOs here, so the transparent balance does not get updated here. Instead, when a

View File

@ -92,7 +92,7 @@ open class CompactBlockDownloader private constructor(val compactBlockRepository
* @param height the height to which the data will rewind. * @param height the height to which the data will rewind.
*/ */
suspend fun rewindToHeight(height: BlockHeight) = suspend fun rewindToHeight(height: BlockHeight) =
// TODO [#685]: cancel anything in flight // TODO [#685]: Cancel anything in flight
// TODO [#685]: https://github.com/zcash/zcash-android-wallet-sdk/issues/685 // TODO [#685]: https://github.com/zcash/zcash-android-wallet-sdk/issues/685
compactBlockRepository.rewindTo(height) compactBlockRepository.rewindTo(height)

View File

@ -39,14 +39,14 @@
<ID>UnusedPrivateProperty:InboundTxTests.kt$InboundTxTests.Companion$private val txRecv = arrayOf( "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/recv/8f064d23c66dc36e32445e5f3b50e0f32ac3ddb78cff21fb521eb6c19c07c99a.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/recv/15a677b6770c5505fb47439361d3d3a7c21238ee1a6874fdedad18ae96850590.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/recv/d2e7be14bbb308f9d4d68de424d622cbf774226d01cd63cc6f155fafd5cd212c.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/recv/e6566be3a4f9a80035dab8e1d97e40832a639e3ea938fb7972ea2f8482ff51ce.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/recv/0821a89be7f2fc1311792c3fa1dd2171a8cdfb2effd98590cbd5ebcdcfcf491f.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/recv/e9527891b5d43d1ac72f2c0a3ac18a33dc5a0529aec04fa600616ed35f8123f8.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/recv/4dcc95dd0a2f1f51bd64bb9f729b423c6de1690664a1b6614c75925e781662f7.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/recv/75f2cdd2ff6a94535326abb5d9e663d53cbfa5f31ebb24b4d7e420e9440d41a2.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/recv/7690c8ec740c1be3c50e2aedae8bf907ac81141ae8b6a134c1811706c73f49a6.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/recv/71935e29127a7de0b96081f4c8a42a9c11584d83adedfaab414362a6f3d965cf.txt" )</ID> <ID>UnusedPrivateProperty:InboundTxTests.kt$InboundTxTests.Companion$private val txRecv = arrayOf( "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/recv/8f064d23c66dc36e32445e5f3b50e0f32ac3ddb78cff21fb521eb6c19c07c99a.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/recv/15a677b6770c5505fb47439361d3d3a7c21238ee1a6874fdedad18ae96850590.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/recv/d2e7be14bbb308f9d4d68de424d622cbf774226d01cd63cc6f155fafd5cd212c.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/recv/e6566be3a4f9a80035dab8e1d97e40832a639e3ea938fb7972ea2f8482ff51ce.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/recv/0821a89be7f2fc1311792c3fa1dd2171a8cdfb2effd98590cbd5ebcdcfcf491f.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/recv/e9527891b5d43d1ac72f2c0a3ac18a33dc5a0529aec04fa600616ed35f8123f8.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/recv/4dcc95dd0a2f1f51bd64bb9f729b423c6de1690664a1b6614c75925e781662f7.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/recv/75f2cdd2ff6a94535326abb5d9e663d53cbfa5f31ebb24b4d7e420e9440d41a2.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/recv/7690c8ec740c1be3c50e2aedae8bf907ac81141ae8b6a134c1811706c73f49a6.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/recv/71935e29127a7de0b96081f4c8a42a9c11584d83adedfaab414362a6f3d965cf.txt" )</ID>
<ID>UnusedPrivateProperty:InboundTxTests.kt$InboundTxTests.Companion$private val txSend = arrayOf( "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/t-shielded-spend.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/sent/c9e35e6ff444b071d63bf9bab6480409d6361760445c8a28d24179adb35c2495.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/sent/72a29d7db511025da969418880b749f7fc0fc910cdb06f52193b5fa5c0401d9d.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/sent/ff6ea36765dc29793775c7aa71de19fca039c5b5b873a0497866e9c4bc48af01.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/sent/34e507cab780546f980176f3ff2695cd404917508c7e5ee18cc1d2ff3858cb08.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/sent/6edf869063eccff3345676b0fed9f1aa6988fb2524e3d9ca7420a13cfadcd76c.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/sent/de97394ae220c28a33ba78b944e82dabec8cb404a4407650b134b3d5950358c0.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/sent/4eaa902279f8380914baf5bcc470d8b7c11d84fda809f67f517a7cb48912b87b.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/sent/73c5edf8ffba774d99155121ccf07e67fbcf14284458f7e732751fea60d3bcbc.txt" )</ID> <ID>UnusedPrivateProperty:InboundTxTests.kt$InboundTxTests.Companion$private val txSend = arrayOf( "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/t-shielded-spend.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/sent/c9e35e6ff444b071d63bf9bab6480409d6361760445c8a28d24179adb35c2495.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/sent/72a29d7db511025da969418880b749f7fc0fc910cdb06f52193b5fa5c0401d9d.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/sent/ff6ea36765dc29793775c7aa71de19fca039c5b5b873a0497866e9c4bc48af01.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/sent/34e507cab780546f980176f3ff2695cd404917508c7e5ee18cc1d2ff3858cb08.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/sent/6edf869063eccff3345676b0fed9f1aa6988fb2524e3d9ca7420a13cfadcd76c.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/sent/de97394ae220c28a33ba78b944e82dabec8cb404a4407650b134b3d5950358c0.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/sent/4eaa902279f8380914baf5bcc470d8b7c11d84fda809f67f517a7cb48912b87b.txt", "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/sent/73c5edf8ffba774d99155121ccf07e67fbcf14284458f7e732751fea60d3bcbc.txt" )</ID>
<ID>UnusedPrivateProperty:LightWalletClientImplTest.kt$LightWalletClientImplTest$private val channelFactory = AndroidChannelFactory(getAppContext())</ID> <ID>UnusedPrivateProperty:LightWalletClientImplTest.kt$LightWalletClientImplTest$private val channelFactory = AndroidChannelFactory(getAppContext())</ID>
<ID>UnusedPrivateProperty:SetupTest.kt$SetupTest.Companion$private const val blocksUrl = "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/basic-reorg/before-reorg.txt"</ID> <ID>UnusedPrivateProperty:SetupTest.kt$SetupTest.Companion$@Suppress("MaxLineLength") private const val blocksUrl = "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/basic-reorg/before-reorg.txt"</ID>
<ID>UnusedPrivateProperty:SetupTest.kt$SetupTest.Companion$private const val firstBlock = 663150</ID> <ID>UnusedPrivateProperty:SetupTest.kt$SetupTest.Companion$private const val firstBlock = 663150</ID>
<ID>UnusedPrivateProperty:SetupTest.kt$SetupTest.Companion$private const val lastBlock = 663200</ID> <ID>UnusedPrivateProperty:SetupTest.kt$SetupTest.Companion$private const val lastBlock = 663200</ID>
<ID>UnusedPrivateProperty:SetupTest.kt$SetupTest.Companion$private const val lastBlockHash = "2fc7b4682f5ba6ba6f86e170b40f0aa9302e1d3becb2a6ee0db611ff87835e4a"</ID> <ID>UnusedPrivateProperty:SetupTest.kt$SetupTest.Companion$private const val lastBlockHash = "2fc7b4682f5ba6ba6f86e170b40f0aa9302e1d3becb2a6ee0db611ff87835e4a"</ID>
<ID>UnusedPrivateProperty:TestnetIntegrationTest.kt$TestnetIntegrationTest.Companion$private const val seedPhrase = "still champion voice habit trend flight survey between bitter process artefact blind carbon truly provide dizzy crush flush breeze blouse charge solid fish spread"</ID> <ID>UnusedPrivateProperty:TestnetIntegrationTest.kt$TestnetIntegrationTest.Companion$private const val seedPhrase = "still champion voice habit trend flight survey between bitter process" + " artefact blind carbon truly provide dizzy crush flush breeze blouse charge solid fish spread"</ID>
<ID>UnusedPrivateProperty:TestnetIntegrationTest.kt$TestnetIntegrationTest.Companion$private const val targetHeight = 663250</ID> <ID>UnusedPrivateProperty:TestnetIntegrationTest.kt$TestnetIntegrationTest.Companion$private const val targetHeight = 663250</ID>
<ID>VariableNaming:FakeRustBackendFixture.kt$FakeRustBackendFixture$private val DEFAULT_NETWORK = ZcashNetwork.Testnet</ID> <ID>VariableNaming:FakeRustBackendFixture.kt$FakeRustBackendFixture$private val DEFAULT_NETWORK = ZcashNetwork.Testnet</ID>
<ID>VariableNaming:ShieldFundsSample.kt$ShieldFundsSample$val SEED_PHRASE = "still champion voice habit trend flight survey between bitter process artefact blind carbon truly provide dizzy crush flush breeze blouse charge solid fish spread" // \"//\"deputy visa gentle among clean scout farm drive comfort patch skin salt ranch cool ramp warrior drink narrow normal lunch behind salt deal person"//"deputy visa gentle among clean scout farm drive comfort patch skin salt ranch cool ramp warrior drink narrow normal lunch behind salt deal person"</ID> <ID>VariableNaming:ShieldFundsSample.kt$ShieldFundsSample$val SEED_PHRASE = "still champion voice habit trend flight survey between bitter process artefact blind carbon" + " truly provide dizzy crush flush breeze blouse charge solid fish spread"</ID>
<ID>VariableNaming:TransparentRestoreSample.kt$TransparentRestoreSample$val TX_VALUE = Zatoshi(ZcashSdk.MINERS_FEE.value / 2)</ID> <ID>VariableNaming:TransparentRestoreSample.kt$TransparentRestoreSample$val TX_VALUE = Zatoshi(ZcashSdk.MINERS_FEE.value / 2)</ID>
</CurrentIssues> </CurrentIssues>
</SmellBaseline> </SmellBaseline>

View File

@ -13,20 +13,24 @@ style:
ForbiddenComment: ForbiddenComment:
active: true active: true
comments: comments:
- reason: 'Forbidden FIXME todo marker in comment, please fix the problem.' - reason: 'Forbidden FIXME todo marker in comment, please fix the problem. Or include issue number prefix for
value: 'FIXME:' FIXME comments, e.g. `FIXME [#123]: Fix this later`'
- reason: 'Forbidden TODO todo marker in comment, please fix the problem or add the issue number (e.g. TODO [#123]).' value: 'FIXME'
value: 'TODO:(?! \[[^\]]\d+\])' - reason: 'Forbidden STOPSHIP todo marker in comment, please address the problem before shipping the code. Or
MaxLineLength: include issue number prefix for STOPSHIP comments, e.g. `STOPSHIP [#123]: Fix this later`'
active: false value: 'STOPSHIP'
- reason: 'Forbidden TODO todo marker in comment, please do the changes. Or include issue number prefix for TODO
comments, e.g. `TODO [#123]: Fix this later`'
value: 'TODO'
allowedPatterns: '[TODO|FIXME|STOPSHIP]+\s\[#\d+\]:\s.+'
NewLineAtEndOfFile: NewLineAtEndOfFile:
active: false active: false
UnusedPrivateMember: UnusedPrivateMember:
active: true active: true
allowedNames: '(_|ignored|expected|serialVersionUID)' allowedNames: '(_|ignored|expected|serialVersionUID)'
excludes: [ '**/*.kts' ] excludes: [ '**/*.kts' ]
WildcardImport: ignoreAnnotated:
active: false - 'Preview'
Compose: Compose:
ModifierMissing: ModifierMissing: