mirror of
https://github.com/pezkuwichain/pezkuwi-wallet-android.git
synced 2026-07-22 13:45:48 +00:00
fix: unnecessary stubbing + missing assertTrue import in Tron backfill test
@Before's preferences.getBoolean stub was never invoked by migrate()-only tests (only migrationNeeded() reads that preference), tripping Mockito's strict-stubs UnnecessaryStubbingException across the whole class. Moved it into a dedicated migrationNeeded() test, matched via any() rather than the production class's private preference-key constant (which isn't visible here), and added the missing assertTrue import.
This commit is contained in:
+11
-2
@@ -17,6 +17,7 @@ import io.novasama.substrate_sdk_android.encrypt.json.JsonDecoder
|
||||
import io.novasama.substrate_sdk_android.encrypt.mnemonic.MnemonicCreator
|
||||
import io.novasama.substrate_sdk_android.scale.EncodableStruct
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
@@ -79,10 +80,18 @@ class TronAddressBackfillMigrationTest {
|
||||
// Real factory, not a mock - the whole point of this test is to exercise the actual derivation.
|
||||
val accountSecretsFactory = AccountSecretsFactory(jsonDecoder)
|
||||
subject = TronAddressBackfillMigration(preferences, secretStoreV2, metaAccountDao, accountSecretsFactory)
|
||||
}
|
||||
|
||||
// any() would try to unbox a null placeholder into the primitive Boolean parameter and crash - Mockito's
|
||||
// own anyBoolean() returns a real `false` default instead, avoiding that entirely.
|
||||
@Test
|
||||
fun `migrationNeeded should reflect the persisted flag`(): Unit = runBlocking {
|
||||
// The flag's preference key is a private implementation detail of the production class - matched via
|
||||
// any() here rather than duplicating the literal key string, which would let this test pass even if
|
||||
// that string silently drifted out of sync with the production code.
|
||||
whenever(preferences.getBoolean(any(), Mockito.anyBoolean())).thenReturn(false)
|
||||
assertTrue(subject.migrationNeeded())
|
||||
|
||||
whenever(preferences.getBoolean(any(), Mockito.anyBoolean())).thenReturn(true)
|
||||
assertTrue(!subject.migrationNeeded())
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user