|
1 |
| -use actix_web::{test, test::TestRequest, App}; |
2 |
| -use pretty_assertions::assert_eq; |
3 |
| -use serde_json::json; |
4 |
| -use smart_contract_verifier_proto::blockscout::smart_contract_verifier::v2::{ |
5 |
| - sourcify_verifier_actix::route_sourcify_verifier, VerifyResponse, |
6 |
| -}; |
7 |
| -use smart_contract_verifier_server::{Settings, SourcifyVerifierService}; |
8 |
| -use std::sync::Arc; |
9 |
| - |
10 |
| -const ROUTE: &str = "/api/v2/verifier/sourcify/sources:verify"; |
11 |
| - |
12 |
| -async fn init_service() -> Arc<SourcifyVerifierService> { |
13 |
| - let settings = Settings::default(); |
14 |
| - let service = SourcifyVerifierService::new(settings.sourcify, settings.extensions.sourcify) |
15 |
| - .await |
16 |
| - .expect("couldn't initialize the service"); |
17 |
| - Arc::new(service) |
18 |
| -} |
19 |
| - |
| 1 | +// use actix_web::{test, test::TestRequest, App}; |
| 2 | +// use pretty_assertions::assert_eq; |
| 3 | +// use serde_json::json; |
| 4 | +// use smart_contract_verifier_proto::blockscout::smart_contract_verifier::v2::{ |
| 5 | +// sourcify_verifier_actix::route_sourcify_verifier, VerifyResponse, |
| 6 | +// }; |
| 7 | +// use smart_contract_verifier_server::{Settings, SourcifyVerifierService}; |
| 8 | +// use std::sync::Arc; |
| 9 | +// |
| 10 | +// const ROUTE: &str = "/api/v2/verifier/sourcify/sources:verify"; |
| 11 | +// |
| 12 | +// async fn init_service() -> Arc<SourcifyVerifierService> { |
| 13 | +// let settings = Settings::default(); |
| 14 | +// let service = SourcifyVerifierService::new(settings.sourcify, settings.extensions.sourcify) |
| 15 | +// .await |
| 16 | +// .expect("couldn't initialize the service"); |
| 17 | +// Arc::new(service) |
| 18 | +// } |
| 19 | +// |
20 | 20 | // #[rstest::rstest]
|
21 | 21 | // #[case("0x6da5E8Cd88641dd371F3ED7737664ea86B3C3ec8", "FULL")]
|
22 | 22 | // #[case("0xdb3b8b0001D2B22502dcEA7b839f10b55A3E43c3", "PARTIAL")]
|
@@ -82,68 +82,68 @@ async fn init_service() -> Arc<SourcifyVerifierService> {
|
82 | 82 | // }),
|
83 | 83 | // );
|
84 | 84 | // }
|
85 |
| - |
86 |
| -#[tokio::test] |
87 |
| -async fn invalid_contracts() { |
88 |
| - let service = init_service().await; |
89 |
| - let app = test::init_service( |
90 |
| - App::new().configure(|config| route_sourcify_verifier(config, service.clone())), |
91 |
| - ) |
92 |
| - .await; |
93 |
| - |
94 |
| - let metadata_content = include_str!("contracts/storage/metadata.json"); |
95 |
| - let source = include_str!("contracts/storage/source.sol"); |
96 |
| - for (request_body, _error_message) in [ |
97 |
| - ( |
98 |
| - json!({ |
99 |
| - // relies on fact that the Ethereum Testnet Goerli HASN'T any contract with this address |
100 |
| - "address": "0x1234567890123456789012345678901234567890", |
101 |
| - "chain": "11155111", |
102 |
| - "files": { |
103 |
| - "metadata.json": metadata_content, |
104 |
| - "contracts/1_Storage.sol": source, |
105 |
| - }, |
106 |
| - }), |
107 |
| - "does not have a contract", |
108 |
| - ), |
109 |
| - ( |
110 |
| - json!({ |
111 |
| - "address": "0x1234567890123456789012345678901234567890", |
112 |
| - "chain": "11155111", |
113 |
| - "files": {}, |
114 |
| - }), |
115 |
| - "Metadata file not found", |
116 |
| - ), |
117 |
| - ( |
118 |
| - json!({ |
119 |
| - // relies on fact that Ethereum Testnet Goerli has some contract, but it is not verified in |
120 |
| - // sourcify and `source` contains wrong source code |
121 |
| - "address": "0xd9dF63753D90E3DCcc5AA4D13e77992a64393354", |
122 |
| - "chain": "11155111", |
123 |
| - "files": { |
124 |
| - "metadata.json": metadata_content, |
125 |
| - "contracts/1_Storage.sol": source, |
126 |
| - }, |
127 |
| - }), |
128 |
| - "deployed and recompiled bytecode don't match", |
129 |
| - ), |
130 |
| - ] { |
131 |
| - let resp = TestRequest::post() |
132 |
| - .uri(ROUTE) |
133 |
| - .set_json(&request_body) |
134 |
| - .send_request(&app) |
135 |
| - .await; |
136 |
| - |
137 |
| - let body: VerifyResponse = test::read_body_json(resp).await; |
138 |
| - |
139 |
| - assert_eq!(body.status().as_str_name(), "FAILURE"); |
140 |
| - assert!(body.source.is_none()); |
141 |
| - assert!(body.extra_data.is_none()); |
142 |
| - // assert!( |
143 |
| - // body.message.contains(error_message), |
144 |
| - // "body message: {}, expected message: {}", |
145 |
| - // body.message, |
146 |
| - // error_message |
147 |
| - // ); |
148 |
| - } |
149 |
| -} |
| 85 | +// |
| 86 | +// #[tokio::test] |
| 87 | +// async fn invalid_contracts() { |
| 88 | +// let service = init_service().await; |
| 89 | +// let app = test::init_service( |
| 90 | +// App::new().configure(|config| route_sourcify_verifier(config, service.clone())), |
| 91 | +// ) |
| 92 | +// .await; |
| 93 | +// |
| 94 | +// let metadata_content = include_str!("contracts/storage/metadata.json"); |
| 95 | +// let source = include_str!("contracts/storage/source.sol"); |
| 96 | +// for (request_body, _error_message) in [ |
| 97 | +// ( |
| 98 | +// json!({ |
| 99 | +// // relies on fact that the Ethereum Testnet Goerli HASN'T any contract with this address |
| 100 | +// "address": "0x1234567890123456789012345678901234567890", |
| 101 | +// "chain": "11155111", |
| 102 | +// "files": { |
| 103 | +// "metadata.json": metadata_content, |
| 104 | +// "contracts/1_Storage.sol": source, |
| 105 | +// }, |
| 106 | +// }), |
| 107 | +// "does not have a contract", |
| 108 | +// ), |
| 109 | +// ( |
| 110 | +// json!({ |
| 111 | +// "address": "0x1234567890123456789012345678901234567890", |
| 112 | +// "chain": "11155111", |
| 113 | +// "files": {}, |
| 114 | +// }), |
| 115 | +// "Metadata file not found", |
| 116 | +// ), |
| 117 | +// ( |
| 118 | +// json!({ |
| 119 | +// // relies on fact that Ethereum Testnet Goerli has some contract, but it is not verified in |
| 120 | +// // sourcify and `source` contains wrong source code |
| 121 | +// "address": "0xd9dF63753D90E3DCcc5AA4D13e77992a64393354", |
| 122 | +// "chain": "11155111", |
| 123 | +// "files": { |
| 124 | +// "metadata.json": metadata_content, |
| 125 | +// "contracts/1_Storage.sol": source, |
| 126 | +// }, |
| 127 | +// }), |
| 128 | +// "deployed and recompiled bytecode don't match", |
| 129 | +// ), |
| 130 | +// ] { |
| 131 | +// let resp = TestRequest::post() |
| 132 | +// .uri(ROUTE) |
| 133 | +// .set_json(&request_body) |
| 134 | +// .send_request(&app) |
| 135 | +// .await; |
| 136 | +// |
| 137 | +// let body: VerifyResponse = test::read_body_json(resp).await; |
| 138 | +// |
| 139 | +// assert_eq!(body.status().as_str_name(), "FAILURE"); |
| 140 | +// assert!(body.source.is_none()); |
| 141 | +// assert!(body.extra_data.is_none()); |
| 142 | +// // assert!( |
| 143 | +// // body.message.contains(error_message), |
| 144 | +// // "body message: {}, expected message: {}", |
| 145 | +// // body.message, |
| 146 | +// // error_message |
| 147 | +// // ); |
| 148 | +// } |
| 149 | +// } |
0 commit comments