mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-04-22 04:28:02 +00:00
76d6a154c1
* Fix the OS FD error * Cache the compiler versions * Allow for auto display impl in declare wrapper type macro * Better logging and fix concurrency issues * Fix tests * Format * Make the code even more concurrent
88 lines
2.5 KiB
Rust
88 lines
2.5 KiB
Rust
use std::path::PathBuf;
|
|
|
|
use revive_dt_compiler::{Compiler, SolidityCompiler, revive_resolc::Resolc, solc::Solc};
|
|
use revive_dt_config::Arguments;
|
|
use semver::Version;
|
|
|
|
#[tokio::test]
|
|
async fn contracts_can_be_compiled_with_solc() {
|
|
// Arrange
|
|
let args = Arguments::default();
|
|
let compiler_path = Solc::get_compiler_executable(&args, Version::new(0, 8, 30))
|
|
.await
|
|
.unwrap();
|
|
|
|
// Act
|
|
let output = Compiler::<Solc>::new()
|
|
.with_source("./tests/assets/array_one_element/callable.sol")
|
|
.unwrap()
|
|
.with_source("./tests/assets/array_one_element/main.sol")
|
|
.unwrap()
|
|
.try_build(compiler_path)
|
|
.await;
|
|
|
|
// Assert
|
|
let output = output.expect("Failed to compile");
|
|
assert_eq!(output.contracts.len(), 2);
|
|
|
|
let main_file_contracts = output
|
|
.contracts
|
|
.get(
|
|
&PathBuf::from("./tests/assets/array_one_element/main.sol")
|
|
.canonicalize()
|
|
.unwrap(),
|
|
)
|
|
.unwrap();
|
|
let callable_file_contracts = output
|
|
.contracts
|
|
.get(
|
|
&PathBuf::from("./tests/assets/array_one_element/callable.sol")
|
|
.canonicalize()
|
|
.unwrap(),
|
|
)
|
|
.unwrap();
|
|
assert!(main_file_contracts.contains_key("Main"));
|
|
assert!(callable_file_contracts.contains_key("Callable"));
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn contracts_can_be_compiled_with_resolc() {
|
|
// Arrange
|
|
let args = Arguments::default();
|
|
let compiler_path = Resolc::get_compiler_executable(&args, Version::new(0, 8, 30))
|
|
.await
|
|
.unwrap();
|
|
|
|
// Act
|
|
let output = Compiler::<Resolc>::new()
|
|
.with_source("./tests/assets/array_one_element/callable.sol")
|
|
.unwrap()
|
|
.with_source("./tests/assets/array_one_element/main.sol")
|
|
.unwrap()
|
|
.try_build(compiler_path)
|
|
.await;
|
|
|
|
// Assert
|
|
let output = output.expect("Failed to compile");
|
|
assert_eq!(output.contracts.len(), 2);
|
|
|
|
let main_file_contracts = output
|
|
.contracts
|
|
.get(
|
|
&PathBuf::from("./tests/assets/array_one_element/main.sol")
|
|
.canonicalize()
|
|
.unwrap(),
|
|
)
|
|
.unwrap();
|
|
let callable_file_contracts = output
|
|
.contracts
|
|
.get(
|
|
&PathBuf::from("./tests/assets/array_one_element/callable.sol")
|
|
.canonicalize()
|
|
.unwrap(),
|
|
)
|
|
.unwrap();
|
|
assert!(main_file_contracts.contains_key("Main"));
|
|
assert!(callable_file_contracts.contains_key("Callable"));
|
|
}
|