|
15 | 15 | // along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16 | 16 |
|
17 | 17 | use std::net::SocketAddr;
|
| 18 | +use std::sync::{Arc, Mutex}; |
18 | 19 |
|
19 | 20 | use clarity::vm::costs::ExecutionCost;
|
20 | 21 | use clarity::vm::types::{QualifiedContractIdentifier, StacksAddressExtensions};
|
@@ -46,7 +47,7 @@ use crate::net::db::PeerDB;
|
46 | 47 | use crate::net::httpcore::{StacksHttpRequest, StacksHttpResponse};
|
47 | 48 | use crate::net::relay::Relayer;
|
48 | 49 | use crate::net::rpc::ConversationHttp;
|
49 |
| -use crate::net::test::{TestEventObserver, TestPeer, TestPeerConfig}; |
| 50 | +use crate::net::test::{RPCHandlerArgsType, TestEventObserver, TestPeer, TestPeerConfig}; |
50 | 51 | use crate::net::tests::inv::nakamoto::make_nakamoto_peers_from_invs_ext;
|
51 | 52 | use crate::net::{
|
52 | 53 | Attachment, AttachmentInstance, MemPoolEventDispatcher, RPCHandlerArgs, StackerDBConfig,
|
@@ -226,10 +227,28 @@ pub struct TestRPC<'a> {
|
226 | 227 |
|
227 | 228 | impl<'a> TestRPC<'a> {
|
228 | 229 | pub fn setup(test_name: &str) -> TestRPC<'a> {
|
229 |
| - Self::setup_ex(test_name, true) |
| 230 | + Self::setup_ex(test_name, true, None, None) |
230 | 231 | }
|
231 | 232 |
|
232 |
| - pub fn setup_ex(test_name: &str, process_microblock: bool) -> TestRPC<'a> { |
| 233 | + pub fn setup_with_rpc_args( |
| 234 | + test_name: &str, |
| 235 | + rpc_handler_args_opt_1: Option<RPCHandlerArgsType>, |
| 236 | + rpc_handler_args_opt_2: Option<RPCHandlerArgsType>, |
| 237 | + ) -> TestRPC<'a> { |
| 238 | + Self::setup_ex( |
| 239 | + test_name, |
| 240 | + true, |
| 241 | + rpc_handler_args_opt_1, |
| 242 | + rpc_handler_args_opt_2, |
| 243 | + ) |
| 244 | + } |
| 245 | + |
| 246 | + pub fn setup_ex( |
| 247 | + test_name: &str, |
| 248 | + process_microblock: bool, |
| 249 | + rpc_handler_args_opt_1: Option<RPCHandlerArgsType>, |
| 250 | + rpc_handler_args_opt_2: Option<RPCHandlerArgsType>, |
| 251 | + ) -> TestRPC<'a> { |
233 | 252 | // ST2DS4MSWSGJ3W9FBC6BVT0Y92S345HY8N3T6AV7R
|
234 | 253 | let privk1 = StacksPrivateKey::from_hex(
|
235 | 254 | "9f1f85a512a96a244e4c0d762788500687feb97481639572e3bffbd6860e6ab001",
|
@@ -317,6 +336,9 @@ impl<'a> TestRPC<'a> {
|
317 | 336 | let mut peer_1 = TestPeer::new(peer_1_config);
|
318 | 337 | let mut peer_2 = TestPeer::new(peer_2_config);
|
319 | 338 |
|
| 339 | + peer_1.rpc_handler_args = rpc_handler_args_opt_1; |
| 340 | + peer_2.rpc_handler_args = rpc_handler_args_opt_2; |
| 341 | + |
320 | 342 | // mine one block with a contract in it
|
321 | 343 | // first the coinbase
|
322 | 344 | // make a coinbase for this miner
|
@@ -976,7 +998,11 @@ impl<'a> TestRPC<'a> {
|
976 | 998 | }
|
977 | 999 |
|
978 | 1000 | {
|
979 |
| - let mut rpc_args = RPCHandlerArgs::default(); |
| 1001 | + let mut rpc_args = peer_1 |
| 1002 | + .rpc_handler_args |
| 1003 | + .as_ref() |
| 1004 | + .map(|args_type| args_type.instantiate()) |
| 1005 | + .unwrap_or(RPCHandlerArgsType::make_default()); |
980 | 1006 | rpc_args.event_observer = event_observer;
|
981 | 1007 | let mut node_state = StacksNodeState::new(
|
982 | 1008 | &mut peer_1.network,
|
@@ -1020,7 +1046,11 @@ impl<'a> TestRPC<'a> {
|
1020 | 1046 | }
|
1021 | 1047 |
|
1022 | 1048 | {
|
1023 |
| - let mut rpc_args = RPCHandlerArgs::default(); |
| 1049 | + let mut rpc_args = peer_2 |
| 1050 | + .rpc_handler_args |
| 1051 | + .as_ref() |
| 1052 | + .map(|args_type| args_type.instantiate()) |
| 1053 | + .unwrap_or(RPCHandlerArgsType::make_default()); |
1024 | 1054 | rpc_args.event_observer = event_observer;
|
1025 | 1055 | let mut node_state = StacksNodeState::new(
|
1026 | 1056 | &mut peer_2.network,
|
@@ -1076,7 +1106,11 @@ impl<'a> TestRPC<'a> {
|
1076 | 1106 | let mut peer_1_stacks_node = peer_1.stacks_node.take().unwrap();
|
1077 | 1107 | let mut peer_1_mempool = peer_1.mempool.take().unwrap();
|
1078 | 1108 |
|
1079 |
| - let rpc_args = RPCHandlerArgs::default(); |
| 1109 | + let rpc_args = peer_1 |
| 1110 | + .rpc_handler_args |
| 1111 | + .as_ref() |
| 1112 | + .map(|args_type| args_type.instantiate()) |
| 1113 | + .unwrap_or(RPCHandlerArgsType::make_default()); |
1080 | 1114 | let mut node_state = StacksNodeState::new(
|
1081 | 1115 | &mut peer_1.network,
|
1082 | 1116 | &peer_1_sortdb,
|
|
0 commit comments