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 @@ -10,7 +10,6 @@ import org.lfdecentralizedtrust.splice.codegen.java.splice.api.token.allocationv
TransferLeg as TransferLegV2,
Reference as SettlementReference,
}
import org.lfdecentralizedtrust.splice.codegen.java.splice.api.token.holdingv2.InstrumentId
import org.lfdecentralizedtrust.splice.codegen.java.splice.api.token.metadatav1.Metadata
import org.lfdecentralizedtrust.splice.integration.EnvironmentDefinition
import org.lfdecentralizedtrust.splice.integration.tests.SpliceTests.SpliceTestConsoleEnvironment
Expand All @@ -21,7 +20,6 @@ import org.lfdecentralizedtrust.splice.util.{
WalletTestUtil,
}

import java.time.format.DateTimeFormatter
import java.time.temporal.ChronoUnit
import java.time.{LocalDateTime, ZoneOffset}
import java.util.Optional
Expand Down Expand Up @@ -61,43 +59,43 @@ class AllocationsFrontendIntegrationTest
webDriver: WebDriverType,
) = {
val validatorPartyId = aliceValidatorBackend.getValidatorPartyId()
val receiver = validatorPartyId
val now = LocalDateTime
.now()
.truncatedTo(ChronoUnit.MICROS)
.toInstant(ZoneOffset.UTC)
val requestedAt = now.minusSeconds(1800)
val allocateBefore = now.plusSeconds(3600)
val settleBefore = now.plusSeconds(3600 * 2)
val wantedTransferLegs = Seq(
new TransferLegV2(
"oneway",
basicAccount(sender),
basicAccount(validatorPartyId),
BigDecimal(12).bigDecimal.setScale(10),
amuletInstrumentIdName,
new Metadata(java.util.Map.of("k3", "v3")),
),
new TransferLegV2(
"waybackbutless",
basicAccount(validatorPartyId),
basicAccount(sender),
BigDecimal(6).bigDecimal.setScale(10),
amuletInstrumentIdName,
new Metadata(java.util.Map.of("k3", "v3")),
),
)

val wantedAllocation = new AllocationSpecification(
new SettlementInfo(
java.util.List.of(validatorPartyId.toProtoPrimitive),
new SettlementReference("some_reference", Optional.empty),
requestedAt,
allocateBefore,
java.util.Optional.of(settleBefore),
new Metadata(java.util.Map.of("k1", "v1", "k2", "v2")),
),
java.util.List.of(
new TransferLegV2(
"oneway",
basicAccount(sender),
basicAccount(receiver),
BigDecimal(12).bigDecimal.setScale(10),
new InstrumentId(dsoParty.toProtoPrimitive, "Amulet"),
new Metadata(java.util.Map.of("k3", "v3")),
),
new TransferLegV2(
"waybackbutless",
basicAccount(receiver),
basicAccount(sender),
BigDecimal(6).bigDecimal.setScale(10),
new InstrumentId(dsoParty.toProtoPrimitive, "Amulet"),
new Metadata(java.util.Map.of("k3", "v3")),
),
),
dsoParty.toProtoPrimitive,
basicAccount(sender),
wantedTransferLegs.map(transferLegSideForAuthorizer(sender, _)).asJava,
Optional.empty[java.util.Map[String, java.math.BigDecimal]](),
false,
new Metadata(java.util.Map.of("k1", "v1", "k2", "v2")),
)

browseToAllocationsPage()
Expand All @@ -113,10 +111,10 @@ class AllocationsFrontendIntegrationTest
validatorPartyId.toProtoPrimitive,
)
// Add n (-1 because one is already there) forms for transfer legs
wantedAllocation.transferLegs.asScala.drop(1).foreach { _ =>
wantedTransferLegs.drop(1).foreach { _ =>
eventuallyClickOn(id("add-transfer-leg"))
}
wantedAllocation.transferLegs.asScala.zipWithIndex.foreach { case (transferLeg, index) =>
wantedTransferLegs.zipWithIndex.foreach { case (transferLeg, index) =>
textField(s"create-allocation-transfer-leg-id-$index").underlying
.sendKeys(transferLeg.transferLegId)
eventuallyClickOn(id(s"create-allocation-transfer-leg-sender-$index"))
Expand All @@ -138,21 +136,6 @@ class AllocationsFrontendIntegrationTest
)
}

val allocationTimestampFormat =
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'")
textField("create-allocation-settlement-requested-at").underlying
.sendKeys(
allocationTimestampFormat.format(
wantedAllocation.settlement.requestedAt.atOffset(ZoneOffset.UTC)
)
)
textField("create-allocation-settlement-settle-at").underlying
.sendKeys(
allocationTimestampFormat.format(
wantedAllocation.settlement.settleAt.atOffset(ZoneOffset.UTC)
)
)

eventuallyClickOn(id("create-allocation-submit-button"))
},
)(
Expand All @@ -169,7 +152,7 @@ class AllocationsFrontendIntegrationTest

checkTransferLegsV2(
allocation,
wantedAllocation.transferLegs.asScala.toSeq,
wantedTransferLegs,
)
},
)
Expand Down Expand Up @@ -221,7 +204,7 @@ class AllocationsFrontendIntegrationTest
Seq(venueParty.toProtoPrimitive),
)

checkTransferLegsV2(allocationRequest, otcTrade.data.transferLegs.asScala.toSeq)
checkTransferLegsV2(allocationRequest, otcTrade.data.tradeLegs.asScala.map(_.leg).toSeq)

allocationRequest
}
Expand Down Expand Up @@ -250,7 +233,7 @@ class AllocationsFrontendIntegrationTest
Seq(venueParty.toProtoPrimitive),
)

checkTransferLegsV2(allocation, otcTrade.data.transferLegs.asScala.toSeq)
checkTransferLegsV2(allocation, otcTrade.data.tradeLegs.asScala.map(_.leg).toSeq)

allocation
},
Expand Down Expand Up @@ -480,7 +463,7 @@ class AllocationsFrontendIntegrationTest
checkTransferLeg(
row = row,
legId = transferLeg.transferLegId,
instrumentId = transferLeg.instrumentId.id,
instrumentId = transferLeg.instrumentId,
amount = transferLeg.amount,
sender = transferLeg.sender.owner,
receiver = transferLeg.receiver.owner,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.digitalasset.canton.topology.PartyId
import org.lfdecentralizedtrust.splice.codegen.java.splice.api.token.allocationv1
import org.lfdecentralizedtrust.splice.codegen.java.splice.api.token.allocationv2
import org.lfdecentralizedtrust.splice.codegen.java.splice.api.token.holdingv1
import org.lfdecentralizedtrust.splice.codegen.java.splice.api.token.holdingv2
import org.lfdecentralizedtrust.splice.codegen.java.splice.api.token.metadatav1.Metadata
import org.lfdecentralizedtrust.splice.http.v0.definitions.AllocationInstructionResultOutput.members
import org.lfdecentralizedtrust.splice.integration.EnvironmentDefinition
Expand All @@ -31,8 +30,6 @@ class AmuletAllocationsIntegrationTest
.simpleTopology1Sv(this.getClass.getSimpleName)
}

private val someMetadata = new Metadata(java.util.Map.of("k1", "v1", "k2", "v2"))

private def createAllocationV1(sender: PartyId)(implicit
ev: SpliceTestConsoleEnvironment
) = {
Expand All @@ -48,15 +45,15 @@ class AmuletAllocationsIntegrationTest
requestedAt.toInstant,
allocateBefore.toInstant,
settleBefore.toInstant,
someMetadata,
new Metadata(java.util.Map.of("k1", "v1", "k2", "v2")),
),
"some_transfer_leg_id",
new allocationv1.TransferLeg(
sender.toProtoPrimitive,
receiver.toProtoPrimitive,
BigDecimal(12).bigDecimal.setScale(10),
new holdingv1.InstrumentId(dsoParty.toProtoPrimitive, "Amulet"),
someMetadata,
new Metadata(java.util.Map.of("k3", "v3")),
),
)

Expand All @@ -68,34 +65,37 @@ class AmuletAllocationsIntegrationTest
ev: SpliceTestConsoleEnvironment
) = {
val validatorPartyId = aliceValidatorBackend.getValidatorPartyId()
val receiver = validatorPartyId
val now = CantonTimestamp.now()
val allocateBefore = now.plusSeconds(3600)
val settlementDeadline = now.plusSeconds(3600 * 2)

def wantedAllocationV2(requestedAt: CantonTimestamp) = new allocationv2.AllocationSpecification(
def wantedAllocationV2() = new allocationv2.AllocationSpecification(
new allocationv2.SettlementInfo(
java.util.List.of(validatorPartyId.toProtoPrimitive),
new allocationv2.Reference("some_reference", Optional.empty),
requestedAt.toInstant,
allocateBefore.toInstant,
java.util.Optional.of(settlementDeadline.toInstant),
someMetadata,
new Metadata(java.util.Map.of("k1", "v1", "k2", "v2")),
),
dsoParty.toProtoPrimitive,
basicAccount(sender),
java.util.List.of(
new allocationv2.TransferLeg(
"some_transfer_leg",
basicAccount(sender),
basicAccount(receiver),
BigDecimal(12).bigDecimal.setScale(10),
new holdingv2.InstrumentId(dsoParty.toProtoPrimitive, "Amulet"),
someMetadata,
transferLegSideForAuthorizer(
sender,
new allocationv2.TransferLeg(
"some_transfer_leg",
basicAccount(sender),
basicAccount(validatorPartyId),
BigDecimal(12).bigDecimal.setScale(10),
amuletInstrumentIdName,
new Metadata(java.util.Map.of("k3", "v3")),
),
)
),
basicAccount(sender),
java.util.Optional.empty[java.util.Map[String, java.math.BigDecimal]](),
false,
new Metadata(java.util.Map.of("k4", "v4")),
)

val specification = wantedAllocationV2(now)
val specification = wantedAllocationV2()
specification -> aliceWalletClient.allocateAmulet(specification)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import org.lfdecentralizedtrust.splice.codegen.java.splice.api.token.allocationv
import org.lfdecentralizedtrust.splice.codegen.java.splice.api.token.{allocationv2, metadatav1}
import org.lfdecentralizedtrust.splice.codegen.java.splice.api.token.holdingv1.InstrumentId
import org.lfdecentralizedtrust.splice.codegen.java.splice.api.token.holdingv2.{
Account as AccountV2,
InstrumentId as InstrumentIdV2,
Account as AccountV2
}
import org.lfdecentralizedtrust.splice.codegen.java.splice.api.token.transferinstructionv1.TransferInstruction
import org.lfdecentralizedtrust.splice.http.v0.definitions.TransferInstructionResultOutput.members
Expand All @@ -28,6 +27,7 @@ class TokenStandardFetchFallbackIntegrationTest
with WalletTestUtil
with WalletTxLogTestUtil
with TriggerTestUtil
with TokenStandardV2TestUtil
with HasActorSystem
with HasExecutionContext {

Expand Down Expand Up @@ -149,22 +149,27 @@ class TokenStandardFetchFallbackIntegrationTest
new allocationv2.SettlementInfo(
java.util.List.of(dsoParty.toProtoPrimitive),
new allocationv2.Reference(referenceIdV2, Optional.empty),
Instant.now,
Instant.now.plusSeconds(3600L),
Optional.of(Instant.now.plusSeconds(2 * 3600L)),
new metadatav1.Metadata(java.util.Map.of()),
),
dsoParty.toProtoPrimitive,
new AccountV2(aliceParty.toProtoPrimitive, Optional.empty(), ""),
java.util.List.of(
new allocationv2.TransferLeg(
UUID.randomUUID().toString,
new AccountV2(aliceParty.toProtoPrimitive, Optional.empty(), ""),
new AccountV2(bobParty.toProtoPrimitive, Optional.empty(), ""),
BigDecimal(10).bigDecimal,
new InstrumentIdV2(dsoParty.toProtoPrimitive, "Amulet"),
new metadatav1.Metadata(java.util.Map.of()),
transferLegSideForAuthorizer(
aliceParty,
new allocationv2.TransferLeg(
UUID.randomUUID().toString,
new AccountV2(aliceParty.toProtoPrimitive, Optional.empty(), ""),
new AccountV2(bobParty.toProtoPrimitive, Optional.empty(), ""),
BigDecimal(10).bigDecimal,
amuletInstrumentIdName,
new metadatav1.Metadata(java.util.Map.of()),
),
)
),
new AccountV2(aliceParty.toProtoPrimitive, Optional.empty(), ""),
java.util.Optional.empty[java.util.Map[String, java.math.BigDecimal]](),
false,
new metadatav1.Metadata(java.util.Map.of()),
)
),
)(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class TokenStandardV2AllocationIntegrationTest
with WalletTxLogTestUtil
with TriggerTestUtil {

// TODO (#5499): restore once tx log parsing works for v2
override protected def runTokenStandardCliSanityCheck: Boolean = false

override def environmentDefinition: EnvironmentDefinition = {
EnvironmentDefinition
.simpleTopology1Sv(this.getClass.getSimpleName)
Expand Down Expand Up @@ -90,15 +93,21 @@ class TokenStandardV2AllocationIntegrationTest
"OTCTrade",
java.util.Optional.of(new metadatav1.AnyContract.ContractId(otcTrade.id.contractId)),
),
otcTrade.data.createdAt,
otcTrade.data.settleAt,
otcTrade.data.settlementDeadline,
emptyMetadata,
)
val settleBatch = new allocationv2.SettlementFactory_SettleBatch(
settlementInfo,
otcTrade.data.transferLegs,
allocations.asJava,
transferLegsFromTrade(otcTrade).asJava,
allocations
.map(cid =>
new allocationv2.FinalizedAllocation(
cid,
java.util.List.of(),
java.util.Optional.empty[java.util.Map[String, java.math.BigDecimal]](),
)
)
.asJava,
/*actors = */ java.util.List.of(venueParty.toProtoPrimitive),
emptyExtraArgs,
)
Expand Down Expand Up @@ -302,11 +311,16 @@ class TokenStandardV2AllocationIntegrationTest
allocationRequestView: allocationrequestv2.AllocationRequestView,
) = {
val allocateResponse = clue(s"${walletClient.name} accepts the Allocation Request") {
val requestedAllocation = allocationRequestView.allocations.asScala.loneElement
walletClient.allocateAmulet(
new allocationv2.AllocationSpecification(
allocationRequestView.settlement,
allocationRequestView.transferLegs,
requestedAllocation.admin,
allocationRequestView.authorizer,
requestedAllocation.transferLegSides,
requestedAllocation.nextIterationFunding,
requestedAllocation.committed,
requestedAllocation.meta,
)
)
}
Expand Down
Loading
Loading