2017-10-17 3 views
0

Veuillez me le suggérer, mais j'ai aussi participé au projet de base. la plupart des tests junit qui ont compiler errror et certains ne peuvent pas être exécutés correctement. J'ai utilisé le code ci-dessous pour tester Junit dans la version V14, le code est correct. mais dans la version CordaV1. pop-up erreur fait sauter:Unité Corda V1 Numéro du code de test

net.corda.core.transactions.MissingContractAttachments: Cannot find contract attachments for [com.legalcontract.contract.LegalContractCode] 
    at net.corda.core.transactions.TransactionBuilder.toWireTransactionWithContext$core_main(TransactionBuilder.kt:96) ~[corda-core-1.0.0.jar:?] 
    at net.corda.core.transactions.TransactionBuilder.toWireTransactionWithContext$core_main$default(TransactionBuilder.kt:87) ~[corda-core-1.0.0.jar:?] 
    at net.corda.core.transactions.TransactionBuilder.toWireTransaction(TransactionBuilder.kt:85) ~[corda-core-1.0.0.jar:?] 
    at net.corda.core.transactions.TransactionBuilder.toLedgerTransaction(TransactionBuilder.kt:107) ~[corda-core-1.0.0.jar:?] 
    at net.corda.core.transactions.TransactionBuilder.verify(TransactionBuilder.kt:113) ~[corda-core-1.0.0.jar:?] 
    at com.legalcontract.flow.LegalContractFlow$Initiator.call(LegalContractFlow.kt:247) ~[main/:?] 
    at com.legalcontract.flow.LegalContractFlow$Initiator.call(LegalContractFlow.kt:47) ~[main/:?] 
    at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:112) [corda-node-1.0.0.jar:?] 
    at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:40) [corda-node-1.0.0.jar:?] 
    at co.paralleluniverse.fibers.Fiber.run1(Fiber.java:1092) [quasar-core-0.7.9-jdk8.jar:0.7.9] 
    at co.paralleluniverse.fibers.Fiber.exec(Fiber.java:788) [quasar-core-0.7.9-jdk8.jar:0.7.9] 
    at co.paralleluniverse.fibers.RunnableFiberTask.doExec(RunnableFiberTask.java:100) [quasar-core-0.7.9-jdk8.jar:0.7.9] 
    at co.paralleluniverse.fibers.RunnableFiberTask.run(RunnableFiberTask.java:91) [quasar-core-0.7.9-jdk8.jar:0.7.9] 
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_131] 
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_131] 
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_131] 
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:1.8.0_131] 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_131] 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_131] 

code:

@After 
fun tearDown() { 
    net.stopNodes() 
} 
@Before 
fun setup() { 
    net = MockNetwork(false, true) 
} 

class WrapperStream(input: InputStream) : FilterInputStream(input) 

@Test 
fun `flow a new status valid Legal Contract`() { 

     val notaryNode = net.createNotaryNode() 
     val a = net.createPartyNode(notaryNode.network.myAddress, CordaX500Name("a","London","GB")) 
     val b = net.createPartyNode(notaryNode.network.myAddress, CordaX500Name("b","New York","US")) 

     a.internals.registerInitiatedFlow(LegalContractFlow.Acceptor::class.java) 
     b.internals.registerInitiatedFlow(LegalContractFlow.Acceptor::class.java) 

     val attachment = gInputStreamAndHash() 
     println(attachment) 

     val id = a.database.transaction { 
     a.attachments.importAttachment(attachment.inputStream) 
     } 


     assertEquals(attachment.sha256, id, "Attachment has correct SHA256 hash") 
     LegalContractFlowTests.attachList.add(id.toString()) 

     var fileName: String = "test1" 

     var legalContract: LegalContract = LegalContract(a.info.legalIdentities.first().name.toString(),LegalContractFlowTests.attachList.get(0)) 
// 

     System.out.print(legalContract) 
     var state: LegalContractState = LegalContractState(
       legalContract, 
       a.info.legalIdentities.first(), 
       b.info.legalIdentities.first()) 

     val flow = LegalContractFlow.Initiator(state, b.info.chooseIdentity(), false) 
     val future = a.services.startFlow(flow).resultFuture 


     var signedTx = future.getOrThrow() 


     for (node in listOf(a, b)) { 
      assertEquals(signedTx, node.services.validatedTransactions.getTransaction(signedTx.id)) 
     } 

    } 

Répondre

0

En Corda V1, vous devez indiquer vos tests paquetages à analyser lors de la recherche des pièces jointes du contrat - voir https://docs.corda.net/key-concepts-contract-constraints.html#testing.

Il s'agit d'une pièce temporaire de type «boilerplate» seulement, qui devrait être retirée à l'avenir. Il n'est également pas requis pour les nœuds réels, uniquement pour les nœuds simulés.

+0

ok, merci. ça marche – Hart