@@ -88,6 +88,26 @@ async fn to_bytes(res: Response) -> Bytes {
8888 res. into_body ( ) . collect ( ) . await . unwrap ( ) . to_bytes ( )
8989}
9090
91+ /// Test that an HTTP server with a `allow_new_txs = false` config rejects new transactions.
92+ #[ rstest]
93+ #[ tokio:: test]
94+ async fn allow_new_txs ( ) {
95+ let index = 10 ;
96+ let tx = rpc_invoke_tx ( ) ;
97+
98+ let mock_gateway_client = MockGatewayClient :: new ( ) ;
99+ let mock_config_manager_client = get_mock_config_manager_client ( false ) ;
100+
101+ // TODO(Yael): avoid the hardcoded node offset index, consider dynamic allocation.
102+ let http_client =
103+ add_tx_http_client ( mock_config_manager_client, mock_gateway_client, 1 + index) . await ;
104+
105+ // Send a transaction to the server.
106+ let response = http_client. add_tx ( tx. clone ( ) ) . await ;
107+ let status = response. status ( ) ;
108+ assert ! ( !status. is_success( ) , "{status:?}" ) ;
109+ }
110+
91111#[ tokio:: test]
92112async fn error_into_response ( ) {
93113 let error = HttpServerError :: DeserializationError (
@@ -127,7 +147,7 @@ async fn record_region_test(#[case] index: u16, #[case] tx: impl GatewayTransact
127147 . times ( 1 )
128148 . return_const ( Ok ( GatewayOutput :: Invoke ( InvokeGatewayOutput :: new ( tx_hash_2) ) ) ) ;
129149
130- let mock_config_manager_client = get_mock_config_manager_client ( ) ;
150+ let mock_config_manager_client = get_mock_config_manager_client ( true ) ;
131151 // TODO(Yael): avoid the hardcoded node offset index, consider dynamic allocation.
132152 let http_client =
133153 add_tx_http_client ( mock_config_manager_client, mock_gateway_client, 1 + index) . await ;
@@ -162,7 +182,7 @@ async fn record_region_gateway_failing_tx(#[case] index: u16, #[case] tx: impl G
162182 ) ) ,
163183 ) ) ;
164184
165- let mock_config_manager_client = get_mock_config_manager_client ( ) ;
185+ let mock_config_manager_client = get_mock_config_manager_client ( true ) ;
166186 let http_client =
167187 add_tx_http_client ( mock_config_manager_client, mock_gateway_client, 3 + index) . await ;
168188
@@ -212,7 +232,7 @@ async fn test_response(#[case] index: u16, #[case] tx: impl GatewayTransaction)
212232 expected_internal_err,
213233 ) ) ;
214234
215- let mock_config_manager_client = get_mock_config_manager_client ( ) ;
235+ let mock_config_manager_client = get_mock_config_manager_client ( true ) ;
216236 let http_client =
217237 add_tx_http_client ( mock_config_manager_client, mock_gateway_client, 5 + index) . await ;
218238
@@ -281,7 +301,7 @@ async fn test_unsupported_tx_version(
281301 }
282302
283303 let mock_gateway_client = MockGatewayClient :: new ( ) ;
284- let mock_config_manager_client = get_mock_config_manager_client ( ) ;
304+ let mock_config_manager_client = get_mock_config_manager_client ( true ) ;
285305 let http_client =
286306 add_tx_http_client ( mock_config_manager_client, mock_gateway_client, 9 + index) . await ;
287307
@@ -302,7 +322,7 @@ async fn sanitizing_error_message() {
302322 tx_object. insert ( "version" . to_string ( ) , Value :: String ( malicious_version. to_string ( ) ) ) . unwrap ( ) ;
303323
304324 let mock_gateway_client = MockGatewayClient :: new ( ) ;
305- let mock_config_manager_client = get_mock_config_manager_client ( ) ;
325+ let mock_config_manager_client = get_mock_config_manager_client ( true ) ;
306326 let http_client = add_tx_http_client ( mock_config_manager_client, mock_gateway_client, 13 ) . await ;
307327
308328 let serialized_err =
0 commit comments