Updated on 2026-08-14
This commit is contained in:
parent
f000c0c687
commit
f990f3c833
9 changed files with 152 additions and 141 deletions
|
|
@ -6,26 +6,22 @@ sealed interface YieldBoostStatus {
|
|||
|
||||
data object NotStarted : YieldBoostStatus
|
||||
|
||||
/** User entered boost, qualification period is still running. */
|
||||
data class Active(
|
||||
/**
|
||||
* User is enrolled in the boost (backend `active` or `completed`).
|
||||
*
|
||||
* The boost block on the active screen is driven entirely by [qualificationEndDate], which the backend
|
||||
* computes as the end of the bonus-accrual period:
|
||||
* - `null` — nothing is shown;
|
||||
* - in the future — days left until the date;
|
||||
* - reached / passed — awaiting payout.
|
||||
*/
|
||||
data class Enrolled(
|
||||
val tokenName: String,
|
||||
val networkId: String,
|
||||
val moduleAddress: String,
|
||||
val userAddress: String,
|
||||
val contractAddress: String,
|
||||
val activationDate: Instant,
|
||||
val qualificationEndDate: Instant,
|
||||
) : YieldBoostStatus
|
||||
|
||||
/** Boost has finished (backend `completed`). */
|
||||
data class Completed(
|
||||
val tokenName: String,
|
||||
val networkId: String,
|
||||
val moduleAddress: String,
|
||||
val userAddress: String,
|
||||
val contractAddress: String,
|
||||
val activationDate: Instant,
|
||||
val qualificationEndDate: Instant,
|
||||
val qualificationEndDate: Instant?,
|
||||
) : YieldBoostStatus
|
||||
|
||||
data class Disqualified(val reason: Reason) : YieldBoostStatus {
|
||||
|
|
|
|||
|
|
@ -91,21 +91,10 @@ class IsYieldBoostPromoEnabledForTokenUseCaseTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN status is Active WHEN invoke THEN returns Right(false)`() = runTest {
|
||||
fun `GIVEN status is Enrolled WHEN invoke THEN returns Right(false)`() = runTest {
|
||||
val token = createToken()
|
||||
coEvery { repository.getYieldBoostPromo(userWalletId, false) } returns activePromo()
|
||||
coEvery { repository.getYieldBoostStatus(userWalletId, false) } returns activeStatus()
|
||||
|
||||
val result = useCase(userWalletId, token)
|
||||
|
||||
assertThat(result.getOrNull()).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN status is Completed WHEN invoke THEN returns Right(false)`() = runTest {
|
||||
val token = createToken()
|
||||
coEvery { repository.getYieldBoostPromo(userWalletId, false) } returns activePromo()
|
||||
coEvery { repository.getYieldBoostStatus(userWalletId, false) } returns completedStatus()
|
||||
coEvery { repository.getYieldBoostStatus(userWalletId, false) } returns enrolledStatus()
|
||||
|
||||
val result = useCase(userWalletId, token)
|
||||
|
||||
|
|
@ -162,26 +151,15 @@ class IsYieldBoostPromoEnabledForTokenUseCaseTest {
|
|||
link = null,
|
||||
)
|
||||
|
||||
private fun activeStatus() = YieldBoostStatus.Active(
|
||||
private fun enrolledStatus() = YieldBoostStatus.Enrolled(
|
||||
tokenName = "USD Coin",
|
||||
networkId = networkRawId,
|
||||
moduleAddress = "0xmodule",
|
||||
userAddress = "0xuser",
|
||||
contractAddress = contractAddress,
|
||||
activationDate = Instant.parse("2026-05-01T00:00:00Z"),
|
||||
qualificationEndDate = Instant.parse("2026-06-01T00:00:00Z"),
|
||||
)
|
||||
|
||||
private fun completedStatus() = YieldBoostStatus.Completed(
|
||||
tokenName = "USD Coin",
|
||||
networkId = networkRawId,
|
||||
moduleAddress = "0xmodule",
|
||||
userAddress = "0xuser",
|
||||
contractAddress = contractAddress,
|
||||
activationDate = Instant.parse("2026-04-01T00:00:00Z"),
|
||||
qualificationEndDate = Instant.parse("2026-05-01T00:00:00Z"),
|
||||
)
|
||||
|
||||
private fun createToken(
|
||||
contractAddress: String = this.contractAddress,
|
||||
networkRawId: String = this.networkRawId,
|
||||
|
|
|
|||
|
|
@ -57,9 +57,9 @@ class ShouldShowYieldBoostMainBannerUseCaseTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN status is Active WHEN invoke THEN returns Right(false)`() = runTest {
|
||||
fun `GIVEN status is Enrolled WHEN invoke THEN returns Right(false)`() = runTest {
|
||||
coEvery { repository.getYieldBoostPromo(userWalletId, false) } returns activePromo()
|
||||
coEvery { repository.getYieldBoostStatus(userWalletId, false) } returns activeStatus()
|
||||
coEvery { repository.getYieldBoostStatus(userWalletId, false) } returns enrolledStatus()
|
||||
|
||||
val result = useCase(userWalletId)
|
||||
|
||||
|
|
@ -92,13 +92,12 @@ class ShouldShowYieldBoostMainBannerUseCaseTest {
|
|||
link = null,
|
||||
)
|
||||
|
||||
private fun activeStatus() = YieldBoostStatus.Active(
|
||||
private fun enrolledStatus() = YieldBoostStatus.Enrolled(
|
||||
tokenName = "USD Coin",
|
||||
networkId = networkRawId,
|
||||
moduleAddress = "0xmodule",
|
||||
userAddress = "0xuser",
|
||||
contractAddress = contractAddress,
|
||||
activationDate = Instant.parse("2026-05-01T00:00:00Z"),
|
||||
qualificationEndDate = Instant.parse("2026-06-01T00:00:00Z"),
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue