| 66 | /// also when running tests to get the same output. If not, it's skipped. |
| 67 | #[tokio::test(flavor = "multi_thread")] |
| 68 | async fn post_simulate_file_etherscan() { |
| 69 | if config().etherscan_key.is_none() { |
| 70 | eprintln!("etherscan_key is none, skipping test"); |
| 71 | return; |
| 72 | } |
| 73 | |
| 74 | let filter = filter(config()); |
| 75 | |
| 76 | let file = File::open("tests/body.json").expect("file should open read only"); |
| 77 | let json: SimulationRequest = |
| 78 | serde_json::from_reader(file).expect("file should be proper JSON"); |
| 79 | |
| 80 | let res = warp::test::request() |
| 81 | .method("POST") |
| 82 | .path("/simulate") |
| 83 | .json(&json) |
| 84 | .reply(&filter) |
| 85 | .await; |
| 86 | |
| 87 | assert_eq!(res.status(), 200); |
| 88 | |
| 89 | // Uncomment to create new file, if you've made changes to the expected response |
| 90 | // let mut file = File::create("tests/expected_etherscan.json").expect("file should open write only"); |
| 91 | // file.write_all(res.body()).expect("file should be written"); |
| 92 | |
| 93 | let body: SimulationResponse = serde_json::from_slice(res.body()).unwrap(); |
| 94 | |
| 95 | let file = File::open("tests/expected_etherscan.json").expect("file should open read only"); |
| 96 | let expected: SimulationResponse = |
| 97 | serde_json::from_reader(file).expect("file should be proper JSON"); |
| 98 | |
| 99 | assert_eq!(body, expected); |
| 100 | } |
| 101 | |
| 102 | #[tokio::test(flavor = "multi_thread")] |
| 103 | async fn post_simulate_frax_tx() { |