package Ġnet . cord a . node api . internal Ċ Ċ import Ġnet . cord a . core . crypto . Crypto Ċ import Ġnet . cord a . testing . core . AL ICE _ NAME Ċ import Ġnet . cord a . testing . core . BO B _ NAME Ċ import Ġnet . cord a . testing . core . Serialization Environment Rule Ċ import Ġnet . cord a . testing . internal . Test NodeInfo Builder Ċ import Ġnet . cord a . testing . internal . sign With Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . assertj . core . api . Assertions . assertThat Thrown By Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġjava . security . Signature Exception Ċ Ċ class ĠSigned NodeInfo Test Ġ{ ĊĠĠĠ Ġ@ Rule ĊĠĠĠ Ġ@ Jvm Field ĊĠĠĠ Ġval Ġtest Serialization Ġ= ĠSerialization Environment Rule () ĊĊĠĠĠ Ġprivate Ġval Ġnode Info Builder Ġ= ĠTest NodeInfo Builder () ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` verify ing Ġsingle Ġidentity `() Ġ{ ĊĠĠĠĠĠĠĠ Ġnode Info Builder . add Identity ( AL ICE _ NAME ) ĊĠĠĠĠĠĠĠ Ġval Ġ( node Info , Ġsigned NodeInfo ) Ġ= Ġnode Info Builder . build With Signed () ĊĠĠĠĠĠĠĠ ĠassertThat ( signed NodeInfo . verified ()). isEqualTo ( node Info ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` verify ing Ġmultiple Ġident ities `() Ġ{ ĊĠĠĠĠĠĠĠ Ġnode Info Builder . add Identity ( AL ICE _ NAME ) ĊĠĠĠĠĠĠĠ Ġnode Info Builder . add Identity ( BO B _ NAME ) ĊĠĠĠĠĠĠĠ Ġval Ġ( node Info , Ġsigned NodeInfo ) Ġ= Ġnode Info Builder . build With Signed () ĊĠĠĠĠĠĠĠ ĠassertThat ( signed NodeInfo . verified ()). isEqualTo ( node Info ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` verify ing Ġmissing Ġsignature `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ(_, Ġalice Key ) Ġ= Ġnode Info Builder . add Identity ( AL ICE _ NAME ) ĊĠĠĠĠĠĠĠ Ġnode Info Builder . add Identity ( BO B _ NAME ) ĊĠĠĠĠĠĠĠ Ġval Ġnode Info Ġ= Ġnode Info Builder . build () ĊĠĠĠĠĠĠĠ Ġval Ġsigned NodeInfo Ġ= Ġnode Info . sign With ( listOf ( alice Key )) ĊĠĠĠĠĠĠĠ ĠassertThat Thrown By Ġ{ Ġsigned NodeInfo . verified () Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. isInstanceOf ( Signature Exception :: class . java ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. has Message Containing (" Missing Ġsignatures ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` verify ing Ġextra Ġsignature `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ(_, Ġalice Key ) Ġ= Ġnode Info Builder . add Identity ( AL ICE _ NAME ) ĊĠĠĠĠĠĠĠ Ġval Ġnode Info Ġ= Ġnode Info Builder . build () ĊĠĠĠĠĠĠĠ Ġval Ġsigned NodeInfo Ġ= Ġnode Info . sign With ( listOf ( alice Key , Ġgenerate KeyPair (). private )) ĊĠĠĠĠĠĠĠ ĠassertThat Thrown By Ġ{ Ġsigned NodeInfo . verified () Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. isInstanceOf ( Signature Exception :: class . java ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. has Message Containing (" Extra Ġsignatures ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` verify ing Ġincorrect Ġsignature `() Ġ{ ĊĠĠĠĠĠĠĠ Ġnode Info Builder . add Identity ( AL ICE _ NAME ) ĊĠĠĠĠĠĠĠ Ġval Ġnode Info Ġ= Ġnode Info Builder . build () ĊĠĠĠĠĠĠĠ Ġval Ġsigned NodeInfo Ġ= Ġnode Info . sign With ( listOf ( generate KeyPair (). private )) ĊĠĠĠĠĠĠĠ ĠassertThat Thrown By Ġ{ Ġsigned NodeInfo . verified () Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. isInstanceOf ( Signature Exception :: class . java ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. has Message Containing ( AL ICE _ NAME . toString ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` verify ing Ġwith Ġsignatures Ġin Ġwrong Ġorder `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ(_, Ġalice Key ) Ġ= Ġnode Info Builder . add Identity ( AL ICE _ NAME ) ĊĠĠĠĠĠĠĠ Ġval Ġ(_, Ġbob Key ) Ġ= Ġnode Info Builder . add Identity ( BO B _ NAME ) ĊĠĠĠĠĠĠĠ Ġval Ġnode Info Ġ= Ġnode Info Builder . build () ĊĠĠĠĠĠĠĠ Ġval Ġsigned NodeInfo Ġ= Ġnode Info . sign With ( listOf ( bob Key , Ġalice Key )) ĊĠĠĠĠĠĠĠ ĠassertThat Thrown By Ġ{ Ġsigned NodeInfo . verified () Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. isInstanceOf ( Signature Exception :: class . java ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. has Message Containing ( AL ICE _ NAME . toString ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġgenerate KeyPair () Ġ= ĠCrypto . generate KeyPair () Ċ } Ċ