Repository: gakonst/ethers-rs
Pull request #1101 (2022-04-03 12:50:21)

test: add multiline flatten test
<!--
Thank you for your Pull Request. Please provide a description above and review
the requirements below.

Bug fixes and new features should include tests.

Contributors guide: https://github.com/gakonst/ethers-rs/blob/master/CONTRIBUTING.md

The contributors guide includes instructions for running rustfmt and building the
documentation.
-->

## Motivation
Add test to check multiline imports are resolved correctly.
<!--
Explain the context and why you're making that change. What is the problem
you're trying to solve? In some cases there is not a problem and this can be
thought of as being the motivation for your change.
-->

## Solution

<!--
Summarize the solution and provide any necessary context needed to understand
the code change.
-->

## PR Checklist

- [x] Added Tests
- [ ] Added Documentation
- [ ] Updated the changelog



Patch:
diff --git a/Cargo.lock b/Cargo.lock
index 23c669b4..07529807 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3522,9 +3522,9 @@ dependencies = [
 
 [[package]]
 name = "solang-parser"
-version = "0.1.10"
+version = "0.1.11"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a06b8bfb6c910adbada563211b876b91a058791505e4cb646591b205fa817d01"
+checksum = "90f49c1bb28a8814fdac132b1ec1f2f65c656186d8dfbc411db8bcaba45cdc06"
 dependencies = [
  "lalrpop",
  "lalrpop-util",
diff --git a/ethers-solc/Cargo.toml b/ethers-solc/Cargo.toml
index 03e4f108..4564afce 100644
--- a/ethers-solc/Cargo.toml
+++ b/ethers-solc/Cargo.toml
@@ -35,7 +35,7 @@ tempfile = { version = "3.3.0", optional = true }
 fs_extra = { version = "1.2.0", optional = true }
 sha2 = { version = "0.9.8", default-features = false, optional = true }
 dunce = "1.0.2"
-solang-parser = { default-features = false, version = "0.1.10" }
+solang-parser = { default-features = false, version = "0.1.11" }
 rayon = "1.5.1"
 rand = { version = "0.8.5", optional = true }
 
@@ -70,12 +70,12 @@ harness = false
 [[test]]
 name = "project"
 path = "tests/project.rs"
-required-features = ["async", "solc-svm", "project-util"]
+required-features = ["full", "project-util"]
 
 [[test]]
 name = "mocked"
 path = "tests/mocked.rs"
-required-features = ["async", "solc-svm", "project-util"]
+required-features = ["full", "project-util"]
 
 [features]
 default = ["rustls"]


Test patch:
diff --git a/ethers-solc/tests/project.rs b/ethers-solc/tests/project.rs
index 8871fe98..4188067f 100644
--- a/ethers-solc/tests/project.rs
+++ b/ethers-solc/tests/project.rs
@@ -550,6 +550,57 @@ contract Contract {
     );
 }
 
+#[test]
+fn can_flatten_multiline() {
+    let project = TempProject::dapptools().unwrap();
+
+    let f = project
+        .add_source(
+            "A",
+            r#"
+pragma solidity ^0.8.10;
+import "./C.sol";
+import {
+    IllegalArgument,
+    IllegalState
+} from "./Errors.sol";
+contract A { }
+"#,
+        )
+        .unwrap();
+
+    project
+        .add_source(
+            "Errors",
+            r#"
+pragma solidity ^0.8.10;
+error IllegalArgument();
+error IllegalState();
+"#,
+        )
+        .unwrap();
+
+    project
+        .add_source(
+            "C",
+            r#"
+pragma solidity ^0.8.10;
+contract C { }
+"#,
+        )
+        .unwrap();
+
+    let result = project.flatten(&f).unwrap();
+    assert_eq!(
+        result.trim(),
+        r#"pragma solidity ^0.8.10;
+contract C { }
+error IllegalArgument();
+error IllegalState();
+contract A { }"#
+    );
+}
+
 #[test]
 fn can_detect_type_error() {
     let project = TempProject::<ConfigurableArtifacts>::dapptools().unwrap();