11package org .lfdecentralizedtrust .splice .integration .tests
22
3+ import com .daml .ledger .javaapi .data .Identifier
34import com .digitalasset .canton .config .NonNegativeFiniteDuration
5+ import com .digitalasset .canton .data .CantonTimestamp
46import org .lfdecentralizedtrust .splice .codegen .java .splice .amulet .UnclaimedDevelopmentFundCoupon
57import org .lfdecentralizedtrust .splice .config .ConfigTransforms
68import org .lfdecentralizedtrust .splice .config .ConfigTransforms .{
@@ -11,6 +13,8 @@ import org.lfdecentralizedtrust.splice.integration.EnvironmentDefinition
1113import org .lfdecentralizedtrust .splice .sv .automation .delegatebased .AdvanceOpenMiningRoundTrigger
1214import org .lfdecentralizedtrust .splice .util .{TriggerTestUtil , WalletTestUtil }
1315
16+ import java .time .Duration
17+
1418@ org.lfdecentralizedtrust.splice.util.scalatesttags.SpliceDsoGovernance_0_1_21
1519class DevelopmentFundCouponIntegrationTest
1620 extends SvIntegrationTestBase
@@ -19,6 +23,12 @@ class DevelopmentFundCouponIntegrationTest
1923
2024 private val threshold = 3
2125
26+ override protected lazy val sanityChecksIgnoredRootCreates : Seq [Identifier ] = Seq (
27+ UnclaimedDevelopmentFundCoupon .TEMPLATE_ID_WITH_PACKAGE_ID
28+ )
29+
30+ override protected def runTokenStandardCliSanityCheck : Boolean = false
31+
2232 override def environmentDefinition
2333 : org.lfdecentralizedtrust.splice.integration.EnvironmentDefinition =
2434 EnvironmentDefinition
@@ -96,4 +106,61 @@ class DevelopmentFundCouponIntegrationTest
96106 },
97107 )
98108 }
109+
110+ " DevelopmentFundCoupons management flow" in { implicit env =>
111+ val sv1UserId = sv1WalletClient.config.ledgerApiUser
112+ val unclaimedDevelopmentFundCouponsToMint = Seq (10.0 , 10.0 , 30.0 , 30.0 )
113+ val unclaimedDevelopmentFundCouponTotal = unclaimedDevelopmentFundCouponsToMint.sum
114+ val aliceParty = onboardWalletUser(aliceWalletClient, aliceValidatorBackend)
115+ val bobParty = onboardWalletUser(bobWalletClient, bobValidatorBackend)
116+ val fundManager = aliceParty
117+ val beneficiary = bobParty
118+ val developmentFundCouponAmount = 40.0
119+ val expiresAt = CantonTimestamp .now().plus(Duration .ofDays(1 ))
120+ val reason = " Bob has contributed to the Daml repo"
121+
122+ val unclaimedDevelopmentFundCouponContractIds =
123+ clue(" Mint some unclaimed development fund coupons" ) {
124+ unclaimedDevelopmentFundCouponsToMint.foreach { amount =>
125+ createUnclaimedDevelopmentFundCoupon(
126+ sv1ValidatorBackend.participantClientWithAdminToken,
127+ sv1UserId,
128+ amount,
129+ )
130+ }
131+ val unclaimedDevelopmentFundCouponContracts =
132+ sv1Backend.participantClient.ledger_api_extensions.acs
133+ .filterJava(UnclaimedDevelopmentFundCoupon .COMPANION )(dsoParty)
134+ unclaimedDevelopmentFundCouponContracts
135+ .map(co => BigDecimal (co.data.amount))
136+ .sum shouldBe unclaimedDevelopmentFundCouponTotal
137+ unclaimedDevelopmentFundCouponContracts.map(_.id)
138+ }
139+
140+ actAndCheck(
141+ " allocate one development fund coupon" , {
142+ aliceWalletClient.allocateDevelopmentFundCoupon(
143+ unclaimedDevelopmentFundCouponContractIds,
144+ beneficiary,
145+ developmentFundCouponAmount,
146+ expiresAt,
147+ reason,
148+ fundManager,
149+ )
150+ },
151+ )(
152+ " One development fund coupon is allocated and the total of unclaimed development fund coupons has decreased" ,
153+ _ => {
154+ val activeDevelopmentFundCoupons =
155+ aliceWalletClient.listActiveDevelopmentFundCoupons().map(_.payload)
156+ activeDevelopmentFundCoupons.length shouldBe 1
157+ val bobDevelopmentFundCoupon = activeDevelopmentFundCoupons.head
158+ bobDevelopmentFundCoupon.amount shouldBe developmentFundCouponAmount
159+ sv1Backend.participantClient.ledger_api_extensions.acs
160+ .filterJava(UnclaimedDevelopmentFundCoupon .COMPANION )(dsoParty)
161+ .map(co => BigDecimal (co.data.amount))
162+ .sum shouldBe (unclaimedDevelopmentFundCouponTotal - developmentFundCouponAmount)
163+ },
164+ )
165+ }
99166}
0 commit comments