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 f673389 commit 37820d1
Showing 1 changed file with 13 additions and 26 deletions.
39 changes: 13 additions & 26 deletions dapp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,16 +586,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 @@ -634,11 +637,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 @@ -679,11 +678,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 @@ -712,11 +707,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 @@ -758,11 +749,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 37820d1

Please sign in to comment.