package Ġnet . cord a . core tests . transactions Ċ Ċ import Ġcom . n ha ar man . mockito _ kotlin . do Return Ċ import Ġcom . n ha ar man . mockito _ kotlin . mock Ċ import Ġcom . n ha ar man . mockito _ kotlin . wh enever Ċ import Ġnet . cord a . core . contracts . Command Ċ import Ġnet . cord a . core . contracts . Contract Attachment Ċ import Ġnet . cord a . core . contracts . Hash Attachment Constraint Ċ import Ġnet . cord a . core . contracts . Privacy Salt Ċ import Ġnet . cord a . core . contracts . Signature Attachment Constraint Ċ import Ġnet . cord a . core . contracts . State And Ref Ċ import Ġnet . cord a . core . contracts . State Ref Ċ import Ġnet . cord a . core . contracts . Time Window Ċ import Ġnet . cord a . core . contracts . Transaction State Ċ import Ġnet . cord a . core . contracts . Transaction Verification Exception Ċ import Ġnet . cord a . core . cord app . C ord app Provider Ċ import Ġnet . cord a . core . crypto . Composite Key Ċ import Ġnet . cord a . core . crypto . Digest Service Ċ import Ġnet . cord a . core . crypto . Secure Hash Ċ import Ġnet . cord a . core . identity . Party Ċ import Ġnet . cord a . core . internal . Abstract Attachment Ċ import Ġnet . cord a . core . internal . Hash Ag ility Ċ import Ġnet . cord a . core . internal . PLATFORM _ VERSION Ċ import Ġnet . cord a . core . internal . digest Service Ċ import Ġnet . cord a . core . node . Services For Resolution Ċ import Ġnet . cord a . core . node . Zone Version Too Low Exception Ċ import Ġnet . cord a . core . node . services . Attachment Storage Ċ import Ġnet . cord a . core . node . services . Identity Service Ċ import Ġnet . cord a . core . node . services . Network Parameters Service Ċ import Ġnet . cord a . core . serialization . serialize Ċ import Ġnet . cord a . core . transactions . Transaction Builder Ċ import Ġnet . cord a . core testing . internal . rig or ous Mock Ċ import Ġnet . cord a . testing . common . internal . test Network Parameters Ċ import Ġnet . cord a . testing . contracts . Dummy Contract Ċ import Ġnet . cord a . testing . contracts . Dummy State Ċ import Ġnet . cord a . testing . core . AL ICE _ NAME Ċ import Ġnet . cord a . testing . core . BO B _ NAME Ċ import Ġnet . cord a . testing . core . D UMMY _ NOT ARY _ NAME Ċ import Ġnet . cord a . testing . core . Dummy Command Data Ċ import Ġnet . cord a . testing . core . Serialization Environment Rule Ċ import Ġnet . cord a . testing . core . Test Identity Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . assertj . core . api . Assertions . assertThat Thrown By Ċ import Ġorg . junit . Assert . assertFalse Ċ import Ġorg . junit . Assert . assertTrue Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Ignore Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġjava . security . PublicKey Ċ import Ġjava . time . Instant Ċ import Ġkotlin . test . assert Fails With Ċ Ċ class ĠTransaction Builder Test Ġ{ ĊĠĠĠ Ġ@ Rule ĊĠĠĠ Ġ@ Jvm Field ĊĠĠĠ Ġval Ġtest Serialization Ġ= ĠSerialization Environment Rule () ĊĊĠĠĠ Ġprivate Ġval Ġnot ary Ġ= ĠTest Identity ( D UMMY _ NOT ARY _ NAME ). party ĊĠĠĠ Ġprivate Ġval Ġservices Ġ= Ġrig or ous Mock < Services For Resolution >() ĊĠĠĠ Ġprivate Ġval Ġcontract Attachment Id Ġ= ĠSecure Hash . random SHA 2 5 6 () ĊĠĠĠ Ġprivate Ġval Ġattachments Ġ= Ġrig or ous Mock < Attachment Storage >() ĊĠĠĠ Ġprivate Ġval Ġnetwork Parameters Service Ġ= Ġmock < Network Parameters Service >() ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġsetup () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġc ord app Provider Ġ= Ġrig or ous Mock < C ord app Provider >() ĊĠĠĠĠĠĠĠ Ġval Ġnetwork Parameters Ġ= Ġtest Network Parameters ( minimum Platform Version Ġ= ĠPLATFORM _ VERSION ) ĊĠĠĠĠĠĠĠ Ġdo Return ( network Parameters Service ). wh enever ( services ). network Parameters Service ĊĠĠĠĠĠĠĠ Ġdo Return ( network Parameters . serialize (). hash ). wh enever ( network Parameters Service ). current Hash ĊĠĠĠĠĠĠĠ Ġdo Return ( cord app Provider ). wh enever ( services ). cord app Provider ĊĠĠĠĠĠĠĠ Ġdo Return ( contract Attachment Id ). wh enever ( cord app Provider ). get Contract Attachment ID ( Dummy Contract . PROGRAM _ ID ) ĊĠĠĠĠĠĠĠ Ġdo Return ( network Parameters ). wh enever ( services ). network Parameters ĊĠĠĠĠĠĠĠ Ġdo Return ( mock < Identity Service > ()). wh enever ( services ). identity Service ĊĊĠĠĠĠĠĠĠ Ġval Ġattachment Storage Ġ= Ġrig or ous Mock < Attachment Storage >() ĊĠĠĠĠĠĠĠ Ġdo Return ( attachment Storage ). wh enever ( services ). attachments ĊĠĠĠĠĠĠĠ Ġval Ġattachment Ġ= Ġrig or ous Mock < Contract Attachment >() ĊĠĠĠĠĠĠĠ Ġdo Return ( attachment ). wh enever ( attachment Storage ). open Attachment ( contract Attachment Id ) ĊĠĠĠĠĠĠĠ Ġdo Return ( contract Attachment Id ). wh enever ( attachment ). id ĊĠĠĠĠĠĠĠ Ġdo Return ( set Of ( Dummy Contract . PROGRAM _ ID )). wh enever ( attachment ). all Contracts ĊĠĠĠĠĠĠĠ Ġdo Return (" app "). wh enever ( attachment ). uploader ĊĠĠĠĠĠĠĠ Ġdo Return ( emptyList < Party > ()). wh enever ( attachment ). signer Keys ĊĠĠĠĠĠĠĠ Ġdo Return ( listOf ( contract Attachment Id )). wh enever ( attachment Storage ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. get Latest Contract Attachments (" net . cord a . testing . contracts . Dummy Contract ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( timeout = 3 0 0 _ 0 0 0 ) Ċ ĉ fun Ġ` bare Ġminimum Ġiss u ance Ġtx `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġoutput State Ġ= ĠTransaction State ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġdata Ġ= ĠDummy State (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcontract Ġ= ĠDummy Contract . PROGRAM _ ID , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġnot ary Ġ= Ġnot ary , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġconstraint Ġ= ĠHash Attachment Constraint ( contract Attachment Id ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġbuilder Ġ= ĠTransaction Builder () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Output State ( output State ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Command ( Dummy Command Data , Ġnot ary . own ing Key ) ĊĠĠĠĠĠĠĠ Ġval Ġw tx Ġ= Ġbuilder . to Wire Transaction ( services ) ĊĠĠĠĠĠĠĠ ĠassertThat ( w tx . outputs ). contains Only ( output State ) ĊĠĠĠĠĠĠĠ ĠassertThat ( w tx . commands ). contains Only ( Command ( Dummy Command Data , Ġnot ary . own ing Key )) ĊĠĠĠĠĠĠĠ ĠassertThat ( w tx . network Parameters Hash ). isEqualTo ( network Parameters Service . current Hash ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( timeout = 3 0 0 _ 0 0 0 ) Ċ ĉ fun Ġ` automatic Ġhash Ġconstraint `() Ġ{ ĊĠĠĠĠĠĠĠ Ġdo Return ( unsigned Attachment ). wh enever ( attachments ). open Attachment ( contract Attachment Id ) ĊĊĠĠĠĠĠĠĠ Ġval Ġoutput State Ġ= ĠTransaction State ( data Ġ= ĠDummy State (), Ġcontract Ġ= ĠDummy Contract . PROGRAM _ ID , Ġnot ary Ġ= Ġnot ary ) ĊĠĠĠĠĠĠĠ Ġval Ġbuilder Ġ= ĠTransaction Builder () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Output State ( output State ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Command ( Dummy Command Data , Ġnot ary . own ing Key ) ĊĠĠĠĠĠĠĠ Ġval Ġw tx Ġ= Ġbuilder . to Wire Transaction ( services ) ĊĠĠĠĠĠĠĠ ĠassertThat ( w tx . outputs ). contains Only ( output State . copy ( constraint Ġ= ĠHash Attachment Constraint ( contract Attachment Id ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( timeout = 3 0 0 _ 0 0 0 ) Ċ ĉ fun Ġ` reference Ġstates `() Ġ{ ĊĠĠĠĠĠĠĠ Ġdo Return ( unsigned Attachment ). wh enever ( attachments ). open Attachment ( contract Attachment Id ) ĊĊĠĠĠĠĠĠĠ Ġval Ġreference State Ġ= ĠTransaction State ( Dummy State (), ĠDummy Contract . PROGRAM _ ID , Ġnot ary ) ĊĠĠĠĠĠĠĠ Ġval Ġreference State Ref Ġ= ĠState Ref ( Secure Hash . random SHA 2 5 6 (), Ġ 1 ) ĊĠĠĠĠĠĠĠ Ġval Ġbuilder Ġ= ĠTransaction Builder ( not ary ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Reference State ( State And Ref ( reference State , Ġreference State Ref ). referenced ()) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Output State ( Transaction State ( Dummy State (), ĠDummy Contract . PROGRAM _ ID , Ġnot ary )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Command ( Dummy Command Data , Ġnot ary . own ing Key ) ĊĊĠĠĠĠĠĠĠ Ġdo Return ( test Network Parameters ( minimum Platform Version Ġ= Ġ 3 )). wh enever ( services ). network Parameters ĊĠĠĠĠĠĠĠ ĠassertThat Thrown By Ġ{ Ġbuilder . to Wire Transaction ( services ) Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. isInstanceOf ( Zone Version Too Low Exception :: class . java ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. has Message Containing (" Reference Ġstates ") ĊĊĠĠĠĠĠĠĠ Ġdo Return ( test Network Parameters ( minimum Platform Version Ġ= Ġ 4 )). wh enever ( services ). network Parameters ĊĠĠĠĠĠĠĠ Ġdo Return ( reference State ). wh enever ( services ). load State ( reference State Ref ) ĊĠĠĠĠĠĠĠ Ġval Ġw tx Ġ= Ġbuilder . to Wire Transaction ( services ) ĊĠĠĠĠĠĠĠ ĠassertThat ( w tx . references ). contains Only ( reference State Ref ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( timeout = 3 0 0 _ 0 0 0 ) Ċ ĉ fun Ġ` automatic Ġsignature Ġconstraint `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġalice Party Ġ= ĠTest Identity ( AL ICE _ NAME ). party ĊĠĠĠĠĠĠĠ Ġval Ġbob Party Ġ= ĠTest Identity ( BO B _ NAME ). party ĊĠĠĠĠĠĠĠ Ġval Ġcomposite Key Ġ= ĠComposite Key . Builder (). add Keys ( alice Party . own ing Key , Ġbob Party . own ing Key ). build () ĊĠĠĠĠĠĠĠ Ġval Ġexpected Constraint Ġ= ĠSignature Attachment Constraint ( composite Key ) ĊĠĠĠĠĠĠĠ Ġval Ġsigned Attachment Ġ= Ġsigned Attachment ( alice Party , Ġbob Party ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( expected Constraint . is Satisf ied By ( signed Attachment )) ĊĠĠĠĠĠĠĠ ĠassertFalse ( expected Constraint . is Satisf ied By ( unsigned Attachment )) ĊĊĠĠĠĠĠĠĠ Ġdo Return ( attachments ). wh enever ( services ). attachments ĊĠĠĠĠĠĠĠ Ġdo Return ( signed Attachment ). wh enever ( attachments ). open Attachment ( contract Attachment Id ) ĊĠĠĠĠĠĠĠ Ġdo Return ( listOf ( contract Attachment Id )). wh enever ( attachments ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. get Latest Contract Attachments (" net . cord a . testing . contracts . Dummy Contract ") ĊĊĠĠĠĠĠĠĠ Ġval Ġoutput State Ġ= ĠTransaction State ( data Ġ= ĠDummy State (), Ġcontract Ġ= ĠDummy Contract . PROGRAM _ ID , Ġnot ary Ġ= Ġnot ary ) ĊĠĠĠĠĠĠĠ Ġval Ġbuilder Ġ= ĠTransaction Builder () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Output State ( output State ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Command ( Dummy Command Data , Ġnot ary . own ing Key ) ĊĠĠĠĠĠĠĠ Ġval Ġw tx Ġ= Ġbuilder . to Wire Transaction ( services ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( w tx . outputs ). contains Only ( output State . copy ( constraint Ġ= Ġexpected Constraint )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġval Ġunsigned Attachment Ġ= ĠContract Attachment ( object Ġ: ĠAbstract Attachment ({ Ġbyte ArrayOf () Ġ}, Ġ" test ") Ġ{ ĊĠĠĠĠĠĠĠ Ġoverride Ġval Ġid : ĠSecure Hash Ġget () Ġ= Ġthrow ĠUnsupportedOperationException () ĊĊĠĠĠĠĠĠĠ Ġoverride Ġval Ġsigner Keys : ĠList < PublicKey > Ġget () Ġ= Ġempty List () ĊĠĠĠ Ġ}, ĠDummy Contract . PROGRAM _ ID ) ĊĊĠĠĠ Ġprivate Ġfun Ġsigned Attachment ( var arg Ġparties : ĠParty ) Ġ= ĠContract Attachment . create ( object Ġ: ĠAbstract Attachment ({ Ġbyte ArrayOf () Ġ}, Ġ" test ") Ġ{ ĊĠĠĠĠĠĠĠ Ġoverride Ġval Ġid : ĠSecure Hash Ġget () Ġ= Ġcontract Attachment Id ĊĊĠĠĠĠĠĠĠ Ġoverride Ġval Ġsigner Keys : ĠList < PublicKey > Ġget () Ġ= Ġparties . map Ġ{ Ġit . own ing Key Ġ} ĊĠĠĠ Ġ}, ĠDummy Contract . PROGRAM _ ID , Ġsigner Keys Ġ= Ġparties . map Ġ{ Ġit . own ing Key Ġ}) ĊĊĠĠĠ Ġ@ Test ( timeout = 3 0 0 _ 0 0 0 ) ĊĠĠĠ Ġfun Ġ` list Ġaccessors Ġare Ġmutable Ġcopies `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġinput State 1 Ġ= ĠTransaction State ( Dummy State (), ĠDummy Contract . PROGRAM _ ID , Ġnot ary ) ĊĠĠĠĠĠĠĠ Ġval Ġinput State Ref 1 Ġ= ĠState Ref ( Secure Hash . random SHA 2 5 6 (), Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġval Ġreference State 1 Ġ= ĠTransaction State ( Dummy State (), ĠDummy Contract . PROGRAM _ ID , Ġnot ary ) ĊĠĠĠĠĠĠĠ Ġval Ġreference State Ref 1 Ġ= ĠState Ref ( Secure Hash . random SHA 2 5 6 (), Ġ 1 ) ĊĠĠĠĠĠĠĠ Ġval Ġbuilder Ġ= ĠTransaction Builder ( not ary ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Input State ( State And Ref ( input State 1 , Ġinput State Ref 1 )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Attachment ( Secure Hash . all On es Hash ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Output State ( Transaction State ( Dummy State (), ĠDummy Contract . PROGRAM _ ID , Ġnot ary )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Command ( Dummy Command Data , Ġnot ary . own ing Key ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Reference State ( State And Ref ( reference State 1 , Ġreference State Ref 1 ). referenced ()) ĊĠĠĠĠĠĠĠ Ġval Ġinput State Ref 2 Ġ= ĠState Ref ( Secure Hash . random SHA 2 5 6 (), Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġval Ġreference State Ref 2 Ġ= ĠState Ref ( Secure Hash . random SHA 2 5 6 (), Ġ 1 ) ĊĊĠĠĠĠĠĠĠ Ġ// ĠList Ġaccessors Ġare Ġmutable . ĊĠĠĠĠĠĠĠ ĠassertThat (( builder . input States () Ġas ĠArrayList ). also Ġ{ Ġit . add ( input State Ref 2 ) Ġ}). has Size ( 2 ) ĊĠĠĠĠĠĠĠ ĠassertThat (( builder . attachments () Ġas ĠArrayList ). also Ġ{ Ġit . add ( Secure Hash . zero Hash ) Ġ}). has Size ( 2 ) ĊĠĠĠĠĠĠĠ ĠassertThat (( builder . output States () Ġas ĠArrayList ). also Ġ{ Ġit . add ( Transaction State ( Dummy State (), ĠDummy Contract . PROGRAM _ ID , Ġnot ary )) Ġ}). has Size ( 2 ) ĊĠĠĠĠĠĠĠ ĠassertThat (( builder . commands () Ġas ĠArrayList ). also Ġ{ Ġit . add ( Command ( Dummy Command Data , Ġnot ary . own ing Key )) Ġ}). has Size ( 2 ) ĊĠĠĠĠĠĠĠ ĠassertThat (( builder . reference States () Ġas ĠArrayList ). also Ġ{ Ġit . add ( reference State Ref 2 ) Ġ}). has Size ( 2 ) ĊĊĠĠĠĠĠĠĠ Ġ// ĠList Ġaccessors Ġare Ġcopies . ĊĠĠĠĠĠĠĠ ĠassertThat ( builder . input States ()). has Size ( 1 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( builder . attachments ()). has Size ( 1 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( builder . output States ()). has Size ( 1 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( builder . commands ()). has Size ( 1 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( builder . reference States ()). has Size ( 1 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( timeout = 3 0 0 _ 0 0 0 ) ĊĠĠĠ Ġfun Ġ` copy Ġmakes Ġcopy Ġexcept Ġlock Id `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġinput State Ġ= ĠTransaction State ( Dummy State (), ĠDummy Contract . PROGRAM _ ID , Ġnot ary ) ĊĠĠĠĠĠĠĠ Ġval Ġinput State Ref Ġ= ĠState Ref ( Secure Hash . random SHA 2 5 6 (), Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġval Ġreference State Ġ= ĠTransaction State ( Dummy State (), ĠDummy Contract . PROGRAM _ ID , Ġnot ary ) ĊĠĠĠĠĠĠĠ Ġval Ġreference State Ref Ġ= ĠState Ref ( Secure Hash . random SHA 2 5 6 (), Ġ 1 ) ĊĠĠĠĠĠĠĠ Ġval Ġtime Window Ġ= ĠTime Window . until Only ( Instant . now ()) ĊĠĠĠĠĠĠĠ Ġval Ġbuilder Ġ= ĠTransaction Builder ( not ary ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Input State ( State And Ref ( input State , Ġinput State Ref )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Attachment ( Secure Hash . all On es Hash ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Output State ( Transaction State ( Dummy State (), ĠDummy Contract . PROGRAM _ ID , Ġnot ary )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Command ( Dummy Command Data , Ġnot ary . own ing Key ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. setTime Window ( time Window ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Privacy Salt ( Privacy Salt ()) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Reference State ( State And Ref ( reference State , Ġreference State Ref ). referenced ()) ĊĠĠĠĠĠĠĠ Ġval Ġcopy Ġ= Ġbuilder . copy () ĊĊĠĠĠĠĠĠĠ ĠassertThat ( builder . not ary ). isEqualTo ( copy . not ary ) ĊĠĠĠĠĠĠĠ ĠassertThat ( builder . lock Id ). isNot EqualTo ( copy . lock Id ) ĊĠĠĠĠĠĠĠ ĠassertThat ( builder . input States ()). isEqualTo ( copy . input States ()) ĊĠĠĠĠĠĠĠ ĠassertThat ( builder . attachments ()). isEqualTo ( copy . attachments ()) ĊĠĠĠĠĠĠĠ ĠassertThat ( builder . output States ()). isEqualTo ( copy . output States ()) ĊĠĠĠĠĠĠĠ ĠassertThat ( builder . commands ()). isEqualTo ( copy . commands ()) Ċ // ĠĠĠĠĠĠĠ ĠassertThat ( builder . time Window ()). isEqualTo ( copy . time Window ()) Ċ // ĠĠĠĠĠĠĠ ĠassertThat ( builder . privacy Salt ()). isEqualTo ( copy . privacy Salt ()) ĊĠĠĠĠĠĠĠ ĠassertThat ( builder . reference States ()). isEqualTo ( copy . reference States ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( timeout = 3 0 0 _ 0 0 0 ) ĊĠĠĠ Ġfun Ġ` copy Ġmakes Ġdeep Ġcopy Ġof Ġlists `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġinput State 1 Ġ= ĠTransaction State ( Dummy State (), ĠDummy Contract . PROGRAM _ ID , Ġnot ary ) ĊĠĠĠĠĠĠĠ Ġval Ġinput State Ref 1 Ġ= ĠState Ref ( Secure Hash . random SHA 2 5 6 (), Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġval Ġreference State 1 Ġ= ĠTransaction State ( Dummy State (), ĠDummy Contract . PROGRAM _ ID , Ġnot ary ) ĊĠĠĠĠĠĠĠ Ġval Ġreference State Ref 1 Ġ= ĠState Ref ( Secure Hash . random SHA 2 5 6 (), Ġ 1 ) ĊĠĠĠĠĠĠĠ Ġval Ġbuilder Ġ= ĠTransaction Builder ( not ary ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Input State ( State And Ref ( input State 1 , Ġinput State Ref 1 )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Attachment ( Secure Hash . all On es Hash ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Output State ( Transaction State ( Dummy State (), ĠDummy Contract . PROGRAM _ ID , Ġnot ary )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Command ( Dummy Command Data , Ġnot ary . own ing Key ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Reference State ( State And Ref ( reference State 1 , Ġreference State Ref 1 ). referenced ()) ĊĠĠĠĠĠĠĠ Ġval Ġinput State 2 Ġ= ĠTransaction State ( Dummy State (), ĠDummy Contract . PROGRAM _ ID , Ġnot ary ) ĊĠĠĠĠĠĠĠ Ġval Ġinput State Ref 2 Ġ= ĠState Ref ( Secure Hash . random SHA 2 5 6 (), Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġval Ġreference State 2 Ġ= ĠTransaction State ( Dummy State (), ĠDummy Contract . PROGRAM _ ID , Ġnot ary ) ĊĠĠĠĠĠĠĠ Ġval Ġreference State Ref 2 Ġ= ĠState Ref ( Secure Hash . random SHA 2 5 6 (), Ġ 1 ) ĊĠĠĠĠĠĠĠ Ġval Ġcopy Ġ= Ġbuilder . copy () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Input State ( State And Ref ( input State 2 , Ġinput State Ref 2 )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Attachment ( Secure Hash . zero Hash ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Output State ( Transaction State ( Dummy State (), ĠDummy Contract . PROGRAM _ ID , Ġnot ary )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Command ( Dummy Command Data , Ġnot ary . own ing Key ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Reference State ( State And Ref ( reference State 2 , Ġreference State Ref 2 ). referenced ()) ĊĊĠĠĠĠĠĠĠ Ġ// ĠLists Ġon Ġthe Ġcopy Ġare Ġlonger ĊĠĠĠĠĠĠĠ ĠassertThat ( copy . input States ()). has Size ( 2 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( copy . attachments ()). has Size ( 2 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( copy . output States ()). has Size ( 2 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( copy . commands ()). has Size ( 2 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( copy . reference States ()). has Size ( 2 ) ĊĊĠĠĠĠĠĠĠ Ġ// ĠLists Ġon Ġthe Ġoriginal Ġare Ġunchanged ĊĠĠĠĠĠĠĠ ĠassertThat ( builder . input States ()). has Size ( 1 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( builder . attachments ()). has Size ( 1 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( builder . output States ()). has Size ( 1 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( builder . commands ()). has Size ( 1 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( builder . reference States ()). has Size ( 1 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Ignore ĊĠĠĠ Ġ@ Test ( timeout = 3 0 0 _ 0 0 0 , Ġexpected Ġ= ĠTransaction Verification Exception . Unsupported Hash Type Exception :: class ) ĊĠĠĠ Ġfun Ġ` throws Ġwith Ġnon - default Ġhash Ġalgorithm `() Ġ{ ĊĠĠĠĠĠĠĠ ĠHash Ag ility . init () ĊĠĠĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġoutput State Ġ= ĠTransaction State ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġdata Ġ= ĠDummy State (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcontract Ġ= ĠDummy Contract . PROGRAM _ ID , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġnot ary Ġ= Ġnot ary , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġconstraint Ġ= ĠHash Attachment Constraint ( contract Attachment Id ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġbuilder Ġ= ĠTransaction Builder ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ// privacy Salt Ġ= ĠDigest Service . sha 2 _ 3 8 4 . privacy Salt , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprivacy Salt Ġ= ĠPrivacy Salt . create For ( Digest Service . sha 2 _ 3 8 4 . hash Algorithm )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Output State ( output State ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Command ( Dummy Command Data , Ġnot ary . own ing Key ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġbuilder . to Wire Transaction ( services ) ĊĠĠĠĠĠĠĠ Ġ} Ġfinally Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠHash Ag ility . init () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( timeout = 3 0 0 _ 0 0 0 , Ġexpected Ġ= ĠTest . None :: class ) ĊĠĠĠ Ġfun Ġ` allows Ġnon - default Ġhash Ġalgorithm `() Ġ{ ĊĠĠĠĠĠĠĠ ĠHash Ag ility . init ( tx Hash Algo Name Ġ= ĠDigest Service . sha 2 _ 3 8 4 . hash Algorithm ) ĊĠĠĠĠĠĠĠ ĠassertThat ( services . digest Service ). isEqualTo ( Digest Service . sha 2 _ 3 8 4 ) ĊĠĠĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġoutput State Ġ= ĠTransaction State ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġdata Ġ= ĠDummy State (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcontract Ġ= ĠDummy Contract . PROGRAM _ ID , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġnot ary Ġ= Ġnot ary , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġconstraint Ġ= ĠHash Attachment Constraint ( contract Attachment Id ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġbuilder Ġ= ĠTransaction Builder ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ// privacy Salt Ġ= ĠDigest Service . sha 2 _ 3 8 4 . privacy Salt , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprivacy Salt Ġ= ĠPrivacy Salt . create For ( Digest Service . sha 2 _ 3 8 4 . hash Algorithm )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Output State ( output State ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Command ( Dummy Command Data , Ġnot ary . own ing Key ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( builder . to Wire Transaction ( services ). digest Service ). isEqualTo ( Digest Service . sha 2 _ 3 8 4 ) ĊĠĠĠĠĠĠĠ Ġ} Ġfinally Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠHash Ag ility . init () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( timeout = 3 0 0 _ 0 0 0 ) ĊĠĠĠ Ġfun Ġ` to Wire Transaction Ġfails Ġif Ġno Ġscheme Ġis Ġregistered Ġwith Ġscheme Id `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġoutput State Ġ= ĠTransaction State ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġdata Ġ= ĠDummy State (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcontract Ġ= ĠDummy Contract . PROGRAM _ ID , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġnot ary Ġ= Ġnot ary , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġconstraint Ġ= ĠHash Attachment Constraint ( contract Attachment Id ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġbuilder Ġ= ĠTransaction Builder () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Output State ( output State ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Command ( Dummy Command Data , Ġnot ary . own ing Key ) ĊĊĠĠĠĠĠĠĠ Ġval Ġscheme Id Ġ= Ġ 7 ĊĠĠĠĠĠĠĠ Ġassert Fails With < Unsupported OperationException >(" Could Ġnot Ġfind Ġcustom Ġserialization Ġscheme Ġwith ĠScheme Id Ġ= Ġ$ scheme Id .") Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbuilder . to Wire Transaction ( services , Ġscheme Id ) ĊĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ