|
| 1 | +package org.lfdecentralizedtrust.splice.integration.tests |
| 2 | + |
| 3 | +import org.lfdecentralizedtrust.splice.config.ConfigTransforms |
| 4 | +import org.lfdecentralizedtrust.splice.integration.EnvironmentDefinition |
| 5 | +import org.lfdecentralizedtrust.splice.integration.tests.SpliceTests.IntegrationTestWithSharedEnvironment |
| 6 | +import org.lfdecentralizedtrust.splice.sv.automation.singlesv.ReceiveSvRewardCouponTrigger |
| 7 | +import org.lfdecentralizedtrust.splice.sv.config.BeneficiaryConfig |
| 8 | +import org.lfdecentralizedtrust.splice.util.{TriggerTestUtil, WalletTestUtil} |
| 9 | +import com.digitalasset.canton.config.RequireTypes.NonNegativeLong |
| 10 | +import com.digitalasset.canton.logging.SuppressionRule |
| 11 | +import com.digitalasset.canton.topology.PartyId |
| 12 | +import monocle.macros.syntax.lens.* |
| 13 | +import org.lfdecentralizedtrust.splice.config.ConfigTransforms.{ |
| 14 | + ConfigurableApp, |
| 15 | + updateAutomationConfig, |
| 16 | +} |
| 17 | +import org.slf4j.event.Level |
| 18 | + |
| 19 | +import scala.math.Ordering.Implicits.* |
| 20 | + |
| 21 | +class SvTimeBasedRewardCouponMissingPartyIntegrationTest |
| 22 | + extends IntegrationTestWithSharedEnvironment |
| 23 | + with SvTimeBasedIntegrationTestUtil |
| 24 | + with WalletTestUtil |
| 25 | + with WalletTxLogTestUtil |
| 26 | + with TriggerTestUtil { |
| 27 | + |
| 28 | + override protected def runUpdateHistorySanityCheck: Boolean = false |
| 29 | + override protected def runTokenStandardCliSanityCheck: Boolean = false |
| 30 | + val badPartyHint = "badpartyhint" |
| 31 | + |
| 32 | + override def environmentDefinition: EnvironmentDefinition = |
| 33 | + EnvironmentDefinition |
| 34 | + .simpleTopology1SvWithSimTime(this.getClass.getSimpleName) |
| 35 | + .addConfigTransforms((_, config) => |
| 36 | + updateAutomationConfig(ConfigurableApp.Sv)( |
| 37 | + _.withPausedTrigger[ReceiveSvRewardCouponTrigger] |
| 38 | + )(config) |
| 39 | + ) |
| 40 | + .addConfigTransform((_, config) => { |
| 41 | + config |
| 42 | + .focus(_.svApps) |
| 43 | + .modify(_.map { case (name, svConfig) => |
| 44 | + // Setting the beneficiary party ID to a value that will never be in the party to participant mapping |
| 45 | + val newConfig = if (name.unwrap == "sv1") { |
| 46 | + val aliceParticipant = |
| 47 | + ConfigTransforms |
| 48 | + .getParticipantIds(config.parameters.clock)("alice_validator_user") |
| 49 | + |
| 50 | + val alicePartyId = PartyId |
| 51 | + .tryFromProtoPrimitive( |
| 52 | + s"$badPartyHint::${aliceParticipant.split("::").last}" |
| 53 | + ) |
| 54 | + svConfig |
| 55 | + .copy(extraBeneficiaries = |
| 56 | + Seq(BeneficiaryConfig(alicePartyId, NonNegativeLong.tryCreate(3333L))) |
| 57 | + ) |
| 58 | + } else svConfig |
| 59 | + |
| 60 | + name -> newConfig |
| 61 | + }) |
| 62 | + }) |
| 63 | + |
| 64 | + "SVs" should { |
| 65 | + "filter out beneficiaries that were not found in party to participant mapping" in { |
| 66 | + implicit env => |
| 67 | + val sv1RewardCouponTrigger = sv1Backend.dsoAutomation.trigger[ReceiveSvRewardCouponTrigger] |
| 68 | + loggerFactory.assertEventuallyLogsSeq(SuppressionRule.LevelAndAbove(Level.WARN))( |
| 69 | + within = { |
| 70 | + |
| 71 | + eventually() { |
| 72 | + clue("No SvRewardCoupon should be issued") { |
| 73 | + advanceRoundsByOneTick |
| 74 | + sv1RewardCouponTrigger.runOnce().futureValue |
| 75 | + eventually() { |
| 76 | + val openRounds = sv1ScanBackend |
| 77 | + .getOpenAndIssuingMiningRounds() |
| 78 | + ._1 |
| 79 | + .filter(_.payload.opensAt <= env.environment.clock.now.toInstant) |
| 80 | + openRounds should not be empty |
| 81 | + } |
| 82 | + } |
| 83 | + } |
| 84 | + }, |
| 85 | + lines => { |
| 86 | + forAtLeast(1, lines) { entry => |
| 87 | + entry.message should include("Beneficiaries did not vet the latest packages") |
| 88 | + } |
| 89 | + forAtLeast(1, lines) { entry => |
| 90 | + entry.message should include( |
| 91 | + "Party to participant mapping not found for synchronizer" |
| 92 | + ) |
| 93 | + entry.message should include(badPartyHint) |
| 94 | + } |
| 95 | + }, |
| 96 | + ) |
| 97 | + } |
| 98 | + } |
| 99 | +} |
0 commit comments