mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-04-22 13:47:55 +00:00
f51693cb9f
* Allow for downloader to use version requirements. We will soon add support for the compiler version requirement from the metadata files to be honored. The compiler version is specified in the solc modes section of the file and its specified as a `VersionReq` and not as a version. Therefore, we need to have the ability to honor this version requirement and find the best version that satisfies the requirement. * Request `VersionOrRequirement` in compiler interface * Honor the compiler version requirement in metadata This commit honors the compiler version requirement listed in the solc modes of the metadata file. If this version requirement is provided then it overrides what was passed in the CLI. Otherwise, the CLI version will be used. * Make compiler IO completely generic. Before this commit, the types that were used for the compiler input and output were the resolc compiler types which was a leaky abstraction as we have traits to abstract the compilers away but we expose their internal types out to other crates. This commit did the following: 1. Made the compiler IO types fully generic so that all of the logic for constructing the map of compiled contracts is all done by the compiler implementation and not by the consuming code. 2. Changed the input types used for Solc to be the forge standard JSON types for Solc instead of resolc. * Fix machete * Add resolc to CI * Add resolc to CI * Add resolc to CI * Add resolc to CI
82 lines
2.4 KiB
Rust
82 lines
2.4 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;
|
|
|
|
#[test]
|
|
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)).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);
|
|
|
|
// 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"));
|
|
}
|
|
|
|
#[test]
|
|
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)).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);
|
|
|
|
// 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"));
|
|
}
|