Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
Add back line and add more logs. (#5328)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuraiKek committed Jul 6, 2022
1 parent 73060cf commit 3e93feb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.flow.distinctUntilChangedBy
import kotlinx.coroutines.flow.drop
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import timber.log.Timber
Expand All @@ -34,6 +35,7 @@ class DccWalletInfoUpdateTrigger @Inject constructor(
init {
appScope.launch {
personCertificateProvider.personCertificates
.drop(1)
/*
Compare persons emissions certificates by using its hash. Changes in certificates set such as
registering, recycling, restoring, retrieving and, re-issuing a DCC will lead to a difference in the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class PersonCertificatesProvider @Inject constructor(
certs.isEmpty() // Any person should have at least one certificate to show up in the list
}.map { certs ->
var personIdentifier: CertificatePersonIdentifier = certs.identifier
// only added for testing to see if there would be any difference between wallets with new grouping.
val walletInfoWrongGrouping = personWalletsGroup[personIdentifier.groupingKey]?.dccWalletInfo
var dccWalletInfo: DccWalletInfo? = null
certs.forEach {
dccWalletInfo = personWalletsGroup[it.personIdentifier.groupingKey]?.dccWalletInfo
Expand All @@ -59,10 +61,11 @@ class PersonCertificatesProvider @Inject constructor(
val settings = personsSettings[personIdentifier]

Timber.tag(TAG).v(
"Person [code=%s, certsCount=%d, walletExist=%s, settings=%s]",
"Person [code=%s, certsCount=%d, walletExist=%s, walletInfoWrongGrouping=%s, settings=%s]",
personIdentifier.codeSHA256,
certs.size,
dccWalletInfo != null,
walletInfoWrongGrouping != null,
settings
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ class DccWalletInfoCalculationManagerTest : BaseTest() {

@Test
fun `calculation runs for each person after certificate change`() = runTest {
every { dccWalletInfo1.boosterNotification.identifier } returns "1"
every { dccWalletInfo2.boosterNotification.identifier } returns "2"
every { certificatesPersonA.dccWalletInfo } returns dccWalletInfo1
every { certificatesPersonB.dccWalletInfo } returns dccWalletInfo2

Expand All @@ -130,6 +132,8 @@ class DccWalletInfoCalculationManagerTest : BaseTest() {

@Test
fun `calculation runs for each person after config change`() = runTest {
every { dccWalletInfo1.boosterNotification.identifier } returns "1"
every { dccWalletInfo2.boosterNotification.identifier } returns "2"
every { certificatesPersonA.dccWalletInfo } returns dccWalletInfo1
every { certificatesPersonB.dccWalletInfo } returns dccWalletInfo2
instance.triggerAfterConfigChange("")
Expand Down Expand Up @@ -175,6 +179,8 @@ class DccWalletInfoCalculationManagerTest : BaseTest() {

@Test
fun `calculation runs for each person with invalid walletInfo`() = runTest {
every { dccWalletInfo1.boosterNotification.identifier } returns "1"
every { dccWalletInfo2.boosterNotification.identifier } returns "2"
every { certificatesPersonA.dccWalletInfo } returns dccWalletInfo1
every { certificatesPersonB.dccWalletInfo } returns dccWalletInfo2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ internal class DccWalletInfoUpdateTriggerTest : BaseTest() {

delay(1_100L)

coVerify(exactly = 1) {
coVerify(exactly = 0) {
dccWalletInfoCalculationManager.triggerNow(any())
dccWalletInfoCleaner.clean()
}
Expand Down

0 comments on commit 3e93feb

Please sign in to comment.