Skip to content

Commit fccdeca

Browse files
committed
.
Signed-off-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
1 parent 94e4910 commit fccdeca

File tree

2 files changed

+18
-73
lines changed

2 files changed

+18
-73
lines changed

apps/app/src/test/scala/org/lfdecentralizedtrust/splice/integration/tests/WalletRewardsTimeBasedIntegrationTest.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import org.lfdecentralizedtrust.splice.integration.EnvironmentDefinition
44
import org.lfdecentralizedtrust.splice.integration.tests.SpliceTests.IntegrationTest
55
import org.lfdecentralizedtrust.splice.util.{SpliceUtil, TimeTestUtil, WalletTestUtil}
66
import org.lfdecentralizedtrust.splice.validator.automation.ReceiveFaucetCouponTrigger
7+
import org.lfdecentralizedtrust.splice.codegen.java.splice.amulet.{AppRewardCoupon, ValidatorRewardCoupon}
78

89
import scala.concurrent.duration.DurationInt
910

@@ -21,22 +22,39 @@ class WalletRewardsTimeBasedIntegrationTest
2122
// TODO (#965) remove and fix test failures
2223
override def walletAmuletPrice = SpliceUtil.damlDecimal(1.0)
2324

25+
override protected lazy val sanityChecksIgnoredRootCreates = Seq(
26+
AppRewardCoupon.TEMPLATE_ID_WITH_PACKAGE_ID,
27+
ValidatorRewardCoupon.TEMPLATE_ID_WITH_PACKAGE_ID
28+
)
29+
2430
"A wallet" should {
2531

2632
"list and automatically collect app & validator rewards" in { implicit env =>
2733
val (alice, bob) = onboardAliceAndBob()
2834
waitForWalletUser(aliceValidatorWalletClient)
2935
waitForWalletUser(bobValidatorWalletClient)
36+
val aliceValidatorParty = aliceValidatorBackend.getValidatorPartyId()
37+
val bobValidatorParty = bobValidatorBackend.getValidatorPartyId()
3038

3139
// Tap amulet and do a transfer from alice to bob
3240
aliceWalletClient.tap(walletAmuletToUsd(50))
3341

3442
p2pTransfer(aliceWalletClient, bobWalletClient, bob, 40.0)
43+
// Rewards roughly match what we had before we set fees to zero
44+
createRewards(
45+
appRewards = Seq((aliceValidatorParty, 0.43, false)),
46+
validatorRewards = Seq((alice, 0.43))
47+
)
3548

3649
// Retrieve transferred amulet in bob's wallet and transfer part of it back to alice;
3750
// bob's validator will receive some app rewards
3851
eventually()(bobWalletClient.list().amulets should have size 1)
3952
p2pTransfer(bobWalletClient, aliceWalletClient, alice, 30.0)
53+
// Rewards roughly match what we had before we set fees to zero
54+
createRewards(
55+
appRewards = Seq((bobValidatorParty, 0.33, false)),
56+
validatorRewards = Seq((bob, 0.33))
57+
)
4058

4159
val openRounds = eventually() {
4260
import math.Ordering.Implicits.*

apps/app/src/test/scala/org/lfdecentralizedtrust/splice/integration/tests/WalletTimeBasedIntegrationTest.scala

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.lfdecentralizedtrust.splice.integration.tests
22

3-
import org.lfdecentralizedtrust.splice.codegen.java.splice.amulet as amuletCodegen
43
import org.lfdecentralizedtrust.splice.config.ConfigTransforms.{
54
ConfigurableApp,
65
updateAutomationConfig,
@@ -209,78 +208,6 @@ class WalletTimeBasedIntegrationTest
209208
}
210209
}
211210
}
212-
213-
"generate rewards for subscriptions" in { implicit env =>
214-
onboardWalletUser(aliceWalletClient, aliceValidatorBackend)
215-
216-
clue(
217-
"Advance seven rounds to ensure that rewards from previous test cases were claimed or expired"
218-
) {
219-
Range(1, 8).foreach(_ => advanceRoundsToNextRoundOpening)
220-
}
221-
222-
val respond = clue("Alice requests an ANS entry") {
223-
aliceAnsExternalClient.createAnsEntry(
224-
testEntryName,
225-
testEntryUrl,
226-
testEntryDescription,
227-
)
228-
}
229-
bracket(
230-
clue("Alice obtains some amulets and accepts the subscription") {
231-
aliceWalletClient.tap(50.0)
232-
aliceWalletClient.acceptSubscriptionRequest(respond.subscriptionRequestCid)
233-
},
234-
cancelAllSubscriptions(aliceWalletClient),
235-
) {
236-
clue("Getting Alice's new entry") {
237-
eventuallySucceeds() {
238-
sv1ScanBackend.lookupEntryByName(testEntryName)
239-
}
240-
}
241-
242-
clue("Wait for reward coupons to be issued") {
243-
eventually()({
244-
aliceValidatorWalletClient.listAppRewardCoupons() should have length 1
245-
aliceValidatorWalletClient.listValidatorRewardCoupons() should have length 2
246-
sv1Backend.participantClient.ledger_api_extensions.acs
247-
.filterJava(amuletCodegen.AppRewardCoupon.COMPANION)(
248-
dsoParty,
249-
_.data.provider == dsoParty.toProtoPrimitive,
250-
) should have length 1
251-
})
252-
}
253-
254-
actAndCheck(
255-
"Advance six rounds - all rewards should be claimed or expired",
256-
Range(1, 7).foreach(_ => advanceRoundsToNextRoundOpening),
257-
)(
258-
"",
259-
_ => {
260-
aliceValidatorWalletClient.listAppRewardCoupons() should be(empty)
261-
aliceValidatorWalletClient.listValidatorRewardCoupons() should be(empty)
262-
sv1Backend.participantClient.ledger_api_extensions.acs
263-
.filterJava(amuletCodegen.AppRewardCoupon.COMPANION)(
264-
dsoParty,
265-
_.data.provider == dsoParty.toProtoPrimitive,
266-
) should be(empty)
267-
},
268-
)
269-
270-
actAndCheck(
271-
"Advance time until ANS entry is up for renewal", {
272-
// We time the advances so that automation doesn't trigger before payments can be made.
273-
// TODO (#996): consider replacing with stopping and starting triggers
274-
advanceTimeAndWaitForRoundAutomation(Duration.ofDays(89).minus(Duration.ofMinutes(17)))
275-
advanceTimeToRoundOpen
276-
},
277-
)(
278-
"Wait for another coupon to be generated upon renewal",
279-
_ => aliceValidatorWalletClient.listAppRewardCoupons() should have length 1,
280-
)
281-
}
282-
}
283-
284211
}
285212

286213
}

0 commit comments

Comments
 (0)