@@ -82,20 +82,28 @@ async fn can_fork() -> Result<()> {
82
82
async fn assert_get_block_methods ( provider : & impl Provider , num : BlockNumber ) -> Result < ( ) > {
83
83
let id = BlockIdOrTag :: Number ( num) ;
84
84
85
- let block = provider. get_block_with_txs ( id) . await ?;
85
+ let block =
86
+ provider. get_block_with_txs ( id) . await . context ( format ! ( "failed to get block {num}" ) ) ?;
86
87
assert_matches ! ( block, MaybePendingBlockWithTxs :: Block ( b) if b. block_number == num) ;
87
88
88
- let block = provider. get_block_with_receipts ( id) . await ?;
89
+ let block = provider
90
+ . get_block_with_receipts ( id)
91
+ . await
92
+ . context ( format ! ( "failed to get block {num} w/ receipts" ) ) ?;
89
93
assert_matches ! ( block, starknet:: core:: types:: MaybePendingBlockWithReceipts :: Block ( b) if b. block_number == num) ;
90
94
91
- let block = provider. get_block_with_tx_hashes ( id) . await ?;
95
+ let block = provider
96
+ . get_block_with_tx_hashes ( id)
97
+ . await
98
+ . context ( format ! ( "failed to get block {num} w/ hashes" ) ) ?;
92
99
assert_matches ! ( block, starknet:: core:: types:: MaybePendingBlockWithTxHashes :: Block ( b) if b. block_number == num) ;
93
100
94
101
let result = provider. get_block_transaction_count ( id) . await ;
95
102
assert ! ( result. is_ok( ) ) ;
96
103
97
- let state = provider. get_state_update ( id) . await ?;
98
- assert_matches ! ( state, starknet:: core:: types:: MaybePendingStateUpdate :: Update ( _) ) ;
104
+ // TODO: uncomment this once we include genesis forked state update
105
+ // let state = provider.get_state_update(id).await?;
106
+ // assert_matches!(state, starknet::core::types::MaybePendingStateUpdate::Update(_));
99
107
100
108
Ok ( ( ) )
101
109
}
@@ -104,19 +112,51 @@ async fn assert_get_block_methods(provider: &impl Provider, num: BlockNumber) ->
104
112
async fn forked_blocks ( ) -> Result < ( ) > {
105
113
let ( _sequencer, provider, _) = setup_test ( ) . await ;
106
114
107
- let block_num = FORK_BLOCK_NUMBER ;
115
+ // -----------------------------------------------------------------------
116
+ // Get the forked block
117
+
118
+ // https://sepolia.voyager.online/block/0x208950cfcbba73ecbda1c14e4d58d66a8d60655ea1b9dcf07c16014ae8a93cd
119
+ let block_num = FORK_BLOCK_NUMBER ; // 268471
108
120
assert_get_block_methods ( & provider, block_num) . await ?;
109
121
110
- let block_num = FORK_BLOCK_NUMBER - 5 ;
122
+ // -----------------------------------------------------------------------
123
+ // Get a block before the forked block
124
+
125
+ // https://sepolia.voyager.online/block/0x42dc67af5003d212ac6cd784e72db945ea4d619898f30f422358ff215cbe1e4
126
+ let block_num = FORK_BLOCK_NUMBER - 5 ; // 268466
111
127
assert_get_block_methods ( & provider, block_num) . await ?;
112
128
129
+ // -----------------------------------------------------------------------
130
+ // Get a block that is locally generated
131
+
113
132
let block_num = FORK_BLOCK_NUMBER + 5 ;
114
133
assert_get_block_methods ( & provider, block_num) . await ?;
115
134
135
+ // -----------------------------------------------------------------------
136
+ // Get a block that only exist in the forked chain
137
+
138
+ // https://sepolia.voyager.online/block/0x347a9fa25700e7a2d8f26b39c0ecf765be9a78c559b9cae722a659f25182d10
139
+ // We only created 10 local blocks so this is fine.
140
+ let id = BlockIdOrTag :: Number ( 270_328 ) ;
141
+ let result = provider. get_block_with_txs ( id) . await . unwrap_err ( ) ;
142
+ assert_provider_starknet_err ! ( result, StarknetError :: BlockNotFound ) ;
143
+
144
+ let result = provider. get_block_with_receipts ( id) . await . unwrap_err ( ) ;
145
+ assert_provider_starknet_err ! ( result, StarknetError :: BlockNotFound ) ;
146
+
147
+ let result = provider. get_block_with_tx_hashes ( id) . await . unwrap_err ( ) ;
148
+ assert_provider_starknet_err ! ( result, StarknetError :: BlockNotFound ) ;
149
+
150
+ let result = provider. get_block_transaction_count ( id) . await . unwrap_err ( ) ;
151
+ assert_provider_starknet_err ! ( result, StarknetError :: BlockNotFound ) ;
152
+
153
+ let result = provider. get_state_update ( id) . await . unwrap_err ( ) ;
154
+ assert_provider_starknet_err ! ( result, StarknetError :: BlockNotFound ) ;
155
+
116
156
// -----------------------------------------------------------------------
117
157
// Get block that doesn't exist on the both the forked and local chain
118
158
119
- let id = BlockIdOrTag :: Number ( BlockNumber :: MAX ) ;
159
+ let id = BlockIdOrTag :: Number ( i64 :: MAX as u64 ) ;
120
160
let result = provider. get_block_with_txs ( id) . await . unwrap_err ( ) ;
121
161
assert_provider_starknet_err ! ( result, StarknetError :: BlockNotFound ) ;
122
162
@@ -139,13 +179,13 @@ async fn assert_get_transaction_methods(provider: &impl Provider, tx_hash: TxHas
139
179
let tx = provider
140
180
. get_transaction_by_hash ( tx_hash)
141
181
. await
142
- . with_context ( || format ! ( "failed to get tx {tx_hash:#x}" ) ) ?;
182
+ . context ( format ! ( "failed to get tx {tx_hash:#x}" ) ) ?;
143
183
assert_eq ! ( * tx. transaction_hash( ) , tx_hash) ;
144
184
145
185
let tx = provider
146
186
. get_transaction_receipt ( tx_hash)
147
187
. await
148
- . with_context ( || format ! ( "failed to get receipt {tx_hash:#x}" ) ) ?;
188
+ . context ( format ! ( "failed to get receipt {tx_hash:#x}" ) ) ?;
149
189
assert_eq ! ( * tx. receipt. transaction_hash( ) , tx_hash) ;
150
190
151
191
let result = provider. get_transaction_status ( tx_hash) . await ;
0 commit comments