Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

test(solc): add another link with remapping test #1191

Merged
merged 1 commit into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions ethers-solc/src/compile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,18 @@ mod tests {
assert!(!bytecode.is_unlinked());
}

#[test]
fn can_compile_with_remapped_links_temp_dir() {
let input: CompilerInput =
serde_json::from_str(include_str!("../../test-data/library-remapping-in-2.json"))
.unwrap();
let out = solc().compile(&input).unwrap();
let (_, mut contracts) = out.split();
let contract = contracts.remove("LinkTest").unwrap();
let bytecode = &contract.get_bytecode().unwrap().object;
assert!(!bytecode.is_unlinked());
}

#[cfg(feature = "async")]
#[tokio::test]
async fn async_solc_compile_works() {
Expand Down
43 changes: 43 additions & 0 deletions ethers-solc/test-data/library-remapping-in-2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"language": "Solidity",
"sources": {
"/private/var/folders/l5/lprhf87s6xv8djgd017f0b2h0000gn/T/can_create_on_goerli-0vd5EOs/lib/remapping/MyLib.sol": {
"content": "\n// SPDX-License-Identifier: MIT\nlibrary MyLib {\n function foobar(uint256 a) public view returns (uint256) {\n \treturn a * 100;\n }\n}\n"
},
"/private/var/folders/l5/lprhf87s6xv8djgd017f0b2h0000gn/T/can_create_on_goerli-0vd5EOs/src/LinkTest.sol": {
"content": "\n// SPDX-License-Identifier: MIT\nimport \"remapping/MyLib.sol\";\ncontract LinkTest {\n function foo() public returns (uint256) {\n return MyLib.foobar(1);\n }\n}\n"
}
},
"settings": {
"remappings": [
"remapping/=/private/var/folders/l5/lprhf87s6xv8djgd017f0b2h0000gn/T/can_create_on_goerli-0vd5EOs/lib/remapping/",
"src/=/private/var/folders/l5/lprhf87s6xv8djgd017f0b2h0000gn/T/can_create_on_goerli-0vd5EOs/src/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"bytecodeHash": "ipfs"
},
"outputSelection": {
"*": {
"": [
"ast"
],
"*": [
"abi",
"evm.bytecode",
"evm.deployedBytecode",
"evm.methodIdentifiers"
]
}
},
"evmVersion": "london",
"libraries": {
"/private/var/folders/l5/lprhf87s6xv8djgd017f0b2h0000gn/T/can_create_on_goerli-0vd5EOs/lib/remapping/MyLib.sol": {
"MyLib": "0x0000000000000000000000000000000000000000"
}
}
}
}