Skip to content

Commit

Permalink
refactor: use solc instead of solcjs
Browse files Browse the repository at this point in the history
Due to differences between solc and solcjs in their generated output
on Windows machines (ethereum/solc-js#365),
compilation will always break because solcjs doesn't handle output
paths correctly.

A fix for this has been proposed here ethereum/solc-js#367,
once that is merged, we can roll back to solcjs again.
  • Loading branch information
0x-r4bbit committed Jun 10, 2019
1 parent c6e49a6 commit 112b1ac
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 43 deletions.
45 changes: 34 additions & 11 deletions .azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,39 @@ jobs:
inputs:
versionSpec: "10.5.0"
displayName: Install Node
- script: npm install -g solc
displayName: Install solcjs
- script: npm install -g ganache-cli
displayName: Install Ganache CLI
- script: bash <(curl https://get.parity.io -L)
condition: ne( variables['Agent.OS'], 'Windows_NT' )
displayName: Install Parity
- bash: |
- script: |
mkdir -p ../Downloads
cd ../Downloads
curl -L -o "parity.exe" "https://releases.parity.io/ethereum/v${PARITY_VERSION}/x86_64-pc-windows-msvc/parity.exe"
curl -L -o "solc" "https://github.com/ethereum/solidity/releases/download/v0.5.9/solc-static-linux"
chmod +x solc
displayName: Linux install Solc
condition: eq( variables['Agent.OS'], 'Linux' )
- script: |
brew update
brew upgrade
brew tap ethereum/ethereum
brew install solidity
displayName: Mac install Solc
condition: eq( variables['Agent.OS'], 'Darwin' )
- powershell: |
mkdir -p ../Downloads
$client = new-object System.Net.WebClient
$client.DownloadFile("https://github.com/ethereum/solidity/releases/download/v0.5.9/solidity-windows.zip", "..\Downloads\solidity-windows.zip")
Expand-Archive –Path “..\Downloads\solidity-windows.zip” –Destination “..\Downloads\solidity-windows”
displayName: Windows install Solc
condition: eq( variables['Agent.OS'], 'Windows_NT' )
displayName: Windows install Parity
- script: |
npm install -g ganache-cli
displayName: Install Ganache CLI
#- script: bash <(curl https://get.parity.io -L)
#condition: ne( variables['Agent.OS'], 'Windows_NT' )
#displayName: Install Parity
#- bash: |
#mkdir -p ../Downloads
#cd ../Downloads
#curl -L -o "parity.exe" "https://releases.parity.io/ethereum/v${PARITY_VERSION}/x86_64-pc-windows-msvc/parity.exe"
#condition: eq( variables['Agent.OS'], 'Windows_NT' )
#displayName: Windows install Parity
- script: |
curl https://sh.rustup.rs -sSf | sh -s -- -y
echo "##vso[task.setvariable variable=PATH;]$PATH:$HOME/.cargo/bin"
Expand Down Expand Up @@ -81,5 +101,8 @@ jobs:
- powershell: Start-Process -FilePath "ganache-cli"
displayName: Windows start Ganache
condition: eq( variables['Agent.OS'], 'Windows_NT' )
- bash: cd cli && cargo test --all
- bash: |
export PATH="$(cd ../Downloads && pwd):${PATH}"
export PATH="$(cd ../Downloads/solidity-windows && pwd):${PATH}"
cd cli && cargo test --all
displayName: Cargo test vibranium-cli
1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ assert_cmd = "0.10"
predicates = "1"
toml = "0.4.10"
tempfile = "3"
float-cmp = "=0.4.0"
39 changes: 7 additions & 32 deletions cli/tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,17 +421,11 @@ mod compile_cmd {
let mut cmd = Command::main_binary()?;

cmd.arg("compile")
.arg("--compiler")
.arg("solcjs")
.arg("--path")
.arg(&project_path);

// We don't provide any source files to solcjs, so we know it
// will fail with the error message below.
cmd.assert()
.failure()
.stderr(predicate::str::contains("Must provide a file"));

// We don't provide any source files to solc, so we know it will
cmd.assert().failure();
tmp_dir.close()?;
Ok(())
}
Expand All @@ -447,17 +441,11 @@ mod compile_cmd {

let mut cmd = Command::main_binary()?;

// There are no Smart Contract files in the generated project
// so if everything goes as expected, this command fails with
// `solcjs` exiting with the error message below.
cmd.arg("compile")
.arg("--path")
.arg(&project_path);

cmd.assert()
.failure()
.stderr(predicate::str::contains("Must provide a file"));

cmd.assert().failure();
tmp_dir.close()?;
Ok(())
}
Expand All @@ -472,16 +460,13 @@ mod compile_cmd {
let mut cmd = Command::main_binary()?;
cmd.arg("compile")
.arg("--compiler")
.arg("solcjs")
.arg("something")
.arg("--path")
.arg(&project_path);

// Failure is the expected behaviour here as we don't provide any Smart Contract
// source files to `solcjs`.
cmd.assert()
.failure()
.stderr(predicate::str::contains("Must provide a file"));

// Failure is the expected behaviour here as we don't provide a valid
// compiler option
cmd.assert().failure();
tmp_dir.close()?;
Ok(())
}
Expand Down Expand Up @@ -606,8 +591,6 @@ mod deploy_cmd {

let mut cmd = Command::main_binary()?;
cmd.arg("compile")
.arg("--compiler")
.arg("solcjs")
.arg("--path")
.arg(&project_path);

Expand Down Expand Up @@ -656,8 +639,6 @@ mod deploy_cmd {

let mut cmd = Command::main_binary()?;
cmd.arg("compile")
.arg("--compiler")
.arg("solcjs")
.arg("--path")
.arg(&project_path);

Expand Down Expand Up @@ -737,8 +718,6 @@ mod deploy_cmd {

let mut cmd = Command::main_binary()?;
cmd.arg("compile")
.arg("--compiler")
.arg("solcjs")
.arg("--path")
.arg(&project_path);

Expand Down Expand Up @@ -784,8 +763,6 @@ mod deploy_cmd {

let mut cmd = Command::main_binary()?;
cmd.arg("compile")
.arg("--compiler")
.arg("solcjs")
.arg("--path")
.arg(&project_path);

Expand Down Expand Up @@ -839,8 +816,6 @@ mod deploy_cmd {

let mut cmd = Command::main_binary()?;
cmd.arg("compile")
.arg("--compiler")
.arg("solcjs")
.arg("--path")
.arg(&project_path);

Expand Down

0 comments on commit 112b1ac

Please sign in to comment.