Skip to content

Commit

Permalink
Update Splice from CCI (#52)
Browse files Browse the repository at this point in the history
Signed-off-by: DA Automation <[email protected]>
Co-authored-by: DA Automation <[email protected]>
  • Loading branch information
canton-network-da and DA Automation authored Oct 3, 2024
1 parent e470459 commit d6b6c16
Show file tree
Hide file tree
Showing 35 changed files with 2,308 additions and 506 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.daml.network.validator.automation.ReceiveFaucetCouponTrigger
import com.digitalasset.canton.config.NonNegativeFiniteDuration
import com.digitalasset.canton.integration.BaseEnvironmentDefinition
import io.circe.JsonObject
import org.openqa.selenium.By
import spray.json.DefaultJsonProtocol.StringJsonFormat

import java.time.{Duration, Instant}
Expand Down Expand Up @@ -580,14 +581,19 @@ class ScanFrontendTimeBasedIntegrationTest
closeVoteModalsIfOpen
reviewButton.underlying.click()

inside(find(id("pretty-json"))) { case Some(json) =>
// TODO(#14813): needs to be changed by using parseAmuletConfigValue() once the diff exists for the first change
try {
val newScheduleItem = webDriver.findElement(By.id("accordion-details"))
val json = newScheduleItem.findElement(By.tagName("pre")).getText
spray.json
.JsonParser(json.text)
.JsonParser(json)
.asJsObject("transferConfig")
.fields("transferConfig")
.asJsObject
.fields("maxNumInputs")
.convertTo[String] should be(newMaxNumInputs.toString)
} catch {
case _: NoSuchElementException => false
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,9 @@ import java.time.format.DateTimeFormatter
import java.time.{LocalDateTime, ZoneOffset}
import scala.concurrent.duration.DurationInt
import scala.jdk.CollectionConverters.*
import com.daml.ledger.javaapi.data.codegen.json.JsonLfReader
import com.daml.network.codegen.java.splice.amuletconfig.AmuletConfig
import com.daml.network.codegen.java.splice.dsorules.voterequestoutcome.VRO_AcceptedButActionFailed
import com.daml.network.codegen.java.splice.wallet.payment.Unit as DamlUnit
import com.daml.network.sv.automation.delegatebased.CloseVoteRequestTrigger

import java.util.Optional

class SvFrontendIntegrationTest
extends SvFrontendCommonIntegrationTest
with SvTestUtil
Expand Down Expand Up @@ -1008,25 +1003,15 @@ class SvFrontendIntegrationTest
tb.text
}

inside(find(id("pretty-json"))) { case Some(json) =>
val amuletConfig =
AmuletConfig
.jsonDecoder(DamlUnit.jsonDecoder())
.decode(new JsonLfReader(json.text))
BigDecimal(amuletConfig.transferConfig.createFee.fee) should be(
BigDecimal(requestNewTransferConfigFeeValue)
)
amuletConfig.issuanceCurve.initialValue.optValidatorFaucetCap should be(
Optional.empty
)
amuletConfig.issuanceCurve.futureValues
.get(0)
._2
.optValidatorFaucetCap
.map(BigDecimal(_)) should be(
Optional.of(BigDecimal(optValidatorFaucetValue))
)
}
BigDecimal(parseAmuletConfigValue("createFee")) should be(
BigDecimal(requestNewTransferConfigFeeValue)
)
BigDecimal(parseAmuletConfigValue("optValidatorFaucetCap", false)) should be(
BigDecimal("2.85")
)
BigDecimal(parseAmuletConfigValue("optValidatorFaucetCap")) should be(
BigDecimal(optValidatorFaucetValue)
)

requestId
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,16 @@ trait VotesFrontendTestUtil { self: FrontendIntegrationTestWithSharedEnvironment
scala.util.Try(click on "vote-result-modal-close-button")
}

def parseAmuletConfigValue(key: String, replacement: Boolean = true)(implicit
webDriver: WebDriverType
) = {
val headElement = webDriver.findElement(By.cssSelector(s"li[data-key='$key']"))
val value = if (replacement) {
headElement.findElement(By.cssSelector("div.jsondiffpatch-right-value"))
} else {
headElement.findElement(By.cssSelector("div.jsondiffpatch-left-value"))
}
value.findElement(By.tagName("pre")).getText.replace("\"", "")
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ abstract class RunbookSvPreflightIntegrationTestBase
}
}

"The SV rewards are claimed by the SV, with 33.33% going to validator1" in { implicit env =>
// TODO (#15162): re-enable after base version is 0.2.5
"The SV rewards are claimed by the SV, with 33.33% going to validator1" ignore { implicit env =>
val svClient = sv_client("sv")
val sv1ScanClient = scancl("sv1Scan")

Expand Down
30 changes: 30 additions & 0 deletions apps/common/frontend-test-utils/src/configDiffs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
import { screen } from '@testing-library/react';
import { expect } from 'vitest';

export function checkAmuletRulesExpectedConfigDiffsHTML(
mockHtmlContent: string,
expectedNumberOfInFlightDiffs: number = 0 // useful when we unfold the diffs
): void {
const htmlContents = screen.getAllByTestId('config-diffs-display');
if (expectedNumberOfInFlightDiffs > 0) {
expect(screen.getAllByTestId('folded-accordion')).toHaveLength(expectedNumberOfInFlightDiffs);
} else {
expect(screen.queryByTestId('folded-accordion')).toBeNull();
}
expect(htmlContents[0].innerHTML).toBe(mockHtmlContent);
}

export function checkDsoRulesExpectedConfigDiffsHTML(
mockHtmlContent: string,
expectedNumberOfInFlightDiffs: number = 0
): void {
const htmlContents = screen.getAllByTestId('config-diffs-display');
if (expectedNumberOfInFlightDiffs > 0) {
expect(screen.getAllByTestId('folded-accordion')).toHaveLength(expectedNumberOfInFlightDiffs);
} else {
expect(screen.queryByTestId('folded-accordion')).toBeNull();
}
expect(htmlContents[0].innerHTML).toBe(mockHtmlContent);
}
6 changes: 5 additions & 1 deletion apps/common/frontend-test-utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
export { validatorLicensesHandler } from './mocks/handlers/validator-licenses-handler';
export { dsoInfoHandler, dsoInfo } from './mocks/handlers/dso-info-handler';
export { dsoInfoHandler, dsoInfo, getAmuletConfig } from './mocks/handlers/dso-info-handler';
export {
checkAmuletRulesExpectedConfigDiffsHTML,
checkDsoRulesExpectedConfigDiffsHTML,
} from './configDiffs';
123 changes: 74 additions & 49 deletions apps/common/frontend-test-utils/src/mocks/handlers/dso-info-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ export const dsoInfo = {
_1: '2024-03-15T08:35:00Z',
_2: getAmuletConfig('4815162342'),
},
{
_1: '2524-03-19T08:35:00Z',
_2: getAmuletConfig('0.03'),
},
],
},
isDevNet: true,
Expand Down Expand Up @@ -170,6 +166,7 @@ export const dsoInfo = {
state: 'DS_Operational',
cometBftGenesisJson:
'TODO(#4900): share CometBFT genesis.json of founding SV node via DsoRules config.',
acsCommitmentReconciliationInterval: '1600',
},
],
],
Expand Down Expand Up @@ -401,112 +398,140 @@ export const dsoInfo = {
sv_node_states: [], // TODO(tech-debt): add better mock data
};

function getAmuletConfig(createFee: string) {
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export function getAmuletConfig(createFee: string) {
return {
packageConfig: {
amulet: '0.1.0',
walletPayments: '0.1.0',
dsoGovernance: '0.1.0',
validatorLifecycle: '0.1.0',
amuletNameService: '0.1.0',
wallet: '0.1.0',
amuletNameService: '0.1.5',
walletPayments: '0.1.5',
dsoGovernance: '0.1.8',
validatorLifecycle: '0.1.1',
amulet: '0.1.5',
wallet: '0.1.5',
},
tickDuration: { microseconds: '150000000' },
transferConfig: {
holdingFee: { rate: '0.0000048225' },
extraFeaturedAppRewardAmount: '1.0',
maxNumInputs: '100',
lockHolderFee: { fee: '0.005' },
createFee: { fee: createFee },
maxNumLockHolders: '50',
transferFee: {
initialRate: '0.01',
steps: [
{ _1: '100.0', _2: '0.001' },
{ _1: '1000.0', _2: '0.0001' },
{ _1: '1000000.0', _2: '0.00001' },
],
},
maxNumOutputs: '100',
tickDuration: {
microseconds: '600000000',
},
decentralizedSynchronizer: {
requiredSynchronizers: {
map: [
[
'global-synchronizer::1220d12352e0839d9aac0a1c0c05b0eaaeb44f0aa19958cca2db37ae22c7817949a7',
'global-domain::12200c1f141acd0b2e48defae40aa2eb3daae48e4c16b7e1fa5d9211d352cc150c81',
{},
],
],
},
activeSynchronizer:
'global-synchronizer::1220d12352e0839d9aac0a1c0c05b0eaaeb44f0aa19958cca2db37ae22c7817949a7',
'global-domain::12200c1f141acd0b2e48defae40aa2eb3daae48e4c16b7e1fa5d9211d352cc150c81',
fees: {
baseRateTrafficLimits: {
burstAmount: '2000000',
burstWindow: { microseconds: '600000000' },
burstAmount: '400000',
burstWindow: {
microseconds: '1200000000',
},
},
extraTrafficPrice: '1.0',
extraTrafficPrice: '16.67',
readVsWriteScalingFactor: '4',
minTopupAmount: '10000000',
minTopupAmount: '200000',
},
},
transferConfig: {
holdingFee: {
rate: '0.0000190259',
},
extraFeaturedAppRewardAmount: '1.0',
maxNumInputs: '100',
lockHolderFee: {
fee: '0.005',
},
createFee: {
fee: createFee,
},
maxNumLockHolders: '50',
transferFee: {
initialRate: '0.01',
steps: [
{
_1: '100.0',
_2: '0.001',
},
{
_1: '1000.0',
_2: '0.0001',
},
{
_1: '1000000.0',
_2: '0.00001',
},
],
},
maxNumOutputs: '100',
},
issuanceCurve: {
initialValue: {
validatorRewardPercentage: '0.5',
amuletToIssuePerYear: '40000000000.0',
validatorRewardPercentage: '0.05',
unfeaturedAppRewardCap: '0.6',
appRewardPercentage: '0.15',
featuredAppRewardCap: '100.0',
amuletToIssuePerYear: '40000000000.0',
validatorRewardCap: '0.2',
optValidatorFaucetCap: null,
optValidatorFaucetCap: '2.85',
},
futureValues: [
{
_1: { microseconds: '15768000000000' },
_1: {
microseconds: '15768000000000',
},
_2: {
validatorRewardPercentage: '0.12',
amuletToIssuePerYear: '20000000000.0',
unfeaturedAppRewardCap: '0.6',
appRewardPercentage: '0.4',
featuredAppRewardCap: '100.0',
amuletToIssuePerYear: '20000000000.0',
validatorRewardCap: '0.2',
optValidatorFaucetCap: null,
optValidatorFaucetCap: '2.85',
},
},
{
_1: { microseconds: '47304000000000' },
_1: {
microseconds: '47304000000000',
},
_2: {
validatorRewardPercentage: '0.18',
amuletToIssuePerYear: '10000000000.0',
unfeaturedAppRewardCap: '0.6',
appRewardPercentage: '0.62',
featuredAppRewardCap: '100.0',
amuletToIssuePerYear: '10000000000.0',
validatorRewardCap: '0.2',
optValidatorFaucetCap: null,
optValidatorFaucetCap: '2.85',
},
},
{
_1: { microseconds: '157680000000000' },
_1: {
microseconds: '157680000000000',
},
_2: {
validatorRewardPercentage: '0.21',
amuletToIssuePerYear: '5000000000.0',
unfeaturedAppRewardCap: '0.6',
appRewardPercentage: '0.69',
featuredAppRewardCap: '100.0',
amuletToIssuePerYear: '5000000000.0',
validatorRewardCap: '0.2',
optValidatorFaucetCap: null,
optValidatorFaucetCap: '2.85',
},
},
{
_1: { microseconds: '315360000000000' },
_1: {
microseconds: '315360000000000',
},
_2: {
validatorRewardPercentage: '0.2',
amuletToIssuePerYear: '2500000000.0',
unfeaturedAppRewardCap: '0.6',
appRewardPercentage: '0.75',
featuredAppRewardCap: '100.0',
amuletToIssuePerYear: '2500000000.0',
validatorRewardCap: '0.2',
optValidatorFaucetCap: null,
optValidatorFaucetCap: '2.85',
},
},
],
Expand Down
7 changes: 6 additions & 1 deletion apps/common/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@
"date-fns": "2.29.3",
"decimal.js-light": "2.5.1",
"splitwell-openapi": "0.0.1",
"dompurify": "3.1.6",
"grpc-web": "1.3.1",
"html-react-parser": "5.1.15",
"jose": "4.10.3",
"jsondiffpatch": "0.6.0",
"react-oidc-context": "2.2.2",
"react-router-dom": "6.8.1",
"sv-openapi": "0.0.1",
Expand All @@ -36,13 +39,15 @@
"@tanstack/react-query-devtools": "4.29.6",
"@trivago/prettier-plugin-sort-imports": "4.0.0",
"@types/node": "18.11.0",
"@types/dompurify": "3.0.5",
"@types/react": "18.0.28",
"@types/react-dom": "18.0.11",
"eslint": "8.34.0",
"eslint-config-react-app": "7.0.1",
"prettier": "2.8.4",
"typescript": "4.9.5",
"vitest": "^2.0.5"
"vitest": "^2.0.5",
"common-test-utils": "^0.1.0"
},
"exports": {
".": "./lib/index.js",
Expand Down
Loading

0 comments on commit d6b6c16

Please sign in to comment.