[#1225] Disable deprecated darkside tests

* [#1225] Disable deprecated darkside tests

- Closes #1225
This commit is contained in:
Honza Rychnovský 2023-09-08 17:35:56 +02:00 committed by Honza
parent c6032b47bd
commit 3721b8b6c4
5 changed files with 37 additions and 26 deletions

View File

@ -10,11 +10,13 @@ import org.junit.runner.RunWith
/** /**
* Integration test to run in order to catch any regressions in transparent behavior. * Integration test to run in order to catch any regressions in transparent behavior.
*/ */
// TODO [#1224]: Refactor and re-enable disabled darkside tests
// TODO [#1224]: https://github.com/zcash/zcash-android-wallet-sdk/issues/1224
@RunWith(AndroidJUnit4::class) @RunWith(AndroidJUnit4::class)
class TransparentIntegrationTest : DarksideTest() { class TransparentIntegrationTest : DarksideTest() {
@Before @Before
fun setup() = runOnce { fun setup() = runOnce {
sithLord.await() // sithLord.await()
} }
@Test @Test

View File

@ -6,15 +6,19 @@ import cash.z.ecc.android.sdk.darkside.test.ScopedTest
import cash.z.ecc.android.sdk.model.BlockHeight import cash.z.ecc.android.sdk.model.BlockHeight
import cash.z.ecc.android.sdk.model.ZcashNetwork import cash.z.ecc.android.sdk.model.ZcashNetwork
import org.junit.BeforeClass import org.junit.BeforeClass
import org.junit.Ignore
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
// TODO [#1224]: Refactor and re-enable disabled darkside tests
// TODO [#1224]: https://github.com/zcash/zcash-android-wallet-sdk/issues/1224
@RunWith(AndroidJUnit4::class) @RunWith(AndroidJUnit4::class)
class InboundTxTests : ScopedTest() { class InboundTxTests : ScopedTest() {
@Test @Test
@Ignore("Temporarily disabled")
fun testTargetBlock_synced() { fun testTargetBlock_synced() {
validator.validateMinHeightSynced(firstBlock) // validator.validateMinHeightSynced(firstBlock)
} }
@Test @Test
@ -28,10 +32,11 @@ class InboundTxTests : ScopedTest() {
} }
@Test @Test
@Ignore("Temporarily disabled")
fun testTxCountAfter() { fun testTxCountAfter() {
// add 2 transactions to block 663188 and 'mine' that block // add 2 transactions to block 663188 and 'mine' that block
addTransactions(targetTxBlock, tx663174, tx663188) addTransactions(targetTxBlock, tx663174, tx663188)
sithLord.await(timeout = 30_000L, targetHeight = targetTxBlock) // sithLord.await(timeout = 30_000L, targetHeight = targetTxBlock)
validator.validateTxCount(2) validator.validateTxCount(2)
} }
@ -91,7 +96,7 @@ class InboundTxTests : ScopedTest() {
.stageEmptyBlocks(firstBlock + 1, 100) .stageEmptyBlocks(firstBlock + 1, 100)
.applyTipHeight(BlockHeight.new(ZcashNetwork.Mainnet, targetTxBlock.value - 1)) .applyTipHeight(BlockHeight.new(ZcashNetwork.Mainnet, targetTxBlock.value - 1))
sithLord.await() // sithLord.await()
} }
} }
} }

View File

@ -3,34 +3,39 @@ package cash.z.ecc.android.sdk.darkside.reorgs
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import cash.z.ecc.android.sdk.darkside.test.DarksideTestCoordinator import cash.z.ecc.android.sdk.darkside.test.DarksideTestCoordinator
import cash.z.ecc.android.sdk.darkside.test.ScopedTest import cash.z.ecc.android.sdk.darkside.test.ScopedTest
import cash.z.ecc.android.sdk.model.BlockHeight
import cash.z.ecc.android.sdk.model.ZcashNetwork
import org.junit.Before import org.junit.Before
import org.junit.BeforeClass import org.junit.BeforeClass
import org.junit.Ignore
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
// TODO [#1224]: Refactor and re-enable disabled darkside tests
// TODO [#1224]: https://github.com/zcash/zcash-android-wallet-sdk/issues/1224
@RunWith(AndroidJUnit4::class) @RunWith(AndroidJUnit4::class)
class ReorgSetupTest : ScopedTest() { class ReorgSetupTest : ScopedTest() {
/*
private val birthdayHeight = BlockHeight.new(ZcashNetwork.Mainnet, 663150) private val birthdayHeight = BlockHeight.new(ZcashNetwork.Mainnet, 663150)
private val targetHeight = BlockHeight.new(ZcashNetwork.Mainnet, 663250) private val targetHeight = BlockHeight.new(ZcashNetwork.Mainnet, 663250)
*/
@Before @Before
fun setup() { fun setup() {
sithLord.await() // sithLord.await()
} }
@Test @Test
@Ignore("Temporarily disabled")
fun testBeforeReorg_minHeight() = timeout(30_000L) { fun testBeforeReorg_minHeight() = timeout(30_000L) {
// validate that we are synced, at least to the birthday height // validate that we are synced, at least to the birthday height
validator.validateMinHeightSynced(birthdayHeight) // validator.validateMinHeightSynced(birthdayHeight)
} }
@Test @Test
@Ignore("Temporarily disabled")
fun testBeforeReorg_maxHeight() = timeout(30_000L) { fun testBeforeReorg_maxHeight() = timeout(30_000L) {
// validate that we are not synced beyond the target height // validate that we are not synced beyond the target height
validator.validateMaxHeightSynced(targetHeight) // validator.validateMaxHeightSynced(targetHeight)
} }
companion object { companion object {

View File

@ -3,45 +3,49 @@ package cash.z.ecc.android.sdk.darkside.reorgs
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import cash.z.ecc.android.sdk.darkside.test.DarksideTestCoordinator import cash.z.ecc.android.sdk.darkside.test.DarksideTestCoordinator
import cash.z.ecc.android.sdk.darkside.test.ScopedTest import cash.z.ecc.android.sdk.darkside.test.ScopedTest
import cash.z.ecc.android.sdk.model.BlockHeight
import cash.z.ecc.android.sdk.model.ZcashNetwork
import org.junit.Assert.assertTrue import org.junit.Assert.assertTrue
import org.junit.Before import org.junit.Before
import org.junit.BeforeClass import org.junit.BeforeClass
import org.junit.Ignore
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class) @RunWith(AndroidJUnit4::class)
class ReorgSmallTest : ScopedTest() { class ReorgSmallTest : ScopedTest() {
/*
private val targetHeight = BlockHeight.new( private val targetHeight = BlockHeight.new(
ZcashNetwork.Mainnet, ZcashNetwork.Mainnet,
663250 663250
) )
private val hashBeforeReorg = "09ec0d5de30d290bc5a2318fbf6a2427a81c7db4790ce0e341a96aeac77108b9" private val hashBeforeReorg = "09ec0d5de30d290bc5a2318fbf6a2427a81c7db4790ce0e341a96aeac77108b9"
private val hashAfterReorg = "tbd" private val hashAfterReorg = "tbd"
*/
@Before @Before
fun setup() { fun setup() {
sithLord.await() // sithLord.await()
} }
@Test @Test
@Ignore("Temporarily disabled")
fun testBeforeReorg_latestBlockHash() = timeout(30_000L) { fun testBeforeReorg_latestBlockHash() = timeout(30_000L) {
validator.validateBlockHash(targetHeight, hashBeforeReorg) // validator.validateBlockHash(targetHeight, hashBeforeReorg)
} }
@Test @Test
@Ignore("Temporarily disabled")
fun testAfterReorg_callbackTriggered() = timeout(30_000L) { fun testAfterReorg_callbackTriggered() = timeout(30_000L) {
hadReorg = false hadReorg = false
// sithLord.triggerSmallReorg() // sithLord.triggerSmallReorg()
sithLord.await() // sithLord.await()
assertTrue(hadReorg) assertTrue(hadReorg)
} }
@Test @Test
@Ignore("Temporarily disabled")
fun testAfterReorg_latestBlockHash() = timeout(30_000L) { fun testAfterReorg_latestBlockHash() = timeout(30_000L) {
validator.validateBlockHash(targetHeight, hashAfterReorg) // validator.validateBlockHash(targetHeight, hashAfterReorg)
} }
companion object { companion object {

View File

@ -2,7 +2,6 @@ package cash.z.ecc.android.sdk.darkside.test
import androidx.test.core.app.ApplicationProvider import androidx.test.core.app.ApplicationProvider
import androidx.test.platform.app.InstrumentationRegistry import androidx.test.platform.app.InstrumentationRegistry
import cash.z.ecc.android.sdk.Synchronizer
import cash.z.ecc.android.sdk.model.Account import cash.z.ecc.android.sdk.model.Account
import cash.z.ecc.android.sdk.model.BlockHeight import cash.z.ecc.android.sdk.model.BlockHeight
import cash.z.ecc.android.sdk.model.Darkside import cash.z.ecc.android.sdk.model.Darkside
@ -13,15 +12,14 @@ import co.electriccoin.lightwallet.client.model.BlockHeightUnsafe
import co.electriccoin.lightwallet.client.model.LightWalletEndpoint import co.electriccoin.lightwallet.client.model.LightWalletEndpoint
import io.grpc.StatusRuntimeException import io.grpc.StatusRuntimeException
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import org.junit.Assert import org.junit.Assert
import org.junit.Assert.assertEquals import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertTrue import org.junit.Assert.assertTrue
// TODO [#1224]: Refactor and re-enable disabled darkside tests
// TODO [#1224]: https://github.com/zcash/zcash-android-wallet-sdk/issues/1224
class DarksideTestCoordinator(val wallet: TestWallet) { class DarksideTestCoordinator(val wallet: TestWallet) {
constructor( constructor(
alias: String = "DarksideTestCoordinator", alias: String = "DarksideTestCoordinator",
@ -95,6 +93,7 @@ class DarksideTestCoordinator(val wallet: TestWallet) {
* Waits for, at most, the given amount of time for the synchronizer to download and scan blocks * Waits for, at most, the given amount of time for the synchronizer to download and scan blocks
* and reach a 'SYNCED' status. * and reach a 'SYNCED' status.
*/ */
/*
fun await(timeout: Long = 60_000L, targetHeight: BlockHeight? = null) = runBlocking { fun await(timeout: Long = 60_000L, targetHeight: BlockHeight? = null) = runBlocking {
ScopedTest.timeoutWith(this, timeout) { ScopedTest.timeoutWith(this, timeout) {
synchronizer.status.map { status -> synchronizer.status.map { status ->
@ -110,6 +109,7 @@ class DarksideTestCoordinator(val wallet: TestWallet) {
}.filter { it == Synchronizer.Status.SYNCED }.first() }.filter { it == Synchronizer.Status.SYNCED }.first()
} }
} }
*/
// /** // /**
// * Send a transaction and wait until it has been fully created and successfully submitted, which // * Send a transaction and wait until it has been fully created and successfully submitted, which
@ -135,13 +135,6 @@ class DarksideTestCoordinator(val wallet: TestWallet) {
inner class DarksideTestValidator { inner class DarksideTestValidator {
fun validateHasBlock(height: BlockHeight) {
runBlocking {
assertTrue(synchronizer.findBlockHashAsHex(height) != null)
assertTrue(synchronizer.findBlockHash(height)?.size ?: 0 > 0)
}
}
fun validateLatestHeight(height: BlockHeight) = runBlocking<Unit> { fun validateLatestHeight(height: BlockHeight) = runBlocking<Unit> {
val info = synchronizer.processorInfo.first() val info = synchronizer.processorInfo.first()
val networkBlockHeight = info.networkBlockHeight val networkBlockHeight = info.networkBlockHeight
@ -152,6 +145,7 @@ class DarksideTestCoordinator(val wallet: TestWallet) {
) )
} }
/*
fun validateMinHeightSynced(minHeight: BlockHeight) = runBlocking<Unit> { fun validateMinHeightSynced(minHeight: BlockHeight) = runBlocking<Unit> {
val info = synchronizer.processorInfo.first() val info = synchronizer.processorInfo.first()
val lastSyncedHeight = info.lastSyncedHeight val lastSyncedHeight = info.lastSyncedHeight
@ -177,6 +171,7 @@ class DarksideTestCoordinator(val wallet: TestWallet) {
val hash = runBlocking { synchronizer.findBlockHashAsHex(height) } val hash = runBlocking { synchronizer.findBlockHashAsHex(height) }
assertEquals(expectedHash, hash) assertEquals(expectedHash, hash)
} }
*/
fun onReorg(callback: (errorHeight: BlockHeight, rewindHeight: BlockHeight) -> Unit) { fun onReorg(callback: (errorHeight: BlockHeight, rewindHeight: BlockHeight) -> Unit) {
synchronizer.onChainErrorHandler = callback synchronizer.onChainErrorHandler = callback