diff --git a/docs/source/example-code/src/main/kotlin/net/corda/docs/tutorial/testdsl/TutorialTestDSL.kt b/docs/source/example-code/src/main/kotlin/net/corda/docs/tutorial/testdsl/TutorialTestDSL.kt index 2b25fe726e..a52961b0e0 100644 --- a/docs/source/example-code/src/main/kotlin/net/corda/docs/tutorial/testdsl/TutorialTestDSL.kt +++ b/docs/source/example-code/src/main/kotlin/net/corda/docs/tutorial/testdsl/TutorialTestDSL.kt @@ -31,7 +31,7 @@ class CommercialPaperTest { transaction { attachments(CP_PROGRAM_ID) input(CP_PROGRAM_ID) { inState } - this.verifies() + verifies() } } } @@ -46,7 +46,7 @@ class CommercialPaperTest { input(CP_PROGRAM_ID) { inState } command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Move() } attachments(CP_PROGRAM_ID) - this.verifies() + verifies() } } } @@ -61,7 +61,7 @@ class CommercialPaperTest { input(CP_PROGRAM_ID) { inState } command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Move() } attachments(CP_PROGRAM_ID) - this `fails with` "the state is propagated" + `fails with`("the state is propagated") } } } @@ -76,9 +76,9 @@ class CommercialPaperTest { input(CP_PROGRAM_ID) { inState } command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Move() } attachments(CP_PROGRAM_ID) - this `fails with` "the state is propagated" + `fails with`("the state is propagated") output(CP_PROGRAM_ID, "alice's paper") { inState.withOwner(ALICE) } - this.verifies() + verifies() } } } @@ -95,11 +95,11 @@ class CommercialPaperTest { // The wrong pubkey. command(BIG_CORP_PUBKEY) { CommercialPaper.Commands.Issue() } timeWindow(TEST_TX_TIME) - this `fails with` "output states are issued by a command signer" + `fails with`("output states are issued by a command signer") } command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Issue() } timeWindow(TEST_TX_TIME) - this.verifies() + verifies() } } } @@ -115,11 +115,11 @@ class CommercialPaperTest { // The wrong pubkey. command(BIG_CORP_PUBKEY) { CommercialPaper.Commands.Issue() } timeWindow(TEST_TX_TIME) - this `fails with` "output states are issued by a command signer" + `fails with`("output states are issued by a command signer") } command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Issue() } timeWindow(TEST_TX_TIME) - this.verifies() + verifies() } } // DOCEND 7 @@ -141,7 +141,7 @@ class CommercialPaperTest { command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Issue() } attachments(CP_PROGRAM_ID) timeWindow(TEST_TX_TIME) - this.verifies() + verifies() } @@ -152,7 +152,7 @@ class CommercialPaperTest { output(CP_PROGRAM_ID, "alice's paper") { "paper".output().withOwner(ALICE) } command(ALICE_PUBKEY) { Cash.Commands.Move() } command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Move() } - this.verifies() + verifies() } } } @@ -174,7 +174,7 @@ class CommercialPaperTest { command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Issue() } attachments(CP_PROGRAM_ID) timeWindow(TEST_TX_TIME) - this.verifies() + verifies() } transaction("Trade") { @@ -184,7 +184,7 @@ class CommercialPaperTest { output(CP_PROGRAM_ID, "alice's paper") { "paper".output().withOwner(ALICE) } command(ALICE_PUBKEY) { Cash.Commands.Move() } command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Move() } - this.verifies() + verifies() } transaction { @@ -192,10 +192,10 @@ class CommercialPaperTest { // We moved a paper to another pubkey. output(CP_PROGRAM_ID, "bob's paper") { "paper".output().withOwner(BOB) } command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Move() } - this.verifies() + verifies() } - this.fails() + fails() } } // DOCEND 9 @@ -216,7 +216,7 @@ class CommercialPaperTest { command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Issue() } attachments(CP_PROGRAM_ID) timeWindow(TEST_TX_TIME) - this.verifies() + verifies() } transaction("Trade") { @@ -226,7 +226,7 @@ class CommercialPaperTest { output(CP_PROGRAM_ID, "alice's paper") { "paper".output().withOwner(ALICE) } command(ALICE_PUBKEY) { Cash.Commands.Move() } command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Move() } - this.verifies() + verifies() } tweak { @@ -235,13 +235,13 @@ class CommercialPaperTest { // We moved a paper to another pubkey. output(CP_PROGRAM_ID, "bob's paper") { "paper".output().withOwner(BOB) } command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Move() } - this.verifies() + verifies() } - this.fails() + fails() } - this.verifies() + verifies() } } // DOCEND 10 -} \ No newline at end of file +} diff --git a/docs/source/tutorial-contract.rst b/docs/source/tutorial-contract.rst index 11e6ef0755..23c1430286 100644 --- a/docs/source/tutorial-contract.rst +++ b/docs/source/tutorial-contract.rst @@ -327,7 +327,7 @@ little odd: we have a *requireThat* construct that looks like it's built into th ordinary function provided by the platform's contract API. Kotlin supports the creation of *domain specific languages* through the intersection of several features of the language, and we use it here to support the natural listing of requirements. To see what it compiles down to, look at the Java version. Each ``"string" using (expression)`` statement -inside a ``requireThat`` turns into an assertion that the given expression is true, with an ``IllegalStateException`` +inside a ``requireThat`` turns into an assertion that the given expression is true, with an ``IllegalArgumentException`` being thrown that contains the string if not. It's just another way to write out a regular assertion, but with the English-language requirement being put front and center. @@ -340,8 +340,8 @@ the owner. 1. We still check there is a CP input state. 2. We want to see that the face value of the CP is being moved as a cash claim against some party, that is, the issuer of the CP is really paying back the face value. -2. The transaction must be happening after the maturity date. -3. The commercial paper must *not* be propagated by this transaction: it must be deleted, by the group having no +3. The transaction must be happening after the maturity date. +4. The commercial paper must *not* be propagated by this transaction: it must be deleted, by the group having no output state. This prevents the same CP being considered redeemable multiple times. To calculate how much cash is moving, we use the ``sumCashBy`` utility function. Again, this is an extension function, @@ -476,7 +476,7 @@ generate methods should operate on the same transaction. You can see an example for the commercial paper contract. The paper is given to us as a ``StateAndRef`` object. This is exactly what it sounds like: -a small object that has a (copy of) a state object, and also the (txhash, index) that indicates the location of this +a small object that has a (copy of a) state object, and also the ``(txhash, index)`` that indicates the location of this state on the ledger. We add the existing paper state as an input, the same paper state with the owner field adjusted as an output, diff --git a/docs/source/tutorial-test-dsl.rst b/docs/source/tutorial-test-dsl.rst index 8bfbab79b0..ce66251a5c 100644 --- a/docs/source/tutorial-test-dsl.rst +++ b/docs/source/tutorial-test-dsl.rst @@ -114,7 +114,7 @@ The above code however doesn't compile: Error:(35, 27) java: incompatible types: bad return type in lambda expression missing return value -This is deliberate: The DSL forces us to specify either ``this.verifies()`` or ``this `fails with` "some text"`` on the +This is deliberate: The DSL forces us to specify either ``verifies()`` or ```fails with`("some text")`` on the last line of ``transaction``: .. container:: codeset @@ -141,11 +141,11 @@ Let's take a look at a transaction that fails. :end-before: DOCEND 3 :dedent: 4 - .. literalinclude:: ../../docs/source/example-code/src/main/java/net/corda/docs/java/tutorial/testdsl/CommercialPaperTest.java -:language: java - :start-after: DOCSTART 3 - :end-before: DOCEND 3 - :dedent: 4 + .. literalinclude:: ../../docs/source/example-code/src/main/java/net/corda/docs/java/tutorial/testdsl/CommercialPaperTest.java + :language: java + :start-after: DOCSTART 3 + :end-before: DOCEND 3 + :dedent: 4 When run, that code produces the following error: @@ -160,7 +160,7 @@ When run, that code produces the following error: net.corda.core.contracts.TransactionVerificationException$ContractRejection: java.lang.IllegalStateException: the state is propagated The transaction verification failed, because we wanted to move paper but didn't specify an output - but the state should be propagated. -However we can specify that this is an intended behaviour by changing ``this.verifies()`` to ``this `fails with` "the state is propagated"``: +However we can specify that this is an intended behaviour by changing ``verifies()`` to ```fails with`("the state is propagated")``: .. container:: codeset @@ -256,7 +256,7 @@ Now that we know how to define a single transaction, let's look at how to define :dedent: 4 In this example we declare that ``ALICE`` has $900 but we don't care where from. For this we can use -``unverifiedTransaction``. Note how we don't need to specify ``this.verifies()``. +``unverifiedTransaction``. Note how we don't need to specify ``verifies()``. Notice that we labelled output with ``"alice's $900"``, also in transaction named ``"Issuance"`` we labelled a commercial paper with ``"paper"``. Now we can subsequently refer to them in other transactions, e.g. @@ -265,7 +265,7 @@ by ``input("alice's $900")`` or ``"paper".output()``. The last transaction named ``"Trade"`` exemplifies simple fact of selling the ``CommercialPaper`` to Alice for her $900, $100 less than the face value at 10% interest after only 7 days. -We can also test whole ledger calling ``this.verifies()`` and ``this.fails()`` on the ledger level. +We can also test whole ledger calling ``verifies()`` and ``fails()`` on the ledger level. To do so let's create a simple example that uses the same input twice: .. container:: codeset @@ -283,7 +283,7 @@ To do so let's create a simple example that uses the same input twice: :dedent: 4 The transactions ``verifies()`` individually, however the state was spent twice! That's why we need the global ledger -verification (``this.fails()`` at the end). As in previous examples we can use ``tweak`` to create a local copy of the whole ledger: +verification (``fails()`` at the end). As in previous examples we can use ``tweak`` to create a local copy of the whole ledger: .. container:: codeset @@ -297,4 +297,4 @@ verification (``this.fails()`` at the end). As in previous examples we can use ` :language: java :start-after: DOCSTART 10 :end-before: DOCEND 10 - :dedent: 4 \ No newline at end of file + :dedent: 4