1- #include "../gen_peer_wire.c"
2-
31#include "../towire.c"
42#include "../fromwire.c"
53#include "../peer_wire.c"
64
75#include <assert.h>
86#include <stdio.h>
7+
8+ #include <ccan/str/hex/hex.h>
99#include <common/amount.h>
10+ #include <common/bigsize.h>
11+ #include <bitcoin/chainparams.h>
1012#include <common/sphinx.h>
13+ #include <wire/gen_peer_wire.h>
1114
1215secp256k1_context * secp256k1_ctx ;
1316
@@ -31,24 +34,6 @@ bool amount_sat_eq(struct amount_sat a UNNEEDED, struct amount_sat b UNNEEDED)
3134 struct amount_sat a UNNEEDED ,
3235 struct amount_sat b UNNEEDED )
3336{ fprintf (stderr , "amount_sat_sub called!\n" ); abort (); }
34- /* Generated stub for bigsize_get */
35- size_t bigsize_get (const u8 * p UNNEEDED , size_t max UNNEEDED , bigsize_t * val UNNEEDED )
36- { fprintf (stderr , "bigsize_get called!\n" ); abort (); }
37- /* Generated stub for bigsize_put */
38- size_t bigsize_put (u8 buf [BIGSIZE_MAX_LEN ] UNNEEDED , bigsize_t v UNNEEDED )
39- { fprintf (stderr , "bigsize_put called!\n" ); abort (); }
40- /* Generated stub for fromwire_tlvs */
41- bool fromwire_tlvs (const u8 * * cursor UNNEEDED , size_t * max UNNEEDED ,
42- const struct tlv_record_type types [] UNNEEDED ,
43- size_t num_types UNNEEDED ,
44- void * record UNNEEDED )
45- { fprintf (stderr , "fromwire_tlvs called!\n" ); abort (); }
46- /* Generated stub for towire_tlvs */
47- void towire_tlvs (u8 * * pptr UNNEEDED ,
48- const struct tlv_record_type types [] UNNEEDED ,
49- size_t num_types UNNEEDED ,
50- const void * record UNNEEDED )
51- { fprintf (stderr , "towire_tlvs called!\n" ); abort (); }
5237/* AUTOGENERATED MOCKS END */
5338
5439/* memsetting pubkeys doesn't work */
@@ -236,6 +221,7 @@ struct msg_channel_announcement {
236221struct msg_init {
237222 u8 * globalfeatures ;
238223 u8 * localfeatures ;
224+ struct tlv_init_tlvs * tlvs ;
239225};
240226struct msg_update_add_htlc {
241227 struct channel_id channel_id ;
@@ -761,16 +747,19 @@ static void *towire_struct_init(const tal_t *ctx,
761747{
762748 return towire_init (ctx ,
763749 s -> globalfeatures ,
764- s -> localfeatures );
750+ s -> localfeatures ,
751+ s -> tlvs );
765752}
766753
767754static struct msg_init * fromwire_struct_init (const tal_t * ctx , const void * p )
768755{
769756 struct msg_init * s = tal (ctx , struct msg_init );
757+ s -> tlvs = tlv_init_tlvs_new (s );
770758
771759 if (!fromwire_init (s , p ,
772760 & s -> globalfeatures ,
773- & s -> localfeatures ))
761+ & s -> localfeatures ,
762+ s -> tlvs ))
774763 return tal_free (s );
775764
776765 return s ;
@@ -844,6 +833,9 @@ static bool error_eq(const struct msg_error *a,
844833static bool init_eq (const struct msg_init * a ,
845834 const struct msg_init * b )
846835{
836+ for (size_t i = 0 ; i < tal_count (a -> tlvs -> networks -> chains ); i ++ )
837+ assert (bitcoin_blkid_eq (& a -> tlvs -> networks -> chains [i ],
838+ & b -> tlvs -> networks -> chains [i ]));
847839 return eq_var (a , b , globalfeatures )
848840 && eq_var (a , b , localfeatures );
849841}
@@ -959,6 +951,7 @@ int main(void)
959951 void * ctx = tal (NULL , char );
960952 size_t i ;
961953 u8 * msg ;
954+ const struct chainparams * * chains ;
962955
963956 secp256k1_ctx = secp256k1_context_create (SECP256K1_CONTEXT_VERIFY
964957 | SECP256K1_CONTEXT_SIGN );
@@ -1039,16 +1032,21 @@ int main(void)
10391032 assert (error_eq (& e , e2 ));
10401033 test_corruption (& e , e2 , error );
10411034
1042- memset (& init , 2 , sizeof (init ));
1043- init .globalfeatures = tal_arr (ctx , u8 , 2 );
1044- memset (init .globalfeatures , 2 , 2 );
1045- init .localfeatures = tal_arr (ctx , u8 , 2 );
1046- memset (init .localfeatures , 2 , 2 );
1047-
1048- msg = towire_struct_init (ctx , & init );
1049- init2 = fromwire_struct_init (ctx , msg );
1050- assert (init_eq (& init , init2 ));
1051- test_corruption (& init , init2 , init );
1035+ chains = chainparams_for_networks (ctx );
1036+ for (i = 0 ; i < tal_count (chains ); i ++ ) {
1037+ memset (& init , 2 , sizeof (init ));
1038+ init .globalfeatures = tal_arr (ctx , u8 , 2 );
1039+ memset (init .globalfeatures , 2 , 2 );
1040+ init .localfeatures = tal_arr (ctx , u8 , 2 );
1041+ memset (init .localfeatures , 2 , 2 );
1042+ init .tlvs = tlv_init_tlvs_new (ctx );
1043+ init .tlvs -> networks = tal (init .tlvs , struct tlv_init_tlvs_networks );
1044+ init .tlvs -> networks -> chains = tal_arr (ctx , struct bitcoin_blkid , 1 );
1045+ init .tlvs -> networks -> chains [0 ] = chains [i ]-> genesis_blockhash ;
1046+ msg = towire_struct_init (ctx , & init );
1047+ init2 = fromwire_struct_init (ctx , msg );
1048+ assert (init_eq (& init , init2 ));
1049+ }
10521050
10531051 memset (& uf , 2 , sizeof (uf ));
10541052
0 commit comments