@@ -22,120 +22,76 @@ pub mod temp_db {
2222 }
2323}
2424
25- pub fn finalized_block_zero ( header : Header ) -> MadaraMaybePendingBlock {
26- let transactions = vec ! [
25+ #[ rstest:: fixture]
26+ fn transactions ( ) -> Vec < mp_transactions:: Transaction > {
27+ vec ! [
2728 InvokeTransactionV0 :: default ( ) . into( ) ,
2829 L1HandlerTransaction :: default ( ) . into( ) ,
2930 DeclareTransactionV0 :: default ( ) . into( ) ,
3031 DeployTransaction :: default ( ) . into( ) ,
3132 DeployAccountTransactionV1 :: default ( ) . into( ) ,
32- ] ;
33-
34- let transaction_receipts = vec ! [
35- InvokeTransactionReceipt :: default ( ) . into( ) ,
36- L1HandlerTransactionReceipt :: default ( ) . into( ) ,
37- DeclareTransactionReceipt :: default ( ) . into( ) ,
38- DeployTransactionReceipt :: default ( ) . into( ) ,
39- DeployAccountTransactionReceipt :: default ( ) . into( ) ,
40- ] ;
41-
42- let block_inner = MadaraBlockInner :: new ( transactions, transaction_receipts) ;
43-
44- let tx_hashes = vec ! [ Felt :: from( 0 ) , Felt :: from( 1 ) , Felt :: from( 2 ) , Felt :: from( 3 ) , Felt :: from( 4 ) ] ;
45- let block_info = MadaraBlockInfo :: new ( header, tx_hashes, felt ! ( "0x12345" ) ) ;
46-
47- MadaraMaybePendingBlock { info : block_info. into ( ) , inner : block_inner }
48- }
49-
50- pub fn finalized_state_diff_zero ( ) -> StateDiff {
51- StateDiff :: default ( )
33+ ]
5234}
5335
54- pub fn finalized_block_one ( ) -> MadaraMaybePendingBlock {
55- let transactions = vec ! [
56- InvokeTransactionV1 :: default ( ) . into( ) ,
57- L1HandlerTransaction :: default ( ) . into( ) ,
58- DeclareTransactionV1 :: default ( ) . into( ) ,
59- DeployTransaction :: default ( ) . into( ) ,
60- DeployAccountTransactionV3 :: default ( ) . into( ) ,
61- ] ;
62-
63- let transaction_receipts = vec ! [
36+ #[ rstest:: fixture]
37+ fn transaction_receipts ( ) -> Vec < mp_receipt:: TransactionReceipt > {
38+ vec ! [
6439 InvokeTransactionReceipt :: default ( ) . into( ) ,
6540 L1HandlerTransactionReceipt :: default ( ) . into( ) ,
6641 DeclareTransactionReceipt :: default ( ) . into( ) ,
6742 DeployTransactionReceipt :: default ( ) . into( ) ,
6843 DeployAccountTransactionReceipt :: default ( ) . into( ) ,
69- ] ;
70-
71- let block_inner = MadaraBlockInner :: new ( transactions, transaction_receipts) ;
72-
73- let tx_hashes = vec ! [ Felt :: from( 10 ) , Felt :: from( 11 ) , Felt :: from( 12 ) , Felt :: from( 13 ) , Felt :: from( 14 ) ] ;
74- let header = Header { block_number : 1 , ..Default :: default ( ) } ;
75- let block_info = MadaraBlockInfo :: new ( header, tx_hashes, Felt :: from ( 1 ) ) ;
76-
77- MadaraMaybePendingBlock { info : block_info. into ( ) , inner : block_inner }
78- }
79-
80- pub fn finalized_state_diff_one ( ) -> StateDiff {
81- StateDiff :: default ( )
44+ ]
8245}
8346
84- pub fn pending_block_one ( ) -> MadaraMaybePendingBlock {
85- let transactions = vec ! [
86- InvokeTransactionV3 :: default ( ) . into( ) ,
87- L1HandlerTransaction :: default ( ) . into( ) ,
88- DeclareTransactionV2 :: default ( ) . into( ) ,
89- DeployTransaction :: default ( ) . into( ) ,
90- DeployAccountTransactionV3 :: default ( ) . into( ) ,
91- ] ;
92-
93- let transaction_receipts = vec ! [
94- InvokeTransactionReceipt :: default ( ) . into( ) ,
95- L1HandlerTransactionReceipt :: default ( ) . into( ) ,
96- DeclareTransactionReceipt :: default ( ) . into( ) ,
97- DeployTransactionReceipt :: default ( ) . into( ) ,
98- DeployAccountTransactionReceipt :: default ( ) . into( ) ,
99- ] ;
100-
47+ #[ rstest:: fixture]
48+ pub fn block (
49+ #[ default( 0 ) ] block_number : u64 ,
50+ transactions : Vec < mp_transactions:: Transaction > ,
51+ transaction_receipts : Vec < mp_receipt:: TransactionReceipt > ,
52+ ) -> MadaraMaybePendingBlock {
53+ let block_i = block_number * 10 ;
10154 let block_inner = MadaraBlockInner :: new ( transactions, transaction_receipts) ;
102-
103- let tx_hashes = vec ! [ Felt :: from( 20 ) , Felt :: from( 21 ) , Felt :: from( 22 ) , Felt :: from( 23 ) , Felt :: from( 24 ) ] ;
104- let block_info = MadaraPendingBlockInfo :: new ( PendingHeader :: default ( ) , tx_hashes) ;
55+ let tx_hashes = vec ! [
56+ Felt :: from( block_i) ,
57+ Felt :: from( block_i + 1 ) ,
58+ Felt :: from( block_i + 2 ) ,
59+ Felt :: from( block_i + 3 ) ,
60+ Felt :: from( block_i + 4 ) ,
61+ ] ;
62+ let header = Header { block_number, ..Default :: default ( ) } ;
63+ let block_info = MadaraBlockInfo :: new ( header, tx_hashes, felt ! ( "0x12345" ) ) ;
10564
10665 MadaraMaybePendingBlock { info : block_info. into ( ) , inner : block_inner }
10766}
10867
109- pub fn pending_state_diff_one ( ) -> StateDiff {
68+ #[ rstest:: fixture]
69+ pub fn state_diff ( ) -> StateDiff {
11070 StateDiff :: default ( )
11171}
11272
113- pub fn pending_block_two ( ) -> MadaraMaybePendingBlock {
114- let transactions = vec ! [
115- InvokeTransactionV3 :: default ( ) . into( ) ,
116- L1HandlerTransaction :: default ( ) . into( ) ,
117- DeclareTransactionV2 :: default ( ) . into( ) ,
118- DeployTransaction :: default ( ) . into( ) ,
119- DeployAccountTransactionV3 :: default ( ) . into( ) ,
120- ] ;
121-
122- let transaction_receipts = vec ! [
123- InvokeTransactionReceipt :: default ( ) . into( ) ,
124- L1HandlerTransactionReceipt :: default ( ) . into( ) ,
125- DeclareTransactionReceipt :: default ( ) . into( ) ,
126- DeployTransactionReceipt :: default ( ) . into( ) ,
127- DeployAccountTransactionReceipt :: default ( ) . into( ) ,
128- ] ;
129-
73+ #[ rstest:: fixture]
74+ pub fn block_pending (
75+ #[ allow( unused) ]
76+ #[ default( 0 ) ]
77+ parent_block_n : u64 ,
78+ #[ from( block) ]
79+ #[ with( parent_block_n) ]
80+ parent : MadaraMaybePendingBlock ,
81+ transactions : Vec < mp_transactions:: Transaction > ,
82+ transaction_receipts : Vec < mp_receipt:: TransactionReceipt > ,
83+ ) -> MadaraMaybePendingBlock {
13084 let block_inner = MadaraBlockInner :: new ( transactions, transaction_receipts) ;
13185
13286 let tx_hashes = vec ! [ Felt :: from( 20 ) , Felt :: from( 21 ) , Felt :: from( 22 ) , Felt :: from( 23 ) , Felt :: from( 24 ) ] ;
133- let header = PendingHeader { parent_block_hash : Felt :: from ( 1 ) , ..Default :: default ( ) } ;
134- let block_info = MadaraPendingBlockInfo :: new ( header, tx_hashes) ;
87+ let block_info = MadaraPendingBlockInfo :: new (
88+ PendingHeader {
89+ parent_block_hash : parent. info . block_hash ( ) . unwrap ( ) ,
90+ parent_block_number : parent. info . block_n ( ) ,
91+ ..Default :: default ( )
92+ } ,
93+ tx_hashes,
94+ ) ;
13595
13696 MadaraMaybePendingBlock { info : block_info. into ( ) , inner : block_inner }
13797}
138-
139- pub fn pending_state_diff_two ( ) -> StateDiff {
140- StateDiff :: default ( )
141- }
0 commit comments