Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,6 @@ abstract class ScanAppReference(
httpCommand(HttpScanAppClient.LookupFeaturedAppRight(providerPartyId))
}

@Help.Summary("Get the total balance of Amulet in the network")
def getTotalAmuletBalance(asOfEndOfRound: Long): Option[BigDecimal] =
consoleEnvironment.run {
httpCommand(HttpScanAppClient.GetTotalAmuletBalance(asOfEndOfRound))
}

@Help.Summary("Get the Amulet config parameters for a given round")
def getAmuletConfigForRound(
round: Long
Expand Down Expand Up @@ -616,6 +610,21 @@ abstract class ScanAppReference(
consoleEnvironment.run {
httpCommand(HttpScanAppClient.LookupInstrument(instrumentId))
}
@Help.Summary(
"Get the total amulet balance (total supply), automatically forces a new acs snapshot to get an up2date response"
)
def getTotalAmuletBalance(
amuletName: String = getSpliceInstanceNames().amuletName
): BigDecimal = {
val _ = forceAcsSnapshotNow()
lookupInstrument(amuletName)
.flatMap(_.totalSupply.map(s => BigDecimal(s)))
.getOrElse(
throw new RuntimeException(
s"'$amuletName' instrument not found or total supply not defined"
)
)
}

def listInstruments() =
consoleEnvironment.run {
Expand Down
8 changes: 0 additions & 8 deletions apps/app/src/test/resources/include/scans/_scan.conf
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@
ttl = 1s
max-size = 1
}
total-amulet-balance {
ttl = 1s
max-size = 1
}
amulet-rules {
ttl = 1s
max-size = 1
Expand All @@ -64,10 +60,6 @@
ttl = 1s
max-size = 1
}
wallet-balance {
ttl = 1s
max-size = 1
}
amulet-config-for-round {
ttl = 1s
max-size = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ class UpdateHistorySanityCheckPlugin(
"DEBUG",
"--report-output",
csvTempFile.toString,
"--scan-balance-assertions",
"--stop-at-record-time",
snapshotRecordTime.toInstant.toString,
"--compare-acs-with-snapshot",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,16 +440,6 @@ class ScanFrontendTimeBasedIntegrationTest
"Wait for round to close in scan",
_ => sv1ScanBackend.getRoundOfLatestData()._1 shouldBe (firstRound + 1),
)
// We do not check the backend computation here, nor do we want to rely on the exact amulet balance created in other tests,
// so here we simply test that:
// The total balance increased as a result of our tap by the tap amount minus some amount to account for holding fees
// The frontend shows the balance from the backend
sv1ScanBackend
.getTotalAmuletBalance(firstRound + 1)
.valueOrFail("Amulet balance not yet computed") should
(be > (sv1ScanBackend
.getTotalAmuletBalance(firstRound)
.valueOrFail("Amulet balance not yet computed") + 99.0))

withFrontEnd("scan-ui") { implicit webDriver =>
actAndCheck(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,29 +689,6 @@ class ScanIntegrationTest extends IntegrationTest with WalletTestUtil with TimeT
}
}

"getWalletBalance should return 400 for invalid party ID" in { implicit env =>
implicit val sys = env.actorSystem
registerHttpConnectionPoolsCleanup(env)

val response = Http()
.singleRequest(
Get(
s"${sv1ScanBackend.httpClientConfig.url}/api/scan/v0/wallet-balance?party_id=None&asOfEndOfRound=0"
)
)
.futureValue

inside(response) {
case _ if response.status == StatusCodes.BadRequest =>
inside(Unmarshal(response.entity).to[String].value.value) {
case Success(successfullResponse) =>
successfullResponse should include(
"Invalid unique identifier `None` with missing namespace"
)
}
}
}

"getUpdateHistory should return 400 for invalid after timestamp" in { implicit env =>
import env.{actorSystem, executionContext}
registerHttpConnectionPoolsCleanup(env)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,89 +290,6 @@ class ScanTimeBasedIntegrationTest
)
}

"get total amulet balance" in { implicit env =>
val (_, _) = onboardAliceAndBob()

def roundNum() =
sv1ScanBackend.getLatestOpenMiningRound(getLedgerTime).contract.payload.round.number
roundNum() shouldBe (firstRound + 1)

val tapRound1Amount = BigDecimal(500.0)
clue(s"Tap in round ${firstRound + 1}") {
aliceWalletClient.tap(tapRound1Amount)
}

advanceRoundsToNextRoundOpening

roundNum() shouldBe (firstRound + 2)

val tapRound2Amount = BigDecimal(500.0)
clue(s"Tap in round ${firstRound + 2}") {
bobWalletClient.tap(tapRound2Amount)
}

actAndCheck(
s"advance to close round ${firstRound + 2}",
(0 to 4).foreach(_ => advanceRoundsToNextRoundOpening),
)(
s"check round ${firstRound + 2} is closed",
_ => {
sv1ScanBackend.automation.trigger[ScanAggregationTrigger].runOnce().futureValue
sv1ScanBackend.getRoundOfLatestData()._1 shouldBe firstRound + 2
sv1ScanBackend.getAggregatedRounds().value shouldBe ScanAggregator.RoundRange(
firstRound + 0,
firstRound + 2,
)
},
)

clue(
s"Get total balances for round ${firstRound + 0}, ${firstRound + 1} and ${firstRound + 2}"
) {
val total0 =
sv1ScanBackend
.getTotalAmuletBalance(firstRound + 0)
.getOrElse(BigDecimal(0))
val total1 =
sv1ScanBackend
.getTotalAmuletBalance(firstRound + 1)
.getOrElse(BigDecimal(0))
val total2 =
sv1ScanBackend
.getTotalAmuletBalance(firstRound + 2)
.valueOrFail("Amulet balance not yet computed")

val holdingFeeAfterOneRound = 1 * defaultHoldingFeeAmulet
val holdingFeeAfterTwoRounds = 2 * defaultHoldingFeeAmulet

total0 shouldBe 0.0
total1 shouldBe (walletUsdToAmulet(tapRound1Amount) - holdingFeeAfterOneRound)
total2 shouldBe (
walletUsdToAmulet(tapRound1Amount) - holdingFeeAfterTwoRounds +
walletUsdToAmulet(tapRound2Amount) - holdingFeeAfterOneRound
)
sv1ScanBackend.getAggregatedRounds().value shouldBe ScanAggregator.RoundRange(
firstRound + 0,
firstRound + 2,
)
sv1ScanBackend
.listRoundTotals(firstRound + 0, firstRound + 2)
.map(rt => (rt.closedRound, BigDecimal(rt.totalAmuletBalance))) shouldBe List(
firstRound + 0L -> total0,
firstRound + 1L -> total1,
firstRound + 2L -> total2,
)
assertThrowsAndLogsCommandFailures(
sv1ScanBackend.listRoundTotals(firstRound + 1, firstRound + 3),
_.errorMessage should include("is outside of the available rounds range"),
)
assertThrowsAndLogsCommandFailures(
sv1ScanBackend.listRoundPartyTotals(firstRound + 1, firstRound + 3),
_.errorMessage should include("is outside of the available rounds range"),
)
}
}

"Not get aggregates for incorrect ranges" in { implicit env =>
clue("Try to get round totals for negative rounds") {
val startRounds = List(-1L, 0L, -1L, 1L, -1L)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import org.lfdecentralizedtrust.splice.config.ConfigTransforms.{
import org.lfdecentralizedtrust.splice.integration.EnvironmentDefinition
import org.lfdecentralizedtrust.splice.integration.tests.SpliceTests.IntegrationTest
import org.lfdecentralizedtrust.splice.sv.automation.singlesv.LocalSequencerConnectionsTrigger
import org.lfdecentralizedtrust.splice.util.SpliceUtil.defaultIssuanceCurve
import org.lfdecentralizedtrust.splice.util.{SvTestUtil, TimeTestUtil, WalletTestUtil}

import scala.util.Try
Expand Down Expand Up @@ -139,39 +138,6 @@ class ScanWithGradualStartsTimeBasedIntegrationTest
}

val validatorLivenessActivityRecordAmount = 2.85
clue("Aggregated total amulet balance on both scan apps should match") {
val svRewardPerRound =
BigDecimal(
computeSvRewardInRound0(
defaultIssuanceCurve().initialValue,
defaultTickDuration,
dsoSize = 2,
)
)
forEvery(
Table(
("round", "total floor", "total ceiling"),
// Alice has 23 USD in Amulet, Bob has 3 USD, all minus holding fees
(2L, walletUsdToAmulet(25.9), walletUsdToAmulet(26.0)),
// sv2 did not start up it's validator app (thus wallet), so it won't claim any coupons.
(
3L,
// validator liveness activity record: SV1, Alice, Bob
walletUsdToAmulet(
26.0 + validatorLivenessActivityRecordAmount * 3 - smallAmount
) + svRewardPerRound,
walletUsdToAmulet(26.0 + validatorLivenessActivityRecordAmount * 3) + svRewardPerRound,
),
)
) { (round, floor, ceil) =>
val total1 =
sv1ScanBackend.getTotalAmuletBalance(round).valueOrFail("Amulet balance not yet computed")
val total2 =
sv2ScanBackend.getTotalAmuletBalance(round).valueOrFail("Amulet balance not yet computed")
total1 shouldBe total2
total1 should beWithin(floor, ceil)
}
}

clue("Aggregated rewards collected on both scan apps should match") {
forEvery(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,9 @@ class TokenStandardMetadataTimeBasedIntegrationTest
)(
"rounds are defined and include tapped amulet",
_ => {
val (roundNumber, _) = sv1ScanBackend.getRoundOfLatestData()
val totalBalance = sv1ScanBackend
.getTotalAmuletBalance(roundNumber)
.getOrElse(fail("total balance not yet defined"))
val totalBalance =
sv1ScanBackend
.getTotalAmuletBalance("Amulet")
totalBalance should be >= walletUsdToAmulet(99.0)
},
)
Expand Down
2 changes: 0 additions & 2 deletions apps/common/frontend/src/api/scan/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import useLookupFeaturedAppRight, {
} from './useLookupFeaturedAppRight';
import useOpenRounds from './useOpenRounds';
import useTopAppProviders from './useTopAppProviders';
import useTotalAmuletBalance from './useTotalAmuletBalance';
import useTotalRewards from './useTotalRewards';

export {
Expand All @@ -45,7 +44,6 @@ export {
useLookupFeaturedAppRightBuilder,
useActivity,
useTopAppProviders,
useTotalAmuletBalance,
useTotalRewards,
useListAnsEntries,
useListAnsEntriesFromResponse,
Expand Down
21 changes: 0 additions & 21 deletions apps/common/frontend/src/api/scan/useTotalAmuletBalance.tsx

This file was deleted.

4 changes: 0 additions & 4 deletions apps/scan/frontend/src/__tests__/mocks/handlers/scan-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
GetRewardsCollectedResponse,
GetRoundOfLatestDataResponse,
GetDsoPartyIdResponse,
GetTotalAmuletBalanceResponse,
ListActivityResponse,
LookupEntryByPartyResponse,
GetOpenAndIssuingMiningRoundsResponse,
Expand Down Expand Up @@ -409,9 +408,6 @@ export const buildScanMock = (baseScanUrl: string): RestHandler[] => {
rest.get(`${scanUrl}/v0/rewards-collected`, (_, res, ctx) => {
return res(ctx.json<GetRewardsCollectedResponse>({ amount: '0.0' }));
}),
rest.get(`${scanUrl}/v0/total-amulet-balance`, (_, res, ctx) => {
return res(ctx.json<GetTotalAmuletBalanceResponse>({ total_balance: '66605.2180742781' }));
}),
rest.post(`${scanUrl}/v0/amulet-rules`, (_, res, ctx) => {
return res(ctx.json<GetAmuletRulesResponse>(getAmuletRulesResponse(true)));
}),
Expand Down
Loading