-
Notifications
You must be signed in to change notification settings - Fork 59
Use GetContract as fallback for token standard context endpoints on Scan #3595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
bc76315
impl
OriolMunoz-da 403f5de
[ci] add test
OriolMunoz-da 07dde1c
[ci] prevent assertion conflict
OriolMunoz-da 38595f4
[ci] Fix tests via createdAt check
OriolMunoz-da 5c392cc
[ci] unnecessary log
OriolMunoz-da c50b13a
Merge branch 'main' into oriol/getcontract-fallback
OriolMunoz-da 5dbfc56
[ci] run
OriolMunoz-da c7690ac
[ci] review fixes
OriolMunoz-da 21f2d45
[ci] Option[X] doesn't imply that something is actually optional.....…
OriolMunoz-da File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 139 additions & 0 deletions
139
...centralizedtrust/splice/integration/tests/TokenStandardFetchFallbackIntegrationTest.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| package org.lfdecentralizedtrust.splice.integration.tests | ||
|
|
||
| import com.digitalasset.canton.data.CantonTimestamp | ||
| import com.digitalasset.canton.{HasActorSystem, HasExecutionContext} | ||
| import org.lfdecentralizedtrust.splice.codegen.java.splice.api.token.allocationv1.* | ||
| import org.lfdecentralizedtrust.splice.codegen.java.splice.api.token.holdingv1.InstrumentId | ||
| import org.lfdecentralizedtrust.splice.codegen.java.splice.api.token.transferinstructionv1.TransferInstruction | ||
| import org.lfdecentralizedtrust.splice.http.v0.definitions.TransferInstructionResultOutput.members | ||
| import org.lfdecentralizedtrust.splice.integration.EnvironmentDefinition | ||
| import org.lfdecentralizedtrust.splice.integration.tests.SpliceTests.IntegrationTestWithSharedEnvironment | ||
| import org.lfdecentralizedtrust.splice.util.{ | ||
| ChoiceContextWithDisclosures, | ||
| TriggerTestUtil, | ||
| WalletTestUtil, | ||
| } | ||
|
|
||
| import java.time.Instant | ||
| import java.util.{Optional, UUID} | ||
|
|
||
| class TokenStandardFetchFallbackIntegrationTest | ||
| extends IntegrationTestWithSharedEnvironment | ||
| with WalletTestUtil | ||
| with WalletTxLogTestUtil | ||
| with TriggerTestUtil | ||
| with HasActorSystem | ||
| with HasExecutionContext { | ||
|
|
||
| override def environmentDefinition: EnvironmentDefinition = { | ||
| EnvironmentDefinition.simpleTopology1Sv(this.getClass.getSimpleName) | ||
| } | ||
|
|
||
| "Token Standard" should { | ||
|
|
||
| "TransferInstruction context can be fetched from Scan even if it's not yet ingested into the store" in { | ||
| implicit env => | ||
| pauseScanIngestionWithin(sv1ScanBackend) { | ||
| onboardWalletUser(aliceWalletClient, aliceValidatorBackend) | ||
| val bobUserParty = onboardWalletUser(bobWalletClient, bobValidatorBackend) | ||
| aliceWalletClient.tap(100) | ||
|
|
||
| val response = actAndCheck( | ||
| "Alice creates transfer offer", | ||
| aliceWalletClient.createTokenStandardTransfer( | ||
| bobUserParty, | ||
| 10, | ||
| s"Transfer", | ||
| CantonTimestamp.now().plusSeconds(3600L), | ||
| UUID.randomUUID().toString, | ||
| ), | ||
| )( | ||
| "Alice and Bob see it", | ||
| _ => { | ||
| Seq(aliceWalletClient, bobWalletClient).foreach( | ||
| _.listTokenStandardTransfers() should have size 1 | ||
| ) | ||
| }, | ||
| )._1 | ||
|
|
||
| val cid = response.output match { | ||
| case members.TransferInstructionPending(value) => | ||
| new TransferInstruction.ContractId(value.transferInstructionCid) | ||
| case _ => fail("The transfers were expected to be pending.") | ||
| } | ||
|
|
||
| clue("SV-1's Scan sees it (still, even though ingestion is paused)") { | ||
| eventuallySucceeds() { | ||
| sv1ScanBackend.getTransferInstructionAcceptContext(cid) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| "AmuletAllocations context can be fetched from Scan even if it's not yet ingested into the store" in { | ||
| implicit env => | ||
| pauseScanIngestionWithin(sv1ScanBackend) { | ||
| val aliceParty = onboardWalletUser(aliceWalletClient, aliceValidatorBackend) | ||
| val bobParty = onboardWalletUser(bobWalletClient, bobValidatorBackend) | ||
| // // Allocate venue on separate participant node, we still go through the validator API instead of parties.enable | ||
| // // so we can use the standard wallet client APIs but give the party a more useful name than splitwell. | ||
| // val venuePartyHint = s"venue-party-${Random.nextInt()}" | ||
| // val venueParty = splitwellValidatorBackend.onboardUser( | ||
| // splitwellWalletClient.config.ledgerApiUser, | ||
| // Some( | ||
| // PartyId.tryFromProtoPrimitive( | ||
| // s"$venuePartyHint::${splitwellValidatorBackend.participantClient.id.namespace.toProtoPrimitive}" | ||
| // ) | ||
| // ), | ||
| // ) | ||
|
|
||
| aliceWalletClient.tap(100) | ||
| val referenceId = UUID.randomUUID().toString | ||
|
|
||
| val (_, allocation) = actAndCheck( | ||
| "Alice creates an Allocation", | ||
| aliceWalletClient.allocateAmulet( | ||
| new AllocationSpecification( | ||
| new SettlementInfo( | ||
| dsoParty.toProtoPrimitive, | ||
| new Reference(referenceId, Optional.empty), | ||
| Instant.now, | ||
| Instant.now.plusSeconds(3600L), | ||
| Instant.now.plusSeconds(2 * 3600L), | ||
| ChoiceContextWithDisclosures.emptyMetadata, | ||
| ), | ||
| UUID.randomUUID().toString, | ||
| new TransferLeg( | ||
| aliceParty.toProtoPrimitive, | ||
| bobParty.toProtoPrimitive, | ||
| BigDecimal(10).bigDecimal, | ||
| new InstrumentId(dsoParty.toProtoPrimitive, "Amulet"), | ||
| ChoiceContextWithDisclosures.emptyMetadata, | ||
| ), | ||
| ) | ||
| ), | ||
| )( | ||
| "Alice sees the Allocation", | ||
| _ => { | ||
| val allocation = | ||
| aliceWalletClient | ||
| .listAmuletAllocations() | ||
| .loneElement | ||
| allocation.payload.allocation.settlement.settlementRef.id should be(referenceId) | ||
| allocation | ||
| }, | ||
| ) | ||
|
|
||
| clue("SV-1's Scan sees it (still, even though ingestion is paused)") { | ||
| eventuallySucceeds() { | ||
| sv1ScanBackend.getAllocationTransferContext( | ||
| allocation.contractId.toInterface(Allocation.INTERFACE) | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test wants the fallback to be enabled and the validity to be long enough, whereas this assertion wants to see an archival immediately, which is in opposition to what this test wants, so I had to move this into a different file