aboutsummaryrefslogtreecommitdiffstats
path: root/common/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'common/compiler')
-rw-r--r--common/compiler/solidity.go8
-rw-r--r--common/compiler/solidity_test.go8
2 files changed, 6 insertions, 10 deletions
diff --git a/common/compiler/solidity.go b/common/compiler/solidity.go
index caf86974e..4d5ffb473 100644
--- a/common/compiler/solidity.go
+++ b/common/compiler/solidity.go
@@ -185,12 +185,12 @@ func (sol *Solidity) Compile(source string) (contracts map[string]*Contract, err
return
}
-func ExtractInfo(contract *Contract, filename string) (contenthash common.Hash, err error) {
- contractInfo, err := json.Marshal(contract.Info)
+func SaveInfo(info *ContractInfo, filename string) (contenthash common.Hash, err error) {
+ infojson, err := json.Marshal(info)
if err != nil {
return
}
- contenthash = common.BytesToHash(crypto.Sha3(contractInfo))
- err = ioutil.WriteFile(filename, contractInfo, 0600)
+ contenthash = common.BytesToHash(crypto.Sha3(infojson))
+ err = ioutil.WriteFile(filename, infojson, 0600)
return
}
diff --git a/common/compiler/solidity_test.go b/common/compiler/solidity_test.go
index 59b6b6cd6..b493d6be3 100644
--- a/common/compiler/solidity_test.go
+++ b/common/compiler/solidity_test.go
@@ -72,19 +72,15 @@ func TestNoCompiler(t *testing.T) {
}
}
-func TestExtractInfo(t *testing.T) {
+func TestSaveInfo(t *testing.T) {
var cinfo ContractInfo
err := json.Unmarshal([]byte(info), &cinfo)
if err != nil {
t.Errorf("%v", err)
}
- contract := &Contract{
- Code: "",
- Info: cinfo,
- }
filename := "/tmp/solctest.info.json"
os.Remove(filename)
- cinfohash, err := ExtractInfo(contract, filename)
+ cinfohash, err := SaveInfo(&cinfo, filename)
if err != nil {
t.Errorf("error extracting info: %v", err)
}