Skip to content

Commit

Permalink
Switch to AnyFlatSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
rautenrieth-da committed Jan 18, 2022
1 parent 5bbb27f commit a2b5143
Showing 1 changed file with 91 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ package com.daml.platform.store.backend
import com.daml.lf.data.Ref
import com.daml.lf.value.Value.ContractId
import org.scalatest.Inside
import org.scalatest.flatspec.AsyncFlatSpec
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

private[backend] trait StorageBackendTestsContracts
extends Matchers
with Inside
with StorageBackendSpec {
this: AsyncFlatSpec =>
this: AnyFlatSpec =>

behavior of "StorageBackend (contracts)"

Expand All @@ -30,24 +30,22 @@ private[backend] trait StorageBackendTestsContracts
dtoCompletion(offset(1)),
)

for {
_ <- executeSql(backend.parameter.initializeParameters(someIdentityParams))
_ <- executeSql(ingest(dtos, _))
_ <- executeSql(
updateLedgerEnd(offset(1), 1L)
)
rawContractO <- executeSql(
backend.contract.activeContractWithArgument(Set(signatory), contractId)
)
templateIdO <- executeSql(
backend.contract.activeContractWithoutArgument(Set(signatory), contractId)
)
} yield {
templateIdO shouldBe Some(someTemplateId.toString)
inside(rawContractO) { case Some(rawContract) =>
rawContract.templateId shouldBe someTemplateId.toString
rawContract.createArgumentCompression shouldBe None
}
executeSql(backend.parameter.initializeParameters(someIdentityParams))
executeSql(ingest(dtos, _))
executeSql(
updateLedgerEnd(offset(1), 1L)
)
val rawContractO = executeSql(
backend.contract.activeContractWithArgument(Set(signatory), contractId)
)
val templateIdO = executeSql(
backend.contract.activeContractWithoutArgument(Set(signatory), contractId)
)

templateIdO shouldBe Some(someTemplateId.toString)
inside(rawContractO) { case Some(rawContract) =>
rawContract.templateId shouldBe someTemplateId.toString
rawContract.createArgumentCompression shouldBe None
}
}

Expand All @@ -65,22 +63,20 @@ private[backend] trait StorageBackendTestsContracts
dtoCompletion(offset(2)),
)

for {
_ <- executeSql(backend.parameter.initializeParameters(someIdentityParams))
_ <- executeSql(ingest(dtos, _))
_ <- executeSql(
updateLedgerEnd(offset(2), 2L)
)
rawContractO <- executeSql(
backend.contract.activeContractWithArgument(Set(signatory), contractId)
)
templateIdO <- executeSql(
backend.contract.activeContractWithoutArgument(Set(signatory), contractId)
)
} yield {
templateIdO shouldBe None
rawContractO shouldBe None
}
executeSql(backend.parameter.initializeParameters(someIdentityParams))
executeSql(ingest(dtos, _))
executeSql(
updateLedgerEnd(offset(2), 2L)
)
val rawContractO = executeSql(
backend.contract.activeContractWithArgument(Set(signatory), contractId)
)
val templateIdO = executeSql(
backend.contract.activeContractWithoutArgument(Set(signatory), contractId)
)

templateIdO shouldBe None
rawContractO shouldBe None
}

it should "correctly find a divulged contract" in {
Expand All @@ -94,24 +90,22 @@ private[backend] trait StorageBackendTestsContracts
dtoCompletion(offset(1)),
)

for {
_ <- executeSql(backend.parameter.initializeParameters(someIdentityParams))
_ <- executeSql(ingest(dtos, _))
_ <- executeSql(
updateLedgerEnd(offset(1), 1L)
)
rawContractO <- executeSql(
backend.contract.activeContractWithArgument(Set(divulgee), contractId)
)
templateIdO <- executeSql(
backend.contract.activeContractWithoutArgument(Set(divulgee), contractId)
)
} yield {
templateIdO shouldBe Some(someTemplateId.toString)
inside(rawContractO) { case Some(rawContract) =>
rawContract.templateId shouldBe someTemplateId.toString
rawContract.createArgumentCompression shouldBe None
}
executeSql(backend.parameter.initializeParameters(someIdentityParams))
executeSql(ingest(dtos, _))
executeSql(
updateLedgerEnd(offset(1), 1L)
)
val rawContractO = executeSql(
backend.contract.activeContractWithArgument(Set(divulgee), contractId)
)
val templateIdO = executeSql(
backend.contract.activeContractWithoutArgument(Set(divulgee), contractId)
)

templateIdO shouldBe Some(someTemplateId.toString)
inside(rawContractO) { case Some(rawContract) =>
rawContract.templateId shouldBe someTemplateId.toString
rawContract.createArgumentCompression shouldBe None
}
}

Expand All @@ -132,24 +126,22 @@ private[backend] trait StorageBackendTestsContracts
dtoCompletion(offset(2)),
)

for {
_ <- executeSql(backend.parameter.initializeParameters(someIdentityParams))
_ <- executeSql(ingest(dtos, _))
_ <- executeSql(
updateLedgerEnd(offset(2), 2L)
)
rawContractO <- executeSql(
backend.contract.activeContractWithArgument(Set(divulgee), contractId)
)
templateIdO <- executeSql(
backend.contract.activeContractWithoutArgument(Set(divulgee), contractId)
)
} yield {
templateIdO shouldBe Some(someTemplateId.toString)
inside(rawContractO) { case Some(rawContract) =>
rawContract.templateId shouldBe someTemplateId.toString
rawContract.createArgumentCompression shouldBe None
}
executeSql(backend.parameter.initializeParameters(someIdentityParams))
executeSql(ingest(dtos, _))
executeSql(
updateLedgerEnd(offset(2), 2L)
)
val rawContractO = executeSql(
backend.contract.activeContractWithArgument(Set(divulgee), contractId)
)
val templateIdO = executeSql(
backend.contract.activeContractWithoutArgument(Set(divulgee), contractId)
)

templateIdO shouldBe Some(someTemplateId.toString)
inside(rawContractO) { case Some(rawContract) =>
rawContract.templateId shouldBe someTemplateId.toString
rawContract.createArgumentCompression shouldBe None
}
}

Expand All @@ -172,34 +164,33 @@ private[backend] trait StorageBackendTestsContracts
dtoCompletion(offset(3)),
)

for {
_ <- executeSql(backend.parameter.initializeParameters(someIdentityParams))
_ <- executeSql(ingest(dtos, _))
_ <- executeSql(
updateLedgerEnd(offset(3), 3L)
)
rawContractDivulgeeO <- executeSql(
backend.contract.activeContractWithArgument(Set(divulgee), contractId)
)
templateIdDivulgeeO <- executeSql(
backend.contract.activeContractWithoutArgument(Set(divulgee), contractId)
)
rawContractSignatoryO <- executeSql(
backend.contract.activeContractWithArgument(Set(signatory), contractId)
)
templateIdSignatoryO <- executeSql(
backend.contract.activeContractWithoutArgument(Set(signatory), contractId)
)
} yield {
// The divulgee still sees the contract
templateIdDivulgeeO shouldBe Some(someTemplateId.toString)
inside(rawContractDivulgeeO) { case Some(rawContract) =>
rawContract.templateId shouldBe someTemplateId.toString
rawContract.createArgumentCompression shouldBe None
}
// The signatory knows it's archived
templateIdSignatoryO shouldBe None
rawContractSignatoryO shouldBe None
executeSql(backend.parameter.initializeParameters(someIdentityParams))
executeSql(ingest(dtos, _))
executeSql(
updateLedgerEnd(offset(3), 3L)
)
val rawContractDivulgeeO = executeSql(
backend.contract.activeContractWithArgument(Set(divulgee), contractId)
)
val templateIdDivulgeeO = executeSql(
backend.contract.activeContractWithoutArgument(Set(divulgee), contractId)
)
val rawContractSignatoryO = executeSql(
backend.contract.activeContractWithArgument(Set(signatory), contractId)
)
val templateIdSignatoryO = executeSql(
backend.contract.activeContractWithoutArgument(Set(signatory), contractId)
)

// The divulgee still sees the contract
templateIdDivulgeeO shouldBe Some(someTemplateId.toString)
inside(rawContractDivulgeeO) { case Some(rawContract) =>
rawContract.templateId shouldBe someTemplateId.toString
rawContract.createArgumentCompression shouldBe None
}
// The signatory knows it's archived
templateIdSignatoryO shouldBe None
rawContractSignatoryO shouldBe None
}

}

0 comments on commit a2b5143

Please sign in to comment.