mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-13 17:41:05 +00:00
bd4e108bb0
- Factor the YUL crate out of `revive-solidity`. - `revive-solidity` is in reality not a Solidity implementation but the revive solidity compiler driver (`resolc`). By renaming we not only get this straight but also a binary with the same name as the crate which should be less confusing. --------- Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
51 lines
1.1 KiB
Rust
51 lines
1.1 KiB
Rust
//! The Solidity compiler unit tests for remappings.
|
|
|
|
#![cfg(test)]
|
|
|
|
use std::collections::BTreeMap;
|
|
use std::collections::BTreeSet;
|
|
|
|
pub const CALLEE_TEST_SOURCE: &str = r#"
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
pragma solidity >=0.4.16;
|
|
|
|
contract Callable {
|
|
function f(uint a) public pure returns(uint) {
|
|
return a * 2;
|
|
}
|
|
}
|
|
"#;
|
|
|
|
pub const CALLER_TEST_SOURCE: &str = r#"
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
pragma solidity >=0.4.16;
|
|
|
|
import "libraries/default/callable.sol";
|
|
|
|
contract Main {
|
|
function main(Callable callable) public returns(uint) {
|
|
return callable.f(5);
|
|
}
|
|
}
|
|
"#;
|
|
|
|
#[test]
|
|
fn default() {
|
|
let mut sources = BTreeMap::new();
|
|
sources.insert("./test.sol".to_owned(), CALLER_TEST_SOURCE.to_owned());
|
|
sources.insert("./callable.sol".to_owned(), CALLEE_TEST_SOURCE.to_owned());
|
|
|
|
let mut remappings = BTreeSet::new();
|
|
remappings.insert("libraries/default/=./".to_owned());
|
|
|
|
super::build_solidity(
|
|
sources,
|
|
BTreeMap::new(),
|
|
Some(remappings),
|
|
revive_llvm_context::OptimizerSettings::cycles(),
|
|
)
|
|
.expect("Test failure");
|
|
}
|