diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-04-13 21:26:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-13 21:26:38 +0800 |
commit | 732b75325ca989db1ce51c334560a5f015b136ba (patch) | |
tree | 2fee5db40047b7b8d93817f0b43cc466ee9e9b2b /common/compiler/solidity_test.go | |
parent | 906378a32e49ff3eff2b729a7a75dd273f12dc32 (diff) | |
parent | 728a299728aaaeaf14f21bdaa9171e857f716b68 (diff) | |
download | dexon-732b75325ca989db1ce51c334560a5f015b136ba.tar dexon-732b75325ca989db1ce51c334560a5f015b136ba.tar.gz dexon-732b75325ca989db1ce51c334560a5f015b136ba.tar.bz2 dexon-732b75325ca989db1ce51c334560a5f015b136ba.tar.lz dexon-732b75325ca989db1ce51c334560a5f015b136ba.tar.xz dexon-732b75325ca989db1ce51c334560a5f015b136ba.tar.zst dexon-732b75325ca989db1ce51c334560a5f015b136ba.zip |
Merge pull request #3786 from fjl/compiler-metadata
common/compiler: add metadata output for solc > 0.4.6
Diffstat (limited to 'common/compiler/solidity_test.go')
-rw-r--r-- | common/compiler/solidity_test.go | 37 |
1 files changed, 4 insertions, 33 deletions
diff --git a/common/compiler/solidity_test.go b/common/compiler/solidity_test.go index f16637547..0da3bb337 100644 --- a/common/compiler/solidity_test.go +++ b/common/compiler/solidity_test.go @@ -17,14 +17,8 @@ package compiler import ( - "encoding/json" - "io/ioutil" - "os" "os/exec" - "path" "testing" - - "github.com/ethereum/go-ethereum/common" ) const ( @@ -36,7 +30,6 @@ contract test { } } ` - 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 --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 skipWithoutSolc(t *testing.T) { @@ -57,7 +50,10 @@ func TestCompiler(t *testing.T) { } c, ok := contracts["test"] if !ok { - t.Fatal("info for contract 'test' not present in result") + c, ok = contracts["<stdin>:test"] + if !ok { + t.Fatal("info for contract 'test' not present in result") + } } if c.Code == "" { t.Error("empty code") @@ -79,28 +75,3 @@ func TestCompileError(t *testing.T) { } t.Logf("error: %v", err) } - -func TestSaveInfo(t *testing.T) { - var cinfo ContractInfo - err := json.Unmarshal([]byte(testInfo), &cinfo) - if err != nil { - t.Errorf("%v", err) - } - filename := path.Join(os.TempDir(), "solctest.info.json") - os.Remove(filename) - cinfohash, err := SaveInfo(&cinfo, filename) - if err != nil { - t.Errorf("error extracting info: %v", err) - } - got, err := ioutil.ReadFile(filename) - if err != nil { - t.Errorf("error reading '%v': %v", filename, err) - } - if string(got) != testInfo { - t.Errorf("incorrect info.json extracted, expected:\n%s\ngot\n%s", testInfo, string(got)) - } - wantHash := common.HexToHash("0x22450a77f0c3ff7a395948d07bc1456881226a1b6325f4189cb5f1254a824080") - if cinfohash != wantHash { - t.Errorf("content hash for info is incorrect. expected %v, got %v", wantHash.Hex(), cinfohash.Hex()) - } -} |