mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-19 16:57:40 +03:00
remove unused definitions, params, args from libs-scala and test tool Scala code (#7051)
* remove unused definitions, params, args from libs-scala and test tool Scala code CHANGELOG_BEGIN CHANGELOG_END * collapse `Some(_) | None` into _ - suggested by @SamirTalwar-DA; thanks Co-authored-by: Samir Talwar <samir.talwar@digitalasset.com> Co-authored-by: Samir Talwar <samir.talwar@digitalasset.com>
This commit is contained in:
parent
3d5e96c9bb
commit
294068ae1d
@ -14,12 +14,12 @@ import scopt.Read.{intRead, stringRead}
|
||||
|
||||
object Cli {
|
||||
|
||||
private def reportUsageOfDeprecatedOption[A, B](
|
||||
private def reportUsageOfDeprecatedOption[B](
|
||||
option: String,
|
||||
)(ignoredValue: A, ignoredConfig: B): B = {
|
||||
) = { (_: Any, config: B) =>
|
||||
System.err.println(
|
||||
s"WARNING: $option has been deprecated and will be removed in a future version")
|
||||
ignoredConfig
|
||||
config
|
||||
}
|
||||
|
||||
private def endpointRead: Read[(String, Int)] = new Read[(String, Int)] {
|
||||
|
@ -50,12 +50,12 @@ object LedgerApiTestTool {
|
||||
println()
|
||||
Tests.PerformanceTestsKeys.foreach(println(_))
|
||||
}
|
||||
private def printAvailableTestSuites(config: Config): Unit = {
|
||||
private def printAvailableTestSuites(): Unit = {
|
||||
println("Listing test suites. Run with --list-all to see individual tests.")
|
||||
printListOfTests(Tests.all)(_.name)
|
||||
}
|
||||
|
||||
private def printAvailableTests(config: Config): Unit = {
|
||||
private def printAvailableTests(): Unit = {
|
||||
println("Listing all tests. Run with --list to only see test suites.")
|
||||
printListOfTests(Tests.all.flatMap(_.tests))(_.name)
|
||||
}
|
||||
@ -83,12 +83,12 @@ object LedgerApiTestTool {
|
||||
val config = Cli.parse(args).getOrElse(sys.exit(1))
|
||||
|
||||
if (config.listTestSuites) {
|
||||
printAvailableTestSuites(config)
|
||||
printAvailableTestSuites()
|
||||
sys.exit(0)
|
||||
}
|
||||
|
||||
if (config.listTests) {
|
||||
printAvailableTests(config)
|
||||
printAvailableTests()
|
||||
sys.exit(0)
|
||||
}
|
||||
|
||||
|
@ -50,9 +50,7 @@ object Assertions extends DiffExtensions {
|
||||
}
|
||||
// None both represents pattern that we do not care about as well as
|
||||
// exceptions that have no message.
|
||||
case (GrpcException(GrpcStatus(`expectedCode`, Some(msg)), _), None) => ()
|
||||
case (GrpcException(GrpcStatus(`expectedCode`, None), _), None) =>
|
||||
()
|
||||
case (GrpcException(GrpcStatus(`expectedCode`, _), _), None) => ()
|
||||
case (GrpcException(GrpcStatus(code, _), _), _) =>
|
||||
fail(s"Expected code [$expectedCode], but got [$code].")
|
||||
case (NonFatal(e), _) =>
|
||||
|
@ -21,14 +21,6 @@ import scala.util.{Failure, Success}
|
||||
|
||||
final class CommandDeduplicationIT extends LedgerTestSuite {
|
||||
|
||||
/** A deduplicated submission can either
|
||||
* succeed (if the participant knows that the original submission has succeeded),
|
||||
* or fail with status ALREADY_EXISTS */
|
||||
private[this] def assertDeduplicated(result: Either[Throwable, Unit]): Unit = result match {
|
||||
case Left(e) => assertGrpcError(e, Status.Code.ALREADY_EXISTS, "")
|
||||
case Right(v) => ()
|
||||
}
|
||||
|
||||
test(
|
||||
"CDSimpleDeduplication",
|
||||
"Deduplicate commands within the deduplication time window",
|
||||
|
@ -189,7 +189,7 @@ final class SemanticTests extends LedgerTestSuite {
|
||||
"It should not be possible to exercise a choice without the consent of the controller",
|
||||
allocate(TwoParties, SingleParty),
|
||||
)(implicit ec => {
|
||||
case Participants(Participant(alpha, bank, houseOwner), Participant(beta, painter)) =>
|
||||
case Participants(Participant(alpha @ _, bank, houseOwner), Participant(beta, painter)) =>
|
||||
for {
|
||||
iou <- beta.create(painter, Iou(painter, houseOwner, onePound))
|
||||
offer <- beta.create(painter, PaintOffer(painter, houseOwner, bank, onePound))
|
||||
|
@ -751,7 +751,7 @@ class TransactionServiceIT extends LedgerTestSuite {
|
||||
|
||||
test("TXStakeholders", "Expose the correct stakeholders", allocate(SingleParty, SingleParty))(
|
||||
implicit ec => {
|
||||
case Participants(Participant(alpha, receiver), Participant(beta, giver)) =>
|
||||
case Participants(Participant(alpha @ _, receiver), Participant(beta, giver)) =>
|
||||
for {
|
||||
_ <- beta.create(giver, CallablePayout(giver, receiver))
|
||||
transactions <- beta.flatTransactions(giver, receiver)
|
||||
@ -767,7 +767,7 @@ class TransactionServiceIT extends LedgerTestSuite {
|
||||
"There should be no contract key if the template does not specify one",
|
||||
allocate(SingleParty, SingleParty),
|
||||
)(implicit ec => {
|
||||
case Participants(Participant(alpha, receiver), Participant(beta, giver)) =>
|
||||
case Participants(Participant(alpha @ _, receiver), Participant(beta, giver)) =>
|
||||
for {
|
||||
_ <- beta.create(giver, CallablePayout(giver, receiver))
|
||||
transactions <- beta.flatTransactions(giver, receiver)
|
||||
|
@ -30,7 +30,8 @@ final class TimeBoundObserver[T](duration: FiniteDuration)(
|
||||
}
|
||||
|
||||
override def onCompleted(): Unit = {
|
||||
val _succeeded = promise.trySuccess(buffer.result())
|
||||
val _cancelled = Context.current().withCancellation().cancel(null)
|
||||
promise.trySuccess(buffer.result())
|
||||
Context.current().withCancellation().cancel(null)
|
||||
()
|
||||
}
|
||||
}
|
||||
|
@ -37,8 +37,9 @@ final class WaitForCompletionsObserver private (expectedCompletions: Int)
|
||||
override def onNext(v: CompletionStreamResponse): Unit = {
|
||||
val total = counter.addAndGet(v.completions.size)
|
||||
if (total >= expectedCompletions) {
|
||||
val _1 = promise.trySuccess(())
|
||||
val _2 = Context.current().withCancellation().cancel(null)
|
||||
promise.trySuccess(())
|
||||
Context.current().withCancellation().cancel(null)
|
||||
()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ trait ResourceOwner[+A] {
|
||||
}
|
||||
|
||||
/** @see [[Resource.withFilter()]] */
|
||||
def withFilter(p: A => Boolean)(implicit executionContext: ExecutionContext): ResourceOwner[A] =
|
||||
def withFilter(p: A => Boolean): ResourceOwner[A] =
|
||||
new ResourceOwner[A] {
|
||||
override def acquire()(implicit executionContext: ExecutionContext): Resource[A] =
|
||||
self.acquire().withFilter(p)
|
||||
|
@ -7,9 +7,7 @@ import scala.concurrent.duration.FiniteDuration
|
||||
import scala.concurrent.{ExecutionContext, Future}
|
||||
|
||||
object DelayedReleaseResourceOwner {
|
||||
def apply[T](value: T, releaseDelay: FiniteDuration)(
|
||||
implicit executionContext: ExecutionContext
|
||||
): TestResourceOwner[T] =
|
||||
def apply[T](value: T, releaseDelay: FiniteDuration): TestResourceOwner[T] =
|
||||
new TestResourceOwner(
|
||||
Future.successful(value),
|
||||
_ => Future(Thread.sleep(releaseDelay.toMillis))(ExecutionContext.global))
|
||||
|
@ -181,7 +181,7 @@ class ResettableResourceOwnerSpec extends AsyncWordSpec with AsyncTimeLimitedTes
|
||||
}
|
||||
|
||||
"not hold on to old values" in {
|
||||
var acquisitions = mutable.Buffer[WeakReference[Object]]()
|
||||
val acquisitions = mutable.Buffer[WeakReference[Object]]()
|
||||
val owner = ResettableResourceOwner(reset =>
|
||||
new ResourceOwner[(Reset, Object)] {
|
||||
override def acquire()(
|
||||
|
@ -13,8 +13,7 @@ object Delayed {
|
||||
Future.by(t)(ScalaFuture(value))
|
||||
|
||||
object Future {
|
||||
def by[T](t: Duration)(value: => ScalaFuture[T])(
|
||||
implicit ec: ExecutionContext): ScalaFuture[T] =
|
||||
def by[T](t: Duration)(value: => ScalaFuture[T]): ScalaFuture[T] =
|
||||
if (!t.isFinite) {
|
||||
ScalaFuture.failed(new IllegalArgumentException(s"A task cannot be postponed indefinitely"))
|
||||
} else if (t.length < 1) {
|
||||
|
Loading…
Reference in New Issue
Block a user