[#1287] Remove LightWalletEndpointExt public API
- Closes #1287 - This refactored out all the occurrences of LightWalletEndpointExt and its functions and variables from the SDK’s public API. It preserves it in tests, demo app, and in the PersistableWallet for backward compatibility, although it’s not available from outside of the SDK. - Changelog updated
This commit is contained in:
parent
d8902d11df
commit
68cfd21fe7
|
@ -9,6 +9,11 @@ and this library adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
### Added
|
||||
- `TransactionOverview.txIdString()` to provide a readable transaction ID to SDK-consuming apps
|
||||
|
||||
### Removed
|
||||
- `LightWalletEndpointExt` and its functions and variables were removed from the SDK's public APIs entirely. It's
|
||||
preserved only for testing and wallet Demo app purposes. The calling wallet app should provide its own
|
||||
`LightWalletEndpoint` instance within `PersistableWallet` or `SdkSynchornizer` APIs.
|
||||
|
||||
### Changed
|
||||
- Gradle 8.5
|
||||
- Kotlin 1.9.21
|
||||
|
|
|
@ -2,9 +2,9 @@ package cash.z.ecc.android.sdk.darkside.test
|
|||
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import cash.z.ecc.android.sdk.ext.Darkside
|
||||
import cash.z.ecc.android.sdk.model.Account
|
||||
import cash.z.ecc.android.sdk.model.BlockHeight
|
||||
import cash.z.ecc.android.sdk.model.Darkside
|
||||
import cash.z.ecc.android.sdk.model.ZcashNetwork
|
||||
import co.electriccoin.lightwallet.client.internal.DarksideApi
|
||||
import co.electriccoin.lightwallet.client.internal.new
|
||||
|
|
|
@ -6,10 +6,10 @@ import cash.z.ecc.android.bip39.toSeed
|
|||
import cash.z.ecc.android.sdk.SdkSynchronizer
|
||||
import cash.z.ecc.android.sdk.Synchronizer
|
||||
import cash.z.ecc.android.sdk.WalletInitMode
|
||||
import cash.z.ecc.android.sdk.ext.Darkside
|
||||
import cash.z.ecc.android.sdk.internal.Twig
|
||||
import cash.z.ecc.android.sdk.model.Account
|
||||
import cash.z.ecc.android.sdk.model.BlockHeight
|
||||
import cash.z.ecc.android.sdk.model.Darkside
|
||||
import cash.z.ecc.android.sdk.model.WalletBalance
|
||||
import cash.z.ecc.android.sdk.model.Zatoshi
|
||||
import cash.z.ecc.android.sdk.model.ZcashNetwork
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
@file:Suppress("ktlint:standard:filename")
|
||||
|
||||
package cash.z.ecc.android.sdk.ext
|
||||
|
||||
import co.electriccoin.lightwallet.client.model.LightWalletEndpoint
|
||||
|
||||
/*
|
||||
* This is a set of the [LightWalletEndpoint] extension functions used for the darkside tests only and not part of the
|
||||
* public APIs.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is a special localhost value on the Android emulator, which allows it to contact
|
||||
* the localhost of the computer running the emulator.
|
||||
*/
|
||||
private const val COMPUTER_LOCALHOST = "10.0.2.2"
|
||||
|
||||
private const val DEFAULT_PORT = 9067
|
||||
|
||||
internal val LightWalletEndpoint.Companion.Darkside
|
||||
get() =
|
||||
LightWalletEndpoint(
|
||||
COMPUTER_LOCALHOST,
|
||||
DEFAULT_PORT,
|
||||
isSecure = false
|
||||
)
|
|
@ -3,15 +3,15 @@ package cash.z.wallet.sdk.sample.demoapp
|
|||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import cash.z.ecc.android.sdk.Synchronizer
|
||||
import cash.z.ecc.android.sdk.WalletInitMode
|
||||
import cash.z.ecc.android.sdk.demoapp.ext.Mainnet
|
||||
import cash.z.ecc.android.sdk.demoapp.ext.defaultForNetwork
|
||||
import cash.z.ecc.android.sdk.demoapp.util.fromResources
|
||||
import cash.z.ecc.android.sdk.ext.convertZecToZatoshi
|
||||
import cash.z.ecc.android.sdk.ext.toHex
|
||||
import cash.z.ecc.android.sdk.internal.Twig
|
||||
import cash.z.ecc.android.sdk.model.Account
|
||||
import cash.z.ecc.android.sdk.model.BlockHeight
|
||||
import cash.z.ecc.android.sdk.model.Mainnet
|
||||
import cash.z.ecc.android.sdk.model.ZcashNetwork
|
||||
import cash.z.ecc.android.sdk.model.defaultForNetwork
|
||||
import cash.z.ecc.android.sdk.tool.DerivationTool
|
||||
import co.electriccoin.lightwallet.client.LightWalletClient
|
||||
import co.electriccoin.lightwallet.client.model.BlockHeightUnsafe
|
||||
|
|
|
@ -20,9 +20,9 @@ import androidx.navigation.ui.navigateUp
|
|||
import androidx.navigation.ui.setupActionBarWithNavController
|
||||
import androidx.navigation.ui.setupWithNavController
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import cash.z.ecc.android.sdk.demoapp.ext.defaultForNetwork
|
||||
import cash.z.ecc.android.sdk.demoapp.util.fromResources
|
||||
import cash.z.ecc.android.sdk.model.ZcashNetwork
|
||||
import cash.z.ecc.android.sdk.model.defaultForNetwork
|
||||
import co.electriccoin.lightwallet.client.LightWalletClient
|
||||
import co.electriccoin.lightwallet.client.model.LightWalletEndpoint
|
||||
import co.electriccoin.lightwallet.client.new
|
||||
|
|
|
@ -7,12 +7,12 @@ import cash.z.ecc.android.bip39.Mnemonics
|
|||
import cash.z.ecc.android.bip39.toSeed
|
||||
import cash.z.ecc.android.sdk.Synchronizer
|
||||
import cash.z.ecc.android.sdk.WalletInitMode
|
||||
import cash.z.ecc.android.sdk.demoapp.ext.defaultForNetwork
|
||||
import cash.z.ecc.android.sdk.demoapp.util.fromResources
|
||||
import cash.z.ecc.android.sdk.ext.onFirst
|
||||
import cash.z.ecc.android.sdk.internal.Twig
|
||||
import cash.z.ecc.android.sdk.model.BlockHeight
|
||||
import cash.z.ecc.android.sdk.model.ZcashNetwork
|
||||
import cash.z.ecc.android.sdk.model.defaultForNetwork
|
||||
import co.electriccoin.lightwallet.client.ext.BenchmarkingExt
|
||||
import co.electriccoin.lightwallet.client.fixture.BenchmarkingBlockRangeFixture
|
||||
import co.electriccoin.lightwallet.client.model.LightWalletEndpoint
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
@file:Suppress("ktlint:standard:filename")
|
||||
|
||||
package cash.z.ecc.android.sdk.demoapp.ext
|
||||
|
||||
import cash.z.ecc.android.sdk.model.ZcashNetwork
|
||||
import co.electriccoin.lightwallet.client.model.LightWalletEndpoint
|
||||
|
||||
/*
|
||||
* This set of extension functions suited for defaults for the Demo app is not part of the SDK's public APIs.
|
||||
*/
|
||||
|
||||
internal fun LightWalletEndpoint.Companion.defaultForNetwork(zcashNetwork: ZcashNetwork): LightWalletEndpoint {
|
||||
return when (zcashNetwork.id) {
|
||||
ZcashNetwork.Mainnet.id -> LightWalletEndpoint.Mainnet
|
||||
ZcashNetwork.Testnet.id -> LightWalletEndpoint.Testnet
|
||||
else -> error("Unknown network id: ${zcashNetwork.id}")
|
||||
}
|
||||
}
|
||||
|
||||
private const val DEFAULT_PORT = 9067
|
||||
|
||||
internal val LightWalletEndpoint.Companion.Mainnet
|
||||
get() =
|
||||
LightWalletEndpoint(
|
||||
"mainnet.lightwalletd.com",
|
||||
DEFAULT_PORT,
|
||||
isSecure = true
|
||||
)
|
||||
|
||||
internal val LightWalletEndpoint.Companion.Testnet
|
||||
get() =
|
||||
LightWalletEndpoint(
|
||||
"lightwalletd.testnet.electriccoin.co",
|
||||
DEFAULT_PORT,
|
||||
isSecure = true
|
||||
)
|
|
@ -9,6 +9,7 @@ import cash.z.ecc.android.sdk.Synchronizer
|
|||
import cash.z.ecc.android.sdk.WalletCoordinator
|
||||
import cash.z.ecc.android.sdk.WalletInitMode
|
||||
import cash.z.ecc.android.sdk.block.processor.CompactBlockProcessor
|
||||
import cash.z.ecc.android.sdk.demoapp.ext.defaultForNetwork
|
||||
import cash.z.ecc.android.sdk.demoapp.getInstance
|
||||
import cash.z.ecc.android.sdk.demoapp.preference.EncryptedPreferenceKeys
|
||||
import cash.z.ecc.android.sdk.demoapp.preference.EncryptedPreferenceSingleton
|
||||
|
@ -25,7 +26,6 @@ import cash.z.ecc.android.sdk.model.WalletBalance
|
|||
import cash.z.ecc.android.sdk.model.Zatoshi
|
||||
import cash.z.ecc.android.sdk.model.ZcashNetwork
|
||||
import cash.z.ecc.android.sdk.model.ZecSend
|
||||
import cash.z.ecc.android.sdk.model.defaultForNetwork
|
||||
import cash.z.ecc.android.sdk.model.send
|
||||
import cash.z.ecc.android.sdk.tool.DerivationTool
|
||||
import co.electriccoin.lightwallet.client.model.LightWalletEndpoint
|
||||
|
|
|
@ -17,11 +17,11 @@ import androidx.compose.ui.res.stringResource
|
|||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import cash.z.ecc.android.sdk.WalletInitMode
|
||||
import cash.z.ecc.android.sdk.demoapp.R
|
||||
import cash.z.ecc.android.sdk.demoapp.ext.defaultForNetwork
|
||||
import cash.z.ecc.android.sdk.fixture.WalletFixture
|
||||
import cash.z.ecc.android.sdk.model.PersistableWallet
|
||||
import cash.z.ecc.android.sdk.model.SeedPhrase
|
||||
import cash.z.ecc.android.sdk.model.ZcashNetwork
|
||||
import cash.z.ecc.android.sdk.model.defaultForNetwork
|
||||
import co.electriccoin.lightwallet.client.model.LightWalletEndpoint
|
||||
|
||||
@Preview(name = "Seed")
|
||||
|
|
|
@ -124,8 +124,20 @@ class PersistableWalletTest {
|
|||
// Wallet version one deserialized by code supporting version two
|
||||
val persistableWallet = PersistableWallet.from(json)
|
||||
assertEquals(
|
||||
LightWalletEndpoint.defaultForNetwork(persistableWallet.network),
|
||||
getLightWalletEndpointForNetwork(persistableWallet.network),
|
||||
persistableWallet.endpoint
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
fun requireSecureMainnet() {
|
||||
assertTrue(LightWalletEndpoint.Mainnet.isSecure)
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
fun requireSecureTestnet() {
|
||||
assertTrue(LightWalletEndpoint.Testnet.isSecure)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import org.json.JSONObject
|
|||
* Represents everything needed to save and restore a wallet.
|
||||
*
|
||||
* @param network the network in which the wallet operates
|
||||
* @param endpoint the endpoint with witch the wallet communicates
|
||||
* @param endpoint the endpoint with which the wallet communicates
|
||||
* @param birthday the birthday of the wallet
|
||||
* @param seedPhrase the seed phrase of the wallet
|
||||
* @param walletInitMode required parameter with one of [WalletInitMode] values. Use [WalletInitMode.NewWallet] when
|
||||
|
@ -25,7 +25,7 @@ import org.json.JSONObject
|
|||
*/
|
||||
data class PersistableWallet(
|
||||
val network: ZcashNetwork,
|
||||
val endpoint: LightWalletEndpoint = LightWalletEndpoint.defaultForNetwork(network),
|
||||
val endpoint: LightWalletEndpoint,
|
||||
val birthday: BlockHeight?,
|
||||
val seedPhrase: SeedPhrase,
|
||||
val walletInitMode: WalletInitMode
|
||||
|
@ -82,7 +82,7 @@ data class PersistableWallet(
|
|||
|
||||
when (val version = getVersion(jsonObject)) {
|
||||
VERSION_1 -> {
|
||||
endpoint = LightWalletEndpoint.defaultForNetwork(network)
|
||||
endpoint = getLightWalletEndpointForNetwork(network)
|
||||
}
|
||||
VERSION_2 -> {
|
||||
endpoint = getEndpoint(jsonObject)
|
||||
|
@ -139,7 +139,7 @@ data class PersistableWallet(
|
|||
* @return A new PersistableWallet with a random seed phrase.
|
||||
*
|
||||
* @param zcashNetwork the network in which the wallet operates
|
||||
* @param endpoint the endpoint with witch the wallet communicates
|
||||
* @param endpoint the endpoint with which the wallet communicates
|
||||
* @param walletInitMode required parameter with one of [WalletInitMode] values. Use [WalletInitMode.NewWallet]
|
||||
* when starting synchronizer for a newly created wallet. Or use [WalletInitMode.RestoreWallet] when
|
||||
* restoring an existing wallet that was created at some point in the past. Or use the last [WalletInitMode
|
||||
|
@ -149,7 +149,7 @@ data class PersistableWallet(
|
|||
suspend fun new(
|
||||
application: Application,
|
||||
zcashNetwork: ZcashNetwork,
|
||||
endpoint: LightWalletEndpoint = LightWalletEndpoint.defaultForNetwork(zcashNetwork),
|
||||
endpoint: LightWalletEndpoint,
|
||||
walletInitMode: WalletInitMode
|
||||
): PersistableWallet {
|
||||
val birthday = BlockHeight.ofLatestCheckpoint(application, zcashNetwork)
|
||||
|
@ -200,3 +200,33 @@ private suspend fun newMnemonic() =
|
|||
}
|
||||
|
||||
private suspend fun newSeedPhrase() = SeedPhrase(newMnemonic().map { it.concatToString() })
|
||||
|
||||
/*
|
||||
* The following functions and variables are package private only and preserved to support backward compatibility for
|
||||
* [PersistableWallet] and testing purposes.
|
||||
*/
|
||||
internal fun getLightWalletEndpointForNetwork(zcashNetwork: ZcashNetwork): LightWalletEndpoint {
|
||||
return when (zcashNetwork.id) {
|
||||
ZcashNetwork.Mainnet.id -> LightWalletEndpoint.Mainnet
|
||||
ZcashNetwork.Testnet.id -> LightWalletEndpoint.Testnet
|
||||
else -> error("Unknown network id: ${zcashNetwork.id}")
|
||||
}
|
||||
}
|
||||
|
||||
private const val DEFAULT_PORT = 9067
|
||||
|
||||
internal val LightWalletEndpoint.Companion.Mainnet
|
||||
get() =
|
||||
LightWalletEndpoint(
|
||||
"mainnet.lightwalletd.com",
|
||||
DEFAULT_PORT,
|
||||
isSecure = true
|
||||
)
|
||||
|
||||
internal val LightWalletEndpoint.Companion.Testnet
|
||||
get() =
|
||||
LightWalletEndpoint(
|
||||
"lightwalletd.testnet.electriccoin.co",
|
||||
DEFAULT_PORT,
|
||||
isSecure = true
|
||||
)
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
@file:Suppress("ktlint:standard:filename")
|
||||
|
||||
package cash.z.ecc.android.sdk.fixture
|
||||
|
||||
import cash.z.ecc.android.sdk.model.ZcashNetwork
|
||||
import co.electriccoin.lightwallet.client.model.LightWalletEndpoint
|
||||
|
||||
/*
|
||||
* This is a set of extension functions for testing purposes only.
|
||||
*/
|
||||
|
||||
object LightWalletEndpointFixture {
|
||||
private const val DEFAULT_PORT = 9067
|
||||
|
||||
val LightWalletEndpoint.Companion.Mainnet
|
||||
get() =
|
||||
LightWalletEndpoint(
|
||||
"mainnet.lightwalletd.com",
|
||||
DEFAULT_PORT,
|
||||
isSecure = true
|
||||
)
|
||||
|
||||
val LightWalletEndpoint.Companion.Testnet
|
||||
get() =
|
||||
LightWalletEndpoint(
|
||||
"lightwalletd.testnet.electriccoin.co",
|
||||
DEFAULT_PORT,
|
||||
isSecure = true
|
||||
)
|
||||
|
||||
fun newEndpointForNetwork(zcashNetwork: ZcashNetwork): LightWalletEndpoint {
|
||||
return when (zcashNetwork.id) {
|
||||
ZcashNetwork.Mainnet.id -> LightWalletEndpoint.Mainnet
|
||||
ZcashNetwork.Testnet.id -> LightWalletEndpoint.Testnet
|
||||
else -> error("Unknown network id: ${zcashNetwork.id}")
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,7 +7,6 @@ import cash.z.ecc.android.sdk.annotation.TestPurpose
|
|||
import cash.z.ecc.android.sdk.internal.Twig
|
||||
import cash.z.ecc.android.sdk.internal.block.CompactBlockDownloader
|
||||
import cash.z.ecc.android.sdk.internal.repository.CompactBlockRepository
|
||||
import cash.z.ecc.android.sdk.model.Mainnet
|
||||
import cash.z.ecc.android.sdk.model.ZcashNetwork
|
||||
import cash.z.ecc.android.sdk.test.ScopedTest
|
||||
import co.electriccoin.lightwallet.client.LightWalletClient
|
||||
|
@ -15,7 +14,6 @@ import co.electriccoin.lightwallet.client.model.BlockHeightUnsafe
|
|||
import co.electriccoin.lightwallet.client.model.LightWalletEndpoint
|
||||
import co.electriccoin.lightwallet.client.model.Response
|
||||
import co.electriccoin.lightwallet.client.new
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertTrue
|
||||
|
@ -31,7 +29,7 @@ import kotlin.test.Ignore
|
|||
@SmallTest
|
||||
class ChangeServiceTest : ScopedTest() {
|
||||
val network = ZcashNetwork.Mainnet
|
||||
val lightWalletEndpoint = LightWalletEndpoint.Mainnet
|
||||
val lightWalletEndpoint = LightWalletEndpoint("mainnet.lightwalletd.com", 9067, true)
|
||||
private val eccEndpoint = LightWalletEndpoint("lightwalletd.electriccoin.co", 9087, true)
|
||||
|
||||
@Mock
|
||||
|
@ -60,8 +58,7 @@ class ChangeServiceTest : ScopedTest() {
|
|||
}
|
||||
|
||||
@Test
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
@Ignore
|
||||
@Ignore("Disabled as not working currently")
|
||||
fun testSanityCheck() =
|
||||
runTest {
|
||||
// Test the result, only if there is no server communication problem.
|
||||
|
|
|
@ -5,10 +5,9 @@ import androidx.test.platform.app.InstrumentationRegistry
|
|||
import cash.z.ecc.android.bip39.Mnemonics
|
||||
import cash.z.ecc.android.sdk.Synchronizer
|
||||
import cash.z.ecc.android.sdk.WalletInitMode
|
||||
import cash.z.ecc.android.sdk.fixture.LightWalletEndpointFixture
|
||||
import cash.z.ecc.android.sdk.fixture.WalletFixture
|
||||
import cash.z.ecc.android.sdk.model.ZcashNetwork
|
||||
import cash.z.ecc.android.sdk.model.defaultForNetwork
|
||||
import co.electriccoin.lightwallet.client.model.LightWalletEndpoint
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import java.util.UUID
|
||||
import kotlin.test.Test
|
||||
|
@ -28,7 +27,7 @@ class SdkSynchronizerTest {
|
|||
InstrumentationRegistry.getInstrumentation().context,
|
||||
ZcashNetwork.Mainnet,
|
||||
alias,
|
||||
LightWalletEndpoint.defaultForNetwork(ZcashNetwork.Mainnet),
|
||||
LightWalletEndpointFixture.newEndpointForNetwork(ZcashNetwork.Mainnet),
|
||||
Mnemonics.MnemonicCode(WalletFixture.SEED_PHRASE).toEntropy(),
|
||||
birthday = null,
|
||||
// Using existing wallet init mode as simplification for the test
|
||||
|
@ -39,7 +38,7 @@ class SdkSynchronizerTest {
|
|||
InstrumentationRegistry.getInstrumentation().context,
|
||||
ZcashNetwork.Mainnet,
|
||||
alias,
|
||||
LightWalletEndpoint.defaultForNetwork(ZcashNetwork.Mainnet),
|
||||
LightWalletEndpointFixture.newEndpointForNetwork(ZcashNetwork.Mainnet),
|
||||
Mnemonics.MnemonicCode(WalletFixture.SEED_PHRASE).toEntropy(),
|
||||
birthday = null,
|
||||
// Using existing wallet init mode as simplification for the test
|
||||
|
@ -64,7 +63,7 @@ class SdkSynchronizerTest {
|
|||
InstrumentationRegistry.getInstrumentation().context,
|
||||
ZcashNetwork.Mainnet,
|
||||
alias,
|
||||
LightWalletEndpoint.defaultForNetwork(ZcashNetwork.Mainnet),
|
||||
LightWalletEndpointFixture.newEndpointForNetwork(ZcashNetwork.Mainnet),
|
||||
Mnemonics.MnemonicCode(WalletFixture.SEED_PHRASE).toEntropy(),
|
||||
birthday = null,
|
||||
// Using existing wallet init mode as simplification for the test
|
||||
|
@ -76,7 +75,7 @@ class SdkSynchronizerTest {
|
|||
InstrumentationRegistry.getInstrumentation().context,
|
||||
ZcashNetwork.Mainnet,
|
||||
alias,
|
||||
LightWalletEndpoint.defaultForNetwork(ZcashNetwork.Mainnet),
|
||||
LightWalletEndpointFixture.newEndpointForNetwork(ZcashNetwork.Mainnet),
|
||||
Mnemonics.MnemonicCode(WalletFixture.SEED_PHRASE).toEntropy(),
|
||||
birthday = null,
|
||||
// Using existing wallet init mode as simplification for the test
|
||||
|
|
|
@ -4,15 +4,14 @@ import androidx.test.platform.app.InstrumentationRegistry
|
|||
import cash.z.ecc.android.sdk.CloseableSynchronizer
|
||||
import cash.z.ecc.android.sdk.Synchronizer
|
||||
import cash.z.ecc.android.sdk.WalletInitMode
|
||||
import cash.z.ecc.android.sdk.fixture.LightWalletEndpointFixture
|
||||
import cash.z.ecc.android.sdk.internal.Twig
|
||||
import cash.z.ecc.android.sdk.internal.ext.deleteSuspend
|
||||
import cash.z.ecc.android.sdk.internal.model.Checkpoint
|
||||
import cash.z.ecc.android.sdk.model.BlockHeight
|
||||
import cash.z.ecc.android.sdk.model.ZcashNetwork
|
||||
import cash.z.ecc.android.sdk.model.defaultForNetwork
|
||||
import cash.z.ecc.android.sdk.test.readFileLinesInFlow
|
||||
import cash.z.ecc.android.sdk.tool.CheckpointTool
|
||||
import co.electriccoin.lightwallet.client.model.LightWalletEndpoint
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.runBlocking
|
||||
|
@ -96,9 +95,7 @@ class BalancePrinterUtil {
|
|||
Synchronizer.new(
|
||||
context,
|
||||
network,
|
||||
lightWalletEndpoint =
|
||||
LightWalletEndpoint
|
||||
.defaultForNetwork(network),
|
||||
lightWalletEndpoint = LightWalletEndpointFixture.newEndpointForNetwork(network),
|
||||
seed = seed,
|
||||
birthday = birthdayHeight,
|
||||
// Using existing wallet init mode as simplification for the test
|
||||
|
|
|
@ -5,10 +5,9 @@ import cash.z.ecc.android.sdk.CloseableSynchronizer
|
|||
import cash.z.ecc.android.sdk.SdkSynchronizer
|
||||
import cash.z.ecc.android.sdk.Synchronizer
|
||||
import cash.z.ecc.android.sdk.WalletInitMode
|
||||
import cash.z.ecc.android.sdk.fixture.LightWalletEndpointFixture
|
||||
import cash.z.ecc.android.sdk.model.BlockHeight
|
||||
import cash.z.ecc.android.sdk.model.ZcashNetwork
|
||||
import cash.z.ecc.android.sdk.model.defaultForNetwork
|
||||
import co.electriccoin.lightwallet.client.model.LightWalletEndpoint
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
|
@ -69,9 +68,7 @@ class DataDbScannerUtil {
|
|||
Synchronizer.newBlocking(
|
||||
context,
|
||||
ZcashNetwork.Mainnet,
|
||||
lightWalletEndpoint =
|
||||
LightWalletEndpoint
|
||||
.defaultForNetwork(ZcashNetwork.Mainnet),
|
||||
lightWalletEndpoint = LightWalletEndpointFixture.newEndpointForNetwork(ZcashNetwork.Mainnet),
|
||||
seed = byteArrayOf(),
|
||||
birthday =
|
||||
BlockHeight.new(
|
||||
|
|
|
@ -6,12 +6,12 @@ import cash.z.ecc.android.bip39.toSeed
|
|||
import cash.z.ecc.android.sdk.SdkSynchronizer
|
||||
import cash.z.ecc.android.sdk.Synchronizer
|
||||
import cash.z.ecc.android.sdk.WalletInitMode
|
||||
import cash.z.ecc.android.sdk.fixture.LightWalletEndpointFixture
|
||||
import cash.z.ecc.android.sdk.internal.Twig
|
||||
import cash.z.ecc.android.sdk.internal.deriveUnifiedSpendingKey
|
||||
import cash.z.ecc.android.sdk.internal.jni.RustDerivationTool
|
||||
import cash.z.ecc.android.sdk.model.Account
|
||||
import cash.z.ecc.android.sdk.model.BlockHeight
|
||||
import cash.z.ecc.android.sdk.model.Testnet
|
||||
import cash.z.ecc.android.sdk.model.WalletBalance
|
||||
import cash.z.ecc.android.sdk.model.Zatoshi
|
||||
import cash.z.ecc.android.sdk.model.ZcashNetwork
|
||||
|
@ -35,7 +35,7 @@ class TestWallet(
|
|||
val seedPhrase: String,
|
||||
val alias: String = "TestWallet",
|
||||
val network: ZcashNetwork = ZcashNetwork.Testnet,
|
||||
val endpoint: LightWalletEndpoint = LightWalletEndpoint.Testnet,
|
||||
val endpoint: LightWalletEndpoint = LightWalletEndpointFixture.newEndpointForNetwork(ZcashNetwork.Testnet),
|
||||
startHeight: BlockHeight? = null
|
||||
) {
|
||||
constructor(
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package cash.z.ecc.android.sdk.util
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import cash.z.ecc.android.sdk.fixture.LightWalletEndpointFixture
|
||||
import cash.z.ecc.android.sdk.internal.Twig
|
||||
import cash.z.ecc.android.sdk.internal.model.ext.from
|
||||
import cash.z.ecc.android.sdk.model.BlockHeight
|
||||
import cash.z.ecc.android.sdk.model.Mainnet
|
||||
import cash.z.ecc.android.sdk.model.ZcashNetwork
|
||||
import co.electriccoin.lightwallet.client.LightWalletClient
|
||||
import co.electriccoin.lightwallet.client.model.BlockHeightUnsafe
|
||||
|
@ -15,7 +15,8 @@ import org.junit.Test
|
|||
|
||||
class TransactionCounterUtil {
|
||||
private val context = InstrumentationRegistry.getInstrumentation().context
|
||||
private val lightWalletClient = LightWalletClient.new(context, LightWalletEndpoint.Mainnet)
|
||||
private val endpoint: LightWalletEndpoint = LightWalletEndpointFixture.newEndpointForNetwork(ZcashNetwork.Mainnet)
|
||||
private val lightWalletClient = LightWalletClient.new(context, endpoint)
|
||||
|
||||
@Test
|
||||
@Ignore("This test is broken")
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
@file:Suppress("ktlint:standard:filename")
|
||||
|
||||
package cash.z.ecc.android.sdk.model
|
||||
|
||||
import co.electriccoin.lightwallet.client.model.LightWalletEndpoint
|
||||
|
||||
/*
|
||||
* This is a set of extension functions currently, because we expect them to change in the future.
|
||||
*/
|
||||
|
||||
fun LightWalletEndpoint.Companion.defaultForNetwork(zcashNetwork: ZcashNetwork): LightWalletEndpoint {
|
||||
return when (zcashNetwork.id) {
|
||||
ZcashNetwork.Mainnet.id -> LightWalletEndpoint.Mainnet
|
||||
ZcashNetwork.Testnet.id -> LightWalletEndpoint.Testnet
|
||||
else -> error("Unknown network id: ${zcashNetwork.id}")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a special localhost value on the Android emulator, which allows it to contact
|
||||
* the localhost of the computer running the emulator.
|
||||
*/
|
||||
private const val COMPUTER_LOCALHOST = "10.0.2.2"
|
||||
|
||||
private const val DEFAULT_PORT = 9067
|
||||
|
||||
val LightWalletEndpoint.Companion.Mainnet
|
||||
get() =
|
||||
LightWalletEndpoint(
|
||||
"mainnet.lightwalletd.com",
|
||||
DEFAULT_PORT,
|
||||
isSecure = true
|
||||
)
|
||||
|
||||
val LightWalletEndpoint.Companion.Testnet
|
||||
get() =
|
||||
LightWalletEndpoint(
|
||||
"lightwalletd.testnet.electriccoin.co",
|
||||
DEFAULT_PORT,
|
||||
isSecure = true
|
||||
)
|
||||
|
||||
val LightWalletEndpoint.Companion.Darkside
|
||||
get() =
|
||||
LightWalletEndpoint(
|
||||
COMPUTER_LOCALHOST,
|
||||
DEFAULT_PORT,
|
||||
isSecure = false
|
||||
)
|
|
@ -1,17 +0,0 @@
|
|||
package cash.z.ecc.android.sdk.model
|
||||
|
||||
import co.electriccoin.lightwallet.client.model.LightWalletEndpoint
|
||||
import org.junit.Test
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class LightWalletEndpointTest {
|
||||
@Test
|
||||
fun requireSecureMainnet() {
|
||||
assertTrue(LightWalletEndpoint.Mainnet.isSecure)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun requireSecureTestnet() {
|
||||
assertTrue(LightWalletEndpoint.Testnet.isSecure)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue