|
@ -1,13 +1,16 @@ |
|
|
#include "../gen_peer_wire.c" |
|
|
|
|
|
|
|
|
|
|
|
#include "../towire.c" |
|
|
#include "../towire.c" |
|
|
#include "../fromwire.c" |
|
|
#include "../fromwire.c" |
|
|
#include "../peer_wire.c" |
|
|
#include "../peer_wire.c" |
|
|
|
|
|
|
|
|
#include <assert.h> |
|
|
#include <assert.h> |
|
|
#include <stdio.h> |
|
|
#include <stdio.h> |
|
|
|
|
|
|
|
|
|
|
|
#include <ccan/str/hex/hex.h> |
|
|
#include <common/amount.h> |
|
|
#include <common/amount.h> |
|
|
|
|
|
#include <common/bigsize.h> |
|
|
|
|
|
#include <bitcoin/chainparams.h> |
|
|
#include <common/sphinx.h> |
|
|
#include <common/sphinx.h> |
|
|
|
|
|
#include <wire/gen_peer_wire.h> |
|
|
|
|
|
|
|
|
secp256k1_context *secp256k1_ctx; |
|
|
secp256k1_context *secp256k1_ctx; |
|
|
|
|
|
|
|
@ -31,24 +34,6 @@ bool amount_sat_eq(struct amount_sat a UNNEEDED, struct amount_sat b UNNEEDED) |
|
|
struct amount_sat a UNNEEDED, |
|
|
struct amount_sat a UNNEEDED, |
|
|
struct amount_sat b UNNEEDED) |
|
|
struct amount_sat b UNNEEDED) |
|
|
{ fprintf(stderr, "amount_sat_sub called!\n"); abort(); } |
|
|
{ fprintf(stderr, "amount_sat_sub called!\n"); abort(); } |
|
|
/* Generated stub for bigsize_get */ |
|
|
|
|
|
size_t bigsize_get(const u8 *p UNNEEDED, size_t max UNNEEDED, bigsize_t *val UNNEEDED) |
|
|
|
|
|
{ fprintf(stderr, "bigsize_get called!\n"); abort(); } |
|
|
|
|
|
/* Generated stub for bigsize_put */ |
|
|
|
|
|
size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN] UNNEEDED, bigsize_t v UNNEEDED) |
|
|
|
|
|
{ fprintf(stderr, "bigsize_put called!\n"); abort(); } |
|
|
|
|
|
/* Generated stub for fromwire_tlvs */ |
|
|
|
|
|
bool fromwire_tlvs(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, |
|
|
|
|
|
const struct tlv_record_type types[] UNNEEDED, |
|
|
|
|
|
size_t num_types UNNEEDED, |
|
|
|
|
|
void *record UNNEEDED) |
|
|
|
|
|
{ fprintf(stderr, "fromwire_tlvs called!\n"); abort(); } |
|
|
|
|
|
/* Generated stub for towire_tlvs */ |
|
|
|
|
|
void towire_tlvs(u8 **pptr UNNEEDED, |
|
|
|
|
|
const struct tlv_record_type types[] UNNEEDED, |
|
|
|
|
|
size_t num_types UNNEEDED, |
|
|
|
|
|
const void *record UNNEEDED) |
|
|
|
|
|
{ fprintf(stderr, "towire_tlvs called!\n"); abort(); } |
|
|
|
|
|
/* AUTOGENERATED MOCKS END */ |
|
|
/* AUTOGENERATED MOCKS END */ |
|
|
|
|
|
|
|
|
/* memsetting pubkeys doesn't work */ |
|
|
/* memsetting pubkeys doesn't work */ |
|
@ -236,6 +221,7 @@ struct msg_channel_announcement { |
|
|
struct msg_init { |
|
|
struct msg_init { |
|
|
u8 *globalfeatures; |
|
|
u8 *globalfeatures; |
|
|
u8 *localfeatures; |
|
|
u8 *localfeatures; |
|
|
|
|
|
struct tlv_init_tlvs *tlvs; |
|
|
}; |
|
|
}; |
|
|
struct msg_update_add_htlc { |
|
|
struct msg_update_add_htlc { |
|
|
struct channel_id channel_id; |
|
|
struct channel_id channel_id; |
|
@ -761,16 +747,19 @@ static void *towire_struct_init(const tal_t *ctx, |
|
|
{ |
|
|
{ |
|
|
return towire_init(ctx, |
|
|
return towire_init(ctx, |
|
|
s->globalfeatures, |
|
|
s->globalfeatures, |
|
|
s->localfeatures); |
|
|
s->localfeatures, |
|
|
|
|
|
s->tlvs); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static struct msg_init *fromwire_struct_init(const tal_t *ctx, const void *p) |
|
|
static struct msg_init *fromwire_struct_init(const tal_t *ctx, const void *p) |
|
|
{ |
|
|
{ |
|
|
struct msg_init *s = tal(ctx, struct msg_init); |
|
|
struct msg_init *s = tal(ctx, struct msg_init); |
|
|
|
|
|
s->tlvs = tlv_init_tlvs_new(s); |
|
|
|
|
|
|
|
|
if (!fromwire_init(s, p, |
|
|
if (!fromwire_init(s, p, |
|
|
&s->globalfeatures, |
|
|
&s->globalfeatures, |
|
|
&s->localfeatures)) |
|
|
&s->localfeatures, |
|
|
|
|
|
s->tlvs)) |
|
|
return tal_free(s); |
|
|
return tal_free(s); |
|
|
|
|
|
|
|
|
return s; |
|
|
return s; |
|
@ -844,6 +833,9 @@ static bool error_eq(const struct msg_error *a, |
|
|
static bool init_eq(const struct msg_init *a, |
|
|
static bool init_eq(const struct msg_init *a, |
|
|
const struct msg_init *b) |
|
|
const struct msg_init *b) |
|
|
{ |
|
|
{ |
|
|
|
|
|
for (size_t i = 0; i < tal_count(a->tlvs->networks->chains); i++) |
|
|
|
|
|
assert(bitcoin_blkid_eq(&a->tlvs->networks->chains[i], |
|
|
|
|
|
&b->tlvs->networks->chains[i])); |
|
|
return eq_var(a, b, globalfeatures) |
|
|
return eq_var(a, b, globalfeatures) |
|
|
&& eq_var(a, b, localfeatures); |
|
|
&& eq_var(a, b, localfeatures); |
|
|
} |
|
|
} |
|
@ -959,6 +951,7 @@ int main(void) |
|
|
void *ctx = tal(NULL, char); |
|
|
void *ctx = tal(NULL, char); |
|
|
size_t i; |
|
|
size_t i; |
|
|
u8 *msg; |
|
|
u8 *msg; |
|
|
|
|
|
const struct chainparams **chains; |
|
|
|
|
|
|
|
|
secp256k1_ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY |
|
|
secp256k1_ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY |
|
|
| SECP256K1_CONTEXT_SIGN); |
|
|
| SECP256K1_CONTEXT_SIGN); |
|
@ -1039,16 +1032,21 @@ int main(void) |
|
|
assert(error_eq(&e, e2)); |
|
|
assert(error_eq(&e, e2)); |
|
|
test_corruption(&e, e2, error); |
|
|
test_corruption(&e, e2, error); |
|
|
|
|
|
|
|
|
|
|
|
chains = chainparams_for_networks(ctx); |
|
|
|
|
|
for (i = 0; i < tal_count(chains); i++) { |
|
|
memset(&init, 2, sizeof(init)); |
|
|
memset(&init, 2, sizeof(init)); |
|
|
init.globalfeatures = tal_arr(ctx, u8, 2); |
|
|
init.globalfeatures = tal_arr(ctx, u8, 2); |
|
|
memset(init.globalfeatures, 2, 2); |
|
|
memset(init.globalfeatures, 2, 2); |
|
|
init.localfeatures = tal_arr(ctx, u8, 2); |
|
|
init.localfeatures = tal_arr(ctx, u8, 2); |
|
|
memset(init.localfeatures, 2, 2); |
|
|
memset(init.localfeatures, 2, 2); |
|
|
|
|
|
init.tlvs = tlv_init_tlvs_new(ctx); |
|
|
|
|
|
init.tlvs->networks = tal(init.tlvs, struct tlv_init_tlvs_networks); |
|
|
|
|
|
init.tlvs->networks->chains = tal_arr(ctx, struct bitcoin_blkid, 1); |
|
|
|
|
|
init.tlvs->networks->chains[0] = chains[i]->genesis_blockhash; |
|
|
msg = towire_struct_init(ctx, &init); |
|
|
msg = towire_struct_init(ctx, &init); |
|
|
init2 = fromwire_struct_init(ctx, msg); |
|
|
init2 = fromwire_struct_init(ctx, msg); |
|
|
assert(init_eq(&init, init2)); |
|
|
assert(init_eq(&init, init2)); |
|
|
test_corruption(&init, init2, init); |
|
|
} |
|
|
|
|
|
|
|
|
memset(&uf, 2, sizeof(uf)); |
|
|
memset(&uf, 2, sizeof(uf)); |
|
|
|
|
|
|
|
|