java.lang.IllegalArgumentException Корда-транслирующий репозиторий с Kotlin - PullRequest
0 голосов
/ 02 июля 2019

Я пытаюсь написать контракт в Kotlin Corda-Tranning Repository с TDD.Все IOUIssueTests был Сбой.

У меня есть jdk 1.8.0_211.Gradle 5.5.И установлен плагин kotlin.IOUStates были также реализованы.

Это мой IOUContract для 5 IOUIssueTest:

 package net.corda.training.contract

    import net.corda.core.contracts.*
    import net.corda.core.transactions.LedgerTransaction
    import net.corda.training.state.IOUState
    /**
     * This is where you'll add the contract code which defines how the [IOUState] behaves. Look at the unit tests in
     * [IOUContractTests] for instructions on how to complete the [IOUContract] class.
     */
    @LegalProseReference(uri = "<prose_contract_uri>")
    class IOUContract : Contract {
        companion object {
            @JvmStatic
            val IOU_CONTRACT_ID = "net.corda.training.contract.IOUContract"

        }


        /**
         * Add any commands required for this contract as classes within this interface.
         * It is useful to encapsulate your commands inside an interface, so you can use the [requireSingleCommand]
         * function to check for a number of commands which implement this interface.
         */
       interface Commands : CommandData {

            class Issue : TypeOnlyCommandData(), Commands
        }

        /**
         * The contract code for the [IOUContract].
         * The constraints are self documenting so don't require any additional explanation.
         */
        override fun verify(tx: LedgerTransaction) {
            val command = tx.commands.requireSingleCommand<Commands>()

            when (command.value) {

                is Commands.Issue -> {
                    requireThat {
                        "No inputs should be consumed when issuing an IOU." using (tx.inputs.isEmpty())
                        "Only one output state should be created when issuing an IOU." using (tx.outputs.size == 1)
                        val iou = tx.outputStates.single() as IOUState
                        "A newly issued IOU must have a positive amount." using (iou.amount.quantity > 0)
                        "The lender and borrower cannot have the same identity." using (iou.lender !== iou.borrower)
                        "Both lender and borrower together only may sign IOU issue transaction." using(iou.participants.toSet() == iou.participants.map { it.owningKey}.toSet())

                    }
                }

            }

        }
    }

Однако, когда я запускаю IOUIsuueTest.kt, я получаю следующую ошибку:

java.lang.IllegalArgumentException: Attempted to find dependent attachment for class net/corda/core/contracts/TypeOnlyCommandData, but could not find a suitable candidate.

    at net.corda.core.transactions.TransactionBuilder.addMissingDependency(TransactionBuilder.kt:179)
    at net.corda.core.transactions.TransactionBuilder.toWireTransactionWithContext$core(TransactionBuilder.kt:160)
    at net.corda.core.transactions.TransactionBuilder.toWireTransactionWithContext$core$default(TransactionBuilder.kt:128)
    at net.corda.core.transactions.TransactionBuilder.toWireTransaction(TransactionBuilder.kt:125)
    at net.corda.testing.dsl.TestTransactionDSLInterpreter.toWireTransaction$test_utils(TestDSL.kt:95)
    at net.corda.testing.dsl.TestLedgerDSLInterpreter.recordTransactionWithTransactionMap(TestDSL.kt:257)
    at net.corda.testing.dsl.TestLedgerDSLInterpreter._transaction(TestDSL.kt:289)
    at net.corda.testing.dsl.LedgerDSL._transaction(LedgerDSLInterpreter.kt)
    at net.corda.testing.dsl.LedgerDSL.transaction(LedgerDSLInterpreter.kt:141)
    at net.corda.testing.dsl.LedgerDSL.transaction$default(LedgerDSLInterpreter.kt:139)
    at net.corda.training.contract.IOUIssueTests$mustIncludeIssueCommand$1.invoke(IOUIssueTests.kt:57)
    at net.corda.training.contract.IOUIssueTests$mustIncludeIssueCommand$1.invoke(IOUIssueTests.kt:21)
    at net.corda.testing.node.NodeTestUtils$ledger$2.invoke(NodeTestUtils.kt:39)
    at net.corda.testing.node.NodeTestUtils$ledger$2.invoke(NodeTestUtils.kt)
    at net.corda.testing.internal.InternalTestUtilsKt$withTestSerializationEnvIfNotSet$1.invoke(InternalTestUtils.kt:214)
    at net.corda.testing.internal.InternalTestUtilsKt$withTestSerializationEnvIfNotSet$1.invoke(InternalTestUtils.kt)
    at net.corda.testing.common.internal.CommonSerializationTestHelpersKt.asContextEnv(CommonSerializationTestHelpers.kt:11)
    at net.corda.testing.internal.InternalSerializationTestHelpersKt.asTestContextEnv(InternalSerializationTestHelpers.kt:33)
    at net.corda.testing.internal.InternalSerializationTestHelpersKt.asTestContextEnv$default(InternalSerializationTestHelpers.kt:31)
    at net.corda.testing.internal.InternalTestUtilsKt.withTestSerializationEnvIfNotSet(InternalTestUtils.kt:214)
    at net.corda.testing.node.NodeTestUtils.ledger(NodeTestUtils.kt:36)
    at net.corda.testing.node.NodeTestUtils.ledger$default(NodeTestUtils.kt:23)
    at net.corda.training.contract.IOUIssueTests.mustIncludeIssueCommand(IOUIssueTests.kt:56)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.

java: 66)

1 Ответ

0 голосов
/ 10 июля 2019

Ошибка была исправлена.Я использовал модульный тест Котлина. Модульный тест Котлина

...