forked from digital-asset/daml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port WronglyTypedContractIdIT to new TestTool. (digital-asset#2907)
Fixes digital-asset#2862.
- Loading branch information
Showing
3 changed files
with
50 additions
and
78 deletions.
There are no files selected for viewing
78 changes: 0 additions & 78 deletions
78
...ala/com/digitalasset/platform/tests/integration/ledger/api/WronglyTypedContractIdIT.scala
This file was deleted.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
...-test-tool/src/main/scala/com/daml/ledger/api/testtool/tests/WronglyTypedContractId.scala
This file contains 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,49 @@ | ||
// Copyright (c) 2019 The DAML Authors. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package com.daml.ledger.api.testtool.tests | ||
|
||
import com.daml.ledger.api.testtool.infrastructure.{LedgerSession, LedgerTest, LedgerTestSuite} | ||
import com.digitalasset.ledger.client.binding.Primitive | ||
import com.digitalasset.ledger.test_stable.Test.DummyWithParam._ | ||
import com.digitalasset.ledger.test_stable.Test.Delegation._ | ||
import com.digitalasset.ledger.test_stable.Test.{Delegated, Delegation, Dummy, DummyWithParam} | ||
import io.grpc.Status.Code | ||
|
||
final class WronglyTypedContractId(session: LedgerSession) extends LedgerTestSuite(session) { | ||
|
||
private[this] val failedExercise = | ||
LedgerTest("WTExerciseFails", "Exercising on a wrong type fails") { context => | ||
for { | ||
ledger <- context.participant() | ||
party <- ledger.allocateParty() | ||
|
||
dummy <- ledger.create(party, Dummy(party)) | ||
fakeDummyWithParam = dummy.asInstanceOf[Primitive.ContractId[DummyWithParam]] | ||
exerciseFailure <- ledger | ||
.exercise(party, fakeDummyWithParam.exerciseDummyChoice2(_, "txt")) | ||
.failed | ||
} yield { | ||
assertGrpcError(exerciseFailure, Code.INVALID_ARGUMENT, "wrongly typed contract id") | ||
} | ||
} | ||
|
||
private[this] val failedFetch = | ||
LedgerTest("WTFetchFails", "Fetching of the wrong type fails") { context => | ||
for { | ||
ledger <- context.participant() | ||
Vector(owner, delegate) <- ledger.allocateParties(2) | ||
|
||
dummy <- ledger.create(owner, Dummy(owner)) | ||
fakeDelegated = dummy.asInstanceOf[Primitive.ContractId[Delegated]] | ||
delegation <- ledger.create(owner, Delegation(owner, delegate)) | ||
|
||
fetchFailure <- ledger | ||
.exercise(owner, delegation.exerciseFetchDelegated(_, fakeDelegated)) | ||
.failed | ||
} yield { | ||
assertGrpcError(fetchFailure, Code.INVALID_ARGUMENT, "wrongly typed contract id") | ||
} | ||
} | ||
override val tests: Vector[LedgerTest] = Vector(failedExercise, failedFetch) | ||
} |
This file contains 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