@@ -214,6 +214,66 @@ fn handle_req_accepted() {
214
214
assert_eq ! ( resp. stacks_block_id, next_block_id) ;
215
215
}
216
216
217
+ #[ test]
218
+ fn handle_req_without_trailing_accepted ( ) {
219
+ let addr = SocketAddr :: new ( IpAddr :: V4 ( Ipv4Addr :: new ( 127 , 0 , 0 , 1 ) ) , 33333 ) ;
220
+ let path_without_slash: & str = "/v3/blocks/upload" ;
221
+ let observer = TestEventObserver :: new ( ) ;
222
+ let mut rpc_test = TestRPC :: setup_nakamoto ( function_name ! ( ) , & observer) ;
223
+ let ( next_block, ..) = rpc_test. peer_1 . single_block_tenure (
224
+ & rpc_test. privk1 ,
225
+ |_| { } ,
226
+ |burn_ops| {
227
+ rpc_test. peer_2 . next_burnchain_block ( burn_ops. clone ( ) ) ;
228
+ } ,
229
+ |_| true ,
230
+ ) ;
231
+ let next_block_id = next_block. block_id ( ) ;
232
+ let mut requests = vec ! [ ] ;
233
+
234
+ // post the block
235
+ requests. push (
236
+ StacksHttpRequest :: new_for_peer (
237
+ addr. into ( ) ,
238
+ "POST" . into ( ) ,
239
+ path_without_slash. into ( ) ,
240
+ HttpRequestContents :: new ( ) . payload_stacks ( & next_block) ,
241
+ )
242
+ . unwrap ( ) ,
243
+ ) ;
244
+
245
+ // idempotent
246
+ requests. push (
247
+ StacksHttpRequest :: new_for_peer (
248
+ addr. into ( ) ,
249
+ "POST" . into ( ) ,
250
+ path_without_slash. into ( ) ,
251
+ HttpRequestContents :: new ( ) . payload_stacks ( & next_block) ,
252
+ )
253
+ . unwrap ( ) ,
254
+ ) ;
255
+ let mut responses = rpc_test. run ( requests) ;
256
+
257
+ let response = responses. remove ( 0 ) ;
258
+ info ! (
259
+ "Response for the request that has the path without the last '/': {}" ,
260
+ std:: str :: from_utf8( & response. try_serialize( ) . unwrap( ) ) . unwrap( )
261
+ ) ;
262
+
263
+ let resp = response. decode_stacks_block_accepted ( ) . unwrap ( ) ;
264
+ assert_eq ! ( resp. accepted, true ) ;
265
+ assert_eq ! ( resp. stacks_block_id, next_block_id) ;
266
+
267
+ let response = responses. remove ( 0 ) ;
268
+ info ! (
269
+ "Response for the request that has the path without the last '/': {}" ,
270
+ std:: str :: from_utf8( & response. try_serialize( ) . unwrap( ) ) . unwrap( )
271
+ ) ;
272
+ let resp = response. decode_stacks_block_accepted ( ) . unwrap ( ) ;
273
+ assert_eq ! ( resp. accepted, false ) ;
274
+ assert_eq ! ( resp. stacks_block_id, next_block_id) ;
275
+ }
276
+
217
277
#[ test]
218
278
fn handle_req_unknown_burn_block ( ) {
219
279
let addr = SocketAddr :: new ( IpAddr :: V4 ( Ipv4Addr :: new ( 127 , 0 , 0 , 1 ) ) , 33333 ) ;
0 commit comments