@@ -5,32 +5,29 @@ use alloy_primitives::U256;
5
5
use forge:: { MultiContractRunner , MultiContractRunnerBuilder } ;
6
6
use foundry_cli:: utils:: install_crypto_provider;
7
7
use foundry_compilers:: {
8
- Project , ProjectCompileOutput , SolcConfig , Vyper ,
8
+ Project , ProjectCompileOutput , SolcConfig ,
9
9
artifacts:: { EvmVersion , Libraries , Settings } ,
10
10
compilers:: multi:: MultiCompiler ,
11
- utils:: RuntimeOrHandle ,
12
11
} ;
13
12
use foundry_config:: {
14
13
Config , FsPermissions , FuzzConfig , FuzzCorpusConfig , FuzzDictionaryConfig , InvariantConfig ,
15
14
RpcEndpointUrl , RpcEndpoints , fs_permissions:: PathPermission ,
16
15
} ;
17
16
use foundry_evm:: { constants:: CALLER , opts:: EvmOpts } ;
18
17
use foundry_test_utils:: {
19
- fd_lock , init_tracing,
18
+ init_tracing,
20
19
rpc:: { next_http_archive_rpc_url, next_rpc_endpoint} ,
21
- test_debug ,
20
+ util :: get_compiled ,
22
21
} ;
23
22
use revm:: primitives:: hardfork:: SpecId ;
24
23
use std:: {
25
24
env, fmt,
26
- io:: Write ,
27
25
path:: { Path , PathBuf } ,
28
26
sync:: { Arc , LazyLock } ,
29
27
} ;
30
28
31
29
pub const RE_PATH_SEPARATOR : & str = "/" ;
32
30
const TESTDATA : & str = concat ! ( env!( "CARGO_MANIFEST_DIR" ) , "/../../testdata" ) ;
33
- static VYPER : LazyLock < PathBuf > = LazyLock :: new ( || std:: env:: temp_dir ( ) . join ( "vyper" ) ) ;
34
31
35
32
/// Profile for the tests group. Used to configure separate configurations for test runs.
36
33
pub enum ForgeTestProfile {
@@ -256,84 +253,6 @@ impl ForgeTestData {
256
253
}
257
254
}
258
255
259
- /// Installs Vyper if it's not already present.
260
- pub fn get_vyper ( ) -> Vyper {
261
- if let Ok ( vyper) = Vyper :: new ( "vyper" ) {
262
- return vyper;
263
- }
264
- if let Ok ( vyper) = Vyper :: new ( & * VYPER ) {
265
- return vyper;
266
- }
267
- RuntimeOrHandle :: new ( ) . block_on ( async {
268
- #[ cfg( target_family = "unix" ) ]
269
- use std:: { fs:: Permissions , os:: unix:: fs:: PermissionsExt } ;
270
-
271
- let suffix = match svm:: platform ( ) {
272
- svm:: Platform :: MacOsAarch64 => "darwin" ,
273
- svm:: Platform :: LinuxAmd64 => "linux" ,
274
- svm:: Platform :: WindowsAmd64 => "windows.exe" ,
275
- platform => panic ! (
276
- "unsupported platform {platform:?} for installing vyper, \
277
- install it manually and add it to $PATH"
278
- ) ,
279
- } ;
280
- let url = format ! ( "https://github.com/vyperlang/vyper/releases/download/v0.4.3/vyper.0.4.3+commit.bff19ea2.{suffix}" ) ;
281
-
282
- test_debug ! ( "downloading vyper from {url}" ) ;
283
- let res = reqwest:: Client :: builder ( ) . build ( ) . unwrap ( ) . get ( url) . send ( ) . await . unwrap ( ) ;
284
-
285
- assert ! ( res. status( ) . is_success( ) ) ;
286
-
287
- let bytes = res. bytes ( ) . await . unwrap ( ) ;
288
-
289
- std:: fs:: write ( & * VYPER , bytes) . unwrap ( ) ;
290
-
291
- #[ cfg( target_family = "unix" ) ]
292
- std:: fs:: set_permissions ( & * VYPER , Permissions :: from_mode ( 0o755 ) ) . unwrap ( ) ;
293
-
294
- Vyper :: new ( & * VYPER ) . unwrap ( )
295
- } )
296
- }
297
-
298
- #[ tracing:: instrument]
299
- pub fn get_compiled ( project : & mut Project ) -> ProjectCompileOutput {
300
- let lock_file_path = project. sources_path ( ) . join ( ".lock" ) ;
301
- // Compile only once per test run.
302
- // We need to use a file lock because `cargo-nextest` runs tests in different processes.
303
- // This is similar to [`foundry_test_utils::util::initialize`], see its comments for more
304
- // details.
305
- let mut lock = fd_lock:: new_lock ( & lock_file_path) ;
306
- let read = lock. read ( ) . unwrap ( ) ;
307
- let out;
308
-
309
- let mut write = None ;
310
- if !project. cache_path ( ) . exists ( ) || std:: fs:: read ( & lock_file_path) . unwrap ( ) != b"1" {
311
- drop ( read) ;
312
- write = Some ( lock. write ( ) . unwrap ( ) ) ;
313
- test_debug ! ( "cache miss for {}" , lock_file_path. display( ) ) ;
314
- } else {
315
- test_debug ! ( "cache hit for {}" , lock_file_path. display( ) ) ;
316
- }
317
-
318
- if project. compiler . vyper . is_none ( ) {
319
- project. compiler . vyper = Some ( get_vyper ( ) ) ;
320
- }
321
-
322
- test_debug ! ( "compiling {}" , lock_file_path. display( ) ) ;
323
- out = project. compile ( ) . unwrap ( ) ;
324
- test_debug ! ( "compiled {}" , lock_file_path. display( ) ) ;
325
-
326
- if out. has_compiler_errors ( ) {
327
- panic ! ( "Compiled with errors:\n {out}" ) ;
328
- }
329
-
330
- if let Some ( ref mut write) = write {
331
- write. write_all ( b"1" ) . unwrap ( ) ;
332
- }
333
-
334
- out
335
- }
336
-
337
256
/// Default data for the tests group.
338
257
pub static TEST_DATA_DEFAULT : LazyLock < ForgeTestData > =
339
258
LazyLock :: new ( || ForgeTestData :: new ( ForgeTestProfile :: Default ) ) ;
0 commit comments