Skip to content

Commit

Permalink
verify previous hash works across multiple panel calls
Browse files Browse the repository at this point in the history
  • Loading branch information
jonesmac committed Nov 19, 2024
1 parent 811482a commit f218152
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion sdk/src/androidTest/java/network/xyo/client/XyoPanelTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.runBlocking
import network.xyo.client.account.Account
import network.xyo.client.boundwitness.XyoBoundWitnessJson
import network.xyo.client.datastore.previous_hash_store.PreviousHashStorePrefsRepository
import network.xyo.client.payload.XyoPayload
import network.xyo.client.witness.location.info.LocationActivity
import network.xyo.client.witness.location.info.XyoLocationWitness
Expand Down Expand Up @@ -44,6 +45,11 @@ class XyoPanelTest {
this.appContext = InstrumentationRegistry.getInstrumentation().targetContext
}

@Before
fun useAccount() {
Account.previousHashStore = PreviousHashStorePrefsRepository.getInstance(InstrumentationRegistry.getInstrumentation().targetContext)
}

private fun testCreatePanel(nodeUrl: String) {
val witness = XyoWitness<XyoPayload>(Account.random())
val panel = XyoPanel(appContext, Account.random(), arrayListOf(Pair(nodeUrl, Account.random())), listOf(witness))
Expand Down Expand Up @@ -94,12 +100,17 @@ class XyoPanelTest {
@Test
fun testSimplePanelReport() {
runBlocking {
val panel = XyoPanel(appContext, Account.random(), fun(_:Context): List<XyoEventPayload> {
val testAccount = Account.random()
val panel = XyoPanel(appContext, testAccount, fun(_:Context): List<XyoEventPayload> {
return listOf(XyoEventPayload("test_event"))
})
val result = panel.reportAsyncQuery()
if (result.apiResults === null) throw NullPointerException("apiResults should not be null")
result.apiResults?.forEach { assertEquals(it.errors, null) }
val bw = result.bw

val result2 = panel.reportAsyncQuery()
assert(result2.bw.previous_hashes.contains(bw._hash))
}
}

Expand Down

0 comments on commit f218152

Please sign in to comment.