@ -28,10 +28,6 @@ static void db_log_(struct log *log UNUSED, enum log_level level UNUSED, const c
bool deprecated_apis = true ;
bool deprecated_apis = true ;
/* AUTOGENERATED MOCKS START */
/* AUTOGENERATED MOCKS START */
/* Generated stub for bip32_pubkey */
bool bip32_pubkey ( const struct ext_key * bip32_base UNNEEDED ,
struct pubkey * pubkey UNNEEDED , u32 index UNNEEDED )
{ fprintf ( stderr , " bip32_pubkey called! \n " ) ; abort ( ) ; }
/* Generated stub for bitcoind_gettxout */
/* Generated stub for bitcoind_gettxout */
void bitcoind_gettxout ( struct bitcoind * bitcoind UNNEEDED ,
void bitcoind_gettxout ( struct bitcoind * bitcoind UNNEEDED ,
const struct bitcoin_txid * txid UNNEEDED , const u32 outnum UNNEEDED ,
const struct bitcoin_txid * txid UNNEEDED , const u32 outnum UNNEEDED ,
@ -332,7 +328,7 @@ u8 *towire_channel_funding_announce_depth(const tal_t *ctx UNNEEDED)
u8 * towire_channel_funding_locked ( const tal_t * ctx UNNEEDED , const struct short_channel_id * short_channel_id UNNEEDED )
u8 * towire_channel_funding_locked ( const tal_t * ctx UNNEEDED , const struct short_channel_id * short_channel_id UNNEEDED )
{ fprintf ( stderr , " towire_channel_funding_locked called! \n " ) ; abort ( ) ; }
{ fprintf ( stderr , " towire_channel_funding_locked called! \n " ) ; abort ( ) ; }
/* Generated stub for towire_channel_send_shutdown */
/* Generated stub for towire_channel_send_shutdown */
u8 * towire_channel_send_shutdown ( const tal_t * ctx UNNEEDED , const u8 * scriptpubkey UNNEEDED )
u8 * towire_channel_send_shutdown ( const tal_t * ctx UNNEEDED )
{ fprintf ( stderr , " towire_channel_send_shutdown called! \n " ) ; abort ( ) ; }
{ fprintf ( stderr , " towire_channel_send_shutdown called! \n " ) ; abort ( ) ; }
/* Generated stub for towire_error */
/* Generated stub for towire_error */
u8 * towire_error ( const tal_t * ctx UNNEEDED , const struct channel_id * channel_id UNNEEDED , const u8 * data UNNEEDED )
u8 * towire_error ( const tal_t * ctx UNNEEDED , const struct channel_id * channel_id UNNEEDED , const u8 * data UNNEEDED )
@ -360,9 +356,6 @@ u8 *towire_gossip_disable_channel(const tal_t *ctx UNNEEDED, const struct short_
/* Generated stub for towire_gossip_getpeers_request */
/* Generated stub for towire_gossip_getpeers_request */
u8 * towire_gossip_getpeers_request ( const tal_t * ctx UNNEEDED , const struct pubkey * id UNNEEDED )
u8 * towire_gossip_getpeers_request ( const tal_t * ctx UNNEEDED , const struct pubkey * id UNNEEDED )
{ fprintf ( stderr , " towire_gossip_getpeers_request called! \n " ) ; abort ( ) ; }
{ fprintf ( stderr , " towire_gossip_getpeers_request called! \n " ) ; abort ( ) ; }
/* Generated stub for txfilter_add_scriptpubkey */
void txfilter_add_scriptpubkey ( struct txfilter * filter UNNEEDED , const u8 * script TAKES UNNEEDED )
{ fprintf ( stderr , " txfilter_add_scriptpubkey called! \n " ) ; abort ( ) ; }
/* Generated stub for unsupported_features */
/* Generated stub for unsupported_features */
bool unsupported_features ( const u8 * gfeatures UNNEEDED , const u8 * lfeatures UNNEEDED )
bool unsupported_features ( const u8 * gfeatures UNNEEDED , const u8 * lfeatures UNNEEDED )
{ fprintf ( stderr , " unsupported_features called! \n " ) ; abort ( ) ; }
{ fprintf ( stderr , " unsupported_features called! \n " ) ; abort ( ) ; }
@ -445,6 +438,12 @@ const char *log_prefix(const struct log *log UNNEEDED)
return " " ;
return " " ;
}
}
void txfilter_add_scriptpubkey ( struct txfilter * filter UNNEEDED , const u8 * script TAKES )
{
if ( taken ( script ) )
tal_free ( script ) ;
}
/**
/**
* mempat - - Set the memory to a pattern
* mempat - - Set the memory to a pattern
*
*
@ -464,6 +463,7 @@ static struct wallet *create_test_wallet(struct lightningd *ld, const tal_t *ctx
char filename [ ] = " /tmp/ldb-XXXXXX " ;
char filename [ ] = " /tmp/ldb-XXXXXX " ;
int fd = mkstemp ( filename ) ;
int fd = mkstemp ( filename ) ;
struct wallet * w = tal ( ctx , struct wallet ) ;
struct wallet * w = tal ( ctx , struct wallet ) ;
static unsigned char badseed [ BIP32_ENTROPY_LEN_128 ] ;
CHECK_MSG ( fd ! = - 1 , " Unable to generate temp filename " ) ;
CHECK_MSG ( fd ! = - 1 , " Unable to generate temp filename " ) ;
close ( fd ) ;
close ( fd ) ;
@ -472,6 +472,12 @@ static struct wallet *create_test_wallet(struct lightningd *ld, const tal_t *ctx
ltmp = tal_tmpctx ( ctx ) ;
ltmp = tal_tmpctx ( ctx ) ;
list_head_init ( & w - > unstored_payments ) ;
list_head_init ( & w - > unstored_payments ) ;
w - > ld = ld ;
w - > ld = ld ;
ld - > wallet = w ;
w - > bip32_base = tal ( w , struct ext_key ) ;
CHECK ( bip32_key_from_seed ( badseed , sizeof ( badseed ) ,
BIP32_VER_TEST_PRIVATE , 0 ,
w - > bip32_base ) = = WALLY_OK ) ;
CHECK_MSG ( w - > db , " Failed opening the db " ) ;
CHECK_MSG ( w - > db , " Failed opening the db " ) ;
db_migrate ( w - > db , w - > log ) ;
db_migrate ( w - > db , w - > log ) ;
@ -668,10 +674,11 @@ static bool channelseq(struct channel *c1, struct channel *c2)
CHECK ( memeq ( & c1 - > last_sig , sizeof ( c1 - > last_sig ) ,
CHECK ( memeq ( & c1 - > last_sig , sizeof ( c1 - > last_sig ) ,
& c2 - > last_sig , sizeof ( c2 - > last_sig ) ) ) ;
& c2 - > last_sig , sizeof ( c2 - > last_sig ) ) ) ;
if ( c1 - > remote_shutdown_scriptpubkey ) {
CHECK ( c1 - > final_key_idx = = c2 - > final_key_idx ) ;
CHECK ( c2 - > remote_shutdown_scriptpubkey ) ;
CHECK ( memeq ( c1 - > remote_shutdown_scriptpubkey ,
CHECK ( c1 - > local_shutdown_idx = = c2 - > local_shutdown_idx ) ;
tal_len ( c1 - > remote_shutdown_scriptpubkey ) ,
}
c2 - > remote_shutdown_scriptpubkey ,
tal_len ( c2 - > remote_shutdown_scriptpubkey ) ) ) ;
CHECK ( c1 - > last_was_revoke = = c2 - > last_was_revoke ) ;
CHECK ( c1 - > last_was_revoke = = c2 - > last_was_revoke ) ;
@ -717,6 +724,7 @@ static bool test_channel_crud(struct lightningd *ld, const tal_t *ctx)
ci - > feerate_per_kw [ LOCAL ] = ci - > feerate_per_kw [ REMOTE ] = 31337 ;
ci - > feerate_per_kw [ LOCAL ] = ci - > feerate_per_kw [ REMOTE ] = 31337 ;
mempat ( scriptpubkey , tal_len ( scriptpubkey ) ) ;
mempat ( scriptpubkey , tal_len ( scriptpubkey ) ) ;
c1 . first_blocknum = 1 ;
c1 . first_blocknum = 1 ;
c1 . final_key_idx = 1337 ;
p = new_peer ( ld , 0 , & pk , NULL ) ;
p = new_peer ( ld , 0 , & pk , NULL ) ;
c1 . peer = p ;
c1 . peer = p ;
c1 . dbid = wallet_get_channel_dbid ( w ) ;
c1 . dbid = wallet_get_channel_dbid ( w ) ;
@ -782,7 +790,6 @@ static bool test_channel_crud(struct lightningd *ld, const tal_t *ctx)
/* Variant 4: update and add remote_shutdown_scriptpubkey */
/* Variant 4: update and add remote_shutdown_scriptpubkey */
c1 . remote_shutdown_scriptpubkey = scriptpubkey ;
c1 . remote_shutdown_scriptpubkey = scriptpubkey ;
c1 . local_shutdown_idx = 1337 ;
wallet_channel_save ( w , & c1 ) ;
wallet_channel_save ( w , & c1 ) ;
CHECK_MSG ( ! wallet_err , tal_fmt ( w , " Insert into DB: %s " , wallet_err ) ) ;
CHECK_MSG ( ! wallet_err , tal_fmt ( w , " Insert into DB: %s " , wallet_err ) ) ;
CHECK_MSG ( c2 = wallet_channel_load ( w , c1 . dbid ) , tal_fmt ( w , " Load from DB " ) ) ;
CHECK_MSG ( c2 = wallet_channel_load ( w , c1 . dbid ) , tal_fmt ( w , " Load from DB " ) ) ;
@ -972,6 +979,13 @@ int main(void)
ok & = test_htlc_crud ( ld , tmpctx ) ;
ok & = test_htlc_crud ( ld , tmpctx ) ;
ok & = test_payment_crud ( ld , tmpctx ) ;
ok & = test_payment_crud ( ld , tmpctx ) ;
take_cleanup ( ) ;
tal_free ( tmpctx ) ;
tal_free ( tmpctx ) ;
/* FIXME! https://github.com/ElementsProject/libwally-core/issues/26 */
{
secp256k1_context * secp_ctx ( void ) ;
secp256k1_context_destroy ( secp_ctx ( ) ) ;
}
return ! ok ;
return ! ok ;
}
}