2021-09-26 05:14:11 -07:00
|
|
|
package cash.z.ecc.android.sdk.darkside.reorgs
|
2020-06-09 19:11:07 -07:00
|
|
|
|
2021-09-26 05:14:11 -07:00
|
|
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
|
|
|
import cash.z.ecc.android.sdk.darkside.test.DarksideTestCoordinator
|
|
|
|
import cash.z.ecc.android.sdk.darkside.test.ScopedTest
|
2020-06-09 19:11:07 -07:00
|
|
|
import org.junit.Assert.assertTrue
|
|
|
|
import org.junit.Before
|
|
|
|
import org.junit.BeforeClass
|
2023-09-08 08:35:56 -07:00
|
|
|
import org.junit.Ignore
|
2020-06-09 19:11:07 -07:00
|
|
|
import org.junit.Test
|
2021-09-26 05:14:11 -07:00
|
|
|
import org.junit.runner.RunWith
|
2020-06-09 19:11:07 -07:00
|
|
|
|
2021-09-26 05:14:11 -07:00
|
|
|
@RunWith(AndroidJUnit4::class)
|
2020-06-09 19:11:07 -07:00
|
|
|
class ReorgSmallTest : ScopedTest() {
|
2023-09-08 08:35:56 -07:00
|
|
|
/*
|
2022-07-12 05:40:09 -07:00
|
|
|
private val targetHeight = BlockHeight.new(
|
|
|
|
ZcashNetwork.Mainnet,
|
|
|
|
663250
|
|
|
|
)
|
2020-06-09 19:11:07 -07:00
|
|
|
private val hashBeforeReorg = "09ec0d5de30d290bc5a2318fbf6a2427a81c7db4790ce0e341a96aeac77108b9"
|
|
|
|
private val hashAfterReorg = "tbd"
|
2023-09-08 08:35:56 -07:00
|
|
|
*/
|
2020-06-09 19:11:07 -07:00
|
|
|
|
|
|
|
@Before
|
|
|
|
fun setup() {
|
2023-09-08 08:35:56 -07:00
|
|
|
// sithLord.await()
|
2020-06-09 19:11:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2023-09-08 08:35:56 -07:00
|
|
|
@Ignore("Temporarily disabled")
|
2024-01-04 12:21:32 -08:00
|
|
|
fun testBeforeReorg_latestBlockHash() =
|
|
|
|
timeout(30_000L) {
|
|
|
|
// validator.validateBlockHash(targetHeight, hashBeforeReorg)
|
|
|
|
}
|
2020-06-09 19:11:07 -07:00
|
|
|
|
|
|
|
@Test
|
2023-09-08 08:35:56 -07:00
|
|
|
@Ignore("Temporarily disabled")
|
2024-01-04 12:21:32 -08:00
|
|
|
fun testAfterReorg_callbackTriggered() =
|
|
|
|
timeout(30_000L) {
|
|
|
|
hadReorg = false
|
2020-06-09 19:11:07 -07:00
|
|
|
// sithLord.triggerSmallReorg()
|
2023-09-08 08:35:56 -07:00
|
|
|
// sithLord.await()
|
2024-01-04 12:21:32 -08:00
|
|
|
assertTrue(hadReorg)
|
|
|
|
}
|
2020-06-09 19:11:07 -07:00
|
|
|
|
|
|
|
@Test
|
2023-09-08 08:35:56 -07:00
|
|
|
@Ignore("Temporarily disabled")
|
2024-01-04 12:21:32 -08:00
|
|
|
fun testAfterReorg_latestBlockHash() =
|
|
|
|
timeout(30_000L) {
|
|
|
|
// validator.validateBlockHash(targetHeight, hashAfterReorg)
|
|
|
|
}
|
2020-06-09 19:11:07 -07:00
|
|
|
|
|
|
|
companion object {
|
2021-09-26 05:14:11 -07:00
|
|
|
private val sithLord = DarksideTestCoordinator()
|
2020-06-09 19:11:07 -07:00
|
|
|
private val validator = sithLord.validator
|
|
|
|
private var hadReorg = false
|
|
|
|
|
|
|
|
@BeforeClass
|
|
|
|
@JvmStatic
|
|
|
|
fun startOnce() {
|
|
|
|
sithLord.enterTheDarkside()
|
|
|
|
validator.onReorg { _, _ ->
|
|
|
|
hadReorg = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|