@@ -135,6 +135,7 @@ impl DbInitializerReal {
135135 Self :: create_config_table ( conn) ;
136136 Self :: initialize_config ( conn, external_params) ;
137137 Self :: create_payable_table ( conn) ;
138+ Self :: create_sent_payable_table ( conn) ;
138139 Self :: create_pending_payable_table ( conn) ;
139140 Self :: create_receivable_table ( conn) ;
140141 Self :: create_banned_table ( conn) ;
@@ -258,6 +259,31 @@ impl DbInitializerReal {
258259 Self :: set_config_value ( conn, "max_block_count" , None , false , "maximum block count" ) ;
259260 }
260261
262+ pub fn create_sent_payable_table ( conn : & Connection ) {
263+ conn. execute (
264+ "create table if not exists sent_payable (
265+ rowid integer primary key,
266+ tx_hash text not null,
267+ receiver_address text not null,
268+ amount_high_b integer not null,
269+ amount_low_b integer not null,
270+ timestamp integer not null,
271+ gas_price_wei integer not null,
272+ nonce integer not null,
273+ status text not null,
274+ retried integer not null
275+ )" ,
276+ [ ] ,
277+ )
278+ . expect ( "Can't create sent_payable table" ) ;
279+
280+ conn. execute (
281+ "CREATE UNIQUE INDEX sent_payable_tx_hash_idx ON sent_payable (tx_hash)" ,
282+ [ ] ,
283+ )
284+ . expect ( "Can't create transaction hash index in sent payments" ) ;
285+ }
286+
261287 pub fn create_pending_payable_table ( conn : & Connection ) {
262288 conn. execute (
263289 "create table if not exists pending_payable (
@@ -621,6 +647,7 @@ impl Debug for DbInitializationConfig {
621647mod tests {
622648 use super :: * ;
623649 use crate :: database:: db_initializer:: InitializationError :: SqliteError ;
650+ use crate :: database:: test_utils:: SQL_ATTRIBUTES_FOR_CREATING_SENT_PAYABLE ;
624651 use crate :: db_config:: config_dao:: { ConfigDao , ConfigDaoReal } ;
625652 use crate :: test_utils:: database_utils:: {
626653 assert_create_table_stm_contains_all_parts,
@@ -652,7 +679,7 @@ mod tests {
652679 #[ test]
653680 fn constants_have_correct_values ( ) {
654681 assert_eq ! ( DATABASE_FILE , "node-data.db" ) ;
655- assert_eq ! ( CURRENT_SCHEMA_VERSION , 10 ) ;
682+ assert_eq ! ( CURRENT_SCHEMA_VERSION , 11 ) ;
656683 }
657684
658685 #[ test]
@@ -713,6 +740,34 @@ mod tests {
713740 )
714741 }
715742
743+ #[ test]
744+ fn db_initialize_creates_sent_payable_table ( ) {
745+ let home_dir = ensure_node_home_directory_does_not_exist (
746+ "db_initializer" ,
747+ "db_initialize_creates_sent_payable_table" ,
748+ ) ;
749+ let subject = DbInitializerReal :: default ( ) ;
750+
751+ let conn = subject
752+ . initialize ( & home_dir, DbInitializationConfig :: test_default ( ) )
753+ . unwrap ( ) ;
754+
755+ let mut stmt = conn. prepare ( "select rowid, tx_hash, receiver_address, amount_high_b, amount_low_b, timestamp, gas_price_wei, nonce, status, retried from sent_payable" ) . unwrap ( ) ;
756+ let mut sent_payable_contents = stmt. query_map ( [ ] , |_| Ok ( 42 ) ) . unwrap ( ) ;
757+ assert ! ( sent_payable_contents. next( ) . is_none( ) ) ;
758+ assert_create_table_stm_contains_all_parts (
759+ & * conn,
760+ "sent_payable" ,
761+ SQL_ATTRIBUTES_FOR_CREATING_SENT_PAYABLE ,
762+ ) ;
763+ let expected_key_words: & [ & [ & str ] ] = & [ & [ "tx_hash" ] ] ;
764+ assert_index_stm_is_coupled_with_right_parameter (
765+ conn. as_ref ( ) ,
766+ "sent_payable_tx_hash_idx" ,
767+ expected_key_words,
768+ )
769+ }
770+
716771 #[ test]
717772 fn db_initialize_creates_payable_table ( ) {
718773 let home_dir = ensure_node_home_directory_does_not_exist (
0 commit comments