aboutsummaryrefslogtreecommitdiffstats
path: root/common/compiler/solidity_test.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@users.noreply.github.com>2017-01-06 22:39:35 +0800
committerGitHub <noreply@github.com>2017-01-06 22:39:35 +0800
commite0fde022909d272e55fb9ea2d4f8cfe9f178dba8 (patch)
tree92897edefa0616b2d3823ebb34d8ec7f30c945fa /common/compiler/solidity_test.go
parent59b8245bbced3c0511623ecaa8b7d4e0434343cd (diff)
downloadgo-tangerine-e0fde022909d272e55fb9ea2d4f8cfe9f178dba8.tar
go-tangerine-e0fde022909d272e55fb9ea2d4f8cfe9f178dba8.tar.gz
go-tangerine-e0fde022909d272e55fb9ea2d4f8cfe9f178dba8.tar.bz2
go-tangerine-e0fde022909d272e55fb9ea2d4f8cfe9f178dba8.tar.lz
go-tangerine-e0fde022909d272e55fb9ea2d4f8cfe9f178dba8.tar.xz
go-tangerine-e0fde022909d272e55fb9ea2d4f8cfe9f178dba8.tar.zst
go-tangerine-e0fde022909d272e55fb9ea2d4f8cfe9f178dba8.zip
common/compiler: remove workaround for solc 0.3.5 stdin bug (#3522)
The crash when compiling stdin was fixed in solc 0.3.6 (released 2016-08-10). While here, simplify the test so it runs with any solc version. Fixes #3484. The byte code was different for each run because recent solc embeds the swarm hash of contract metadata into the code. When compiling from stdin the name in the metadata is constant.
Diffstat (limited to 'common/compiler/solidity_test.go')
-rw-r--r--common/compiler/solidity_test.go28
1 files changed, 12 insertions, 16 deletions
diff --git a/common/compiler/solidity_test.go b/common/compiler/solidity_test.go
index e4d96bd01..8ba9e55d0 100644
--- a/common/compiler/solidity_test.go
+++ b/common/compiler/solidity_test.go
@@ -20,6 +20,7 @@ import (
"encoding/json"
"io/ioutil"
"os"
+ "os/exec"
"path"
"testing"
@@ -27,8 +28,7 @@ import (
)
const (
- supportedSolcVersion = "0.3.5"
- testSource = `
+ testSource = `
contract test {
/// @notice Will multiply ` + "`a`" + ` by 7.
function multiply(uint a) returns(uint d) {
@@ -36,23 +36,18 @@ contract test {
}
}
`
- testCode = "0x6060604052602a8060106000396000f3606060405260e060020a6000350463c6888fa18114601a575b005b6007600435026060908152602090f3"
testInfo = `{"source":"\ncontract test {\n /// @notice Will multiply ` + "`a`" + ` by 7.\n function multiply(uint a) returns(uint d) {\n return a * 7;\n }\n}\n","language":"Solidity","languageVersion":"0.1.1","compilerVersion":"0.1.1","compilerOptions":"--binary file --json-abi file --natspec-user file --natspec-dev file --add-std 1","abiDefinition":[{"constant":false,"inputs":[{"name":"a","type":"uint256"}],"name":"multiply","outputs":[{"name":"d","type":"uint256"}],"type":"function"}],"userDoc":{"methods":{"multiply(uint256)":{"notice":"Will multiply ` + "`a`" + ` by 7."}}},"developerDoc":{"methods":{}}}`
)
-func skipUnsupported(t *testing.T) {
- sol, err := SolidityVersion("")
- if err != nil {
+func skipWithoutSolc(t *testing.T) {
+ if _, err := exec.LookPath("solc"); err != nil {
t.Skip(err)
- return
- }
- if sol.Version != supportedSolcVersion {
- t.Skipf("unsupported version of solc found (%v, expect %v)", sol.Version, supportedSolcVersion)
}
}
func TestCompiler(t *testing.T) {
- skipUnsupported(t)
+ skipWithoutSolc(t)
+
contracts, err := CompileSolidityString("", testSource)
if err != nil {
t.Fatalf("error compiling source. result %v: %v", contracts, err)
@@ -64,19 +59,20 @@ func TestCompiler(t *testing.T) {
if !ok {
t.Fatal("info for contract 'test' not present in result")
}
- if c.Code != testCode {
- t.Errorf("wrong code: expected\n%s, got\n%s", testCode, c.Code)
+ if c.Code == "" {
+ t.Error("empty code")
}
if c.Info.Source != testSource {
t.Error("wrong source")
}
- if c.Info.CompilerVersion != supportedSolcVersion {
- t.Errorf("wrong version: expected %q, got %q", supportedSolcVersion, c.Info.CompilerVersion)
+ if c.Info.CompilerVersion == "" {
+ t.Error("empty version")
}
}
func TestCompileError(t *testing.T) {
- skipUnsupported(t)
+ skipWithoutSolc(t)
+
contracts, err := CompileSolidityString("", testSource[4:])
if err == nil {
t.Errorf("error expected compiling source. got none. result %v", contracts)