Skip to content

Commit

Permalink
test: share compilation step
Browse files Browse the repository at this point in the history
  • Loading branch information
gakonst committed Sep 13, 2021
1 parent 3e9afed commit 2f8658a
Showing 1 changed file with 13 additions and 28 deletions.
41 changes: 13 additions & 28 deletions dapp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,6 @@ impl<'a> SolcBuilder<'a> {
.clone();
compiler_path.push(format!("solc-{}", &version));

dbg!(std::process::Command::new("ls").args(["-lah", "/home/runner/.svm/*"]).output().unwrap());

let mut solc = Solc::new_with_paths(files).solc_path(compiler_path);
let lib_paths = self
.lib_paths
Expand Down Expand Up @@ -591,16 +589,19 @@ impl<'a> MultiContractRunner<'a> {
#[cfg(test)]
mod tests {
use super::*;
use ethers::utils::id;
use ethers::{prelude::Lazy, utils::id};

static COMPILED: Lazy<HashMap<String, CompiledContract>> = Lazy::new(|| {
SolcBuilder::new("./*.sol", &[], &[])
.unwrap()
.build_all()
.unwrap()
});

#[test]
fn can_call_vm_directly() {
let cfg = Config::istanbul();
let compiled = SolcBuilder::new("./*.sol", &[], &[])
.unwrap()
.build_all()
.unwrap();
let compiled = compiled.get("Greeter").expect("could not find contract");
let compiled = COMPILED.get("Greeter").expect("could not find contract");

let addr = "0x1000000000000000000000000000000000000000"
.parse()
Expand Down Expand Up @@ -639,11 +640,7 @@ mod tests {
fn solidity_unit_test() {
let cfg = Config::istanbul();

let compiled = SolcBuilder::new("./*.sol", &[], &[])
.unwrap()
.build_all()
.unwrap();
let compiled = compiled
let compiled = COMPILED
.get("GreeterTest")
.expect("could not find contract");

Expand Down Expand Up @@ -684,11 +681,7 @@ mod tests {
fn failing_with_no_reason_if_no_setup() {
let cfg = Config::istanbul();

let compiled = SolcBuilder::new("./*.sol", &[], &[])
.unwrap()
.build_all()
.unwrap();
let compiled = compiled
let compiled = COMPILED
.get("GreeterTest")
.expect("could not find contract");

Expand Down Expand Up @@ -717,11 +710,7 @@ mod tests {
fn failing_solidity_unit_test() {
let cfg = Config::istanbul();

let compiled = SolcBuilder::new("./*.sol", &[], &[])
.unwrap()
.build_all()
.unwrap();
let compiled = compiled
let compiled = COMPILED
.get("GreeterTest")
.expect("could not find contract");

Expand Down Expand Up @@ -763,11 +752,7 @@ mod tests {
fn test_runner() {
let cfg = Config::istanbul();

let compiled = SolcBuilder::new("./*.sol", &[], &[])
.unwrap()
.build_all()
.unwrap();
let compiled = compiled
let compiled = COMPILED
.get("GreeterTest")
.expect("could not find contract");

Expand Down

0 comments on commit 2f8658a

Please sign in to comment.