aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/api_test.go
diff options
context:
space:
mode:
authorzelig <viktor.tron@gmail.com>2015-05-20 11:11:48 +0800
committerzelig <viktor.tron@gmail.com>2015-05-20 11:11:48 +0800
commitb0ae84aa0dae65f00492f981bb61887331def2a5 (patch)
tree369d5c342c6df8b5486c386663806937a4d9def1 /rpc/api_test.go
parentea893aca8fbda0d821424ab7509a0a0cfef1f77d (diff)
downloadgo-tangerine-b0ae84aa0dae65f00492f981bb61887331def2a5.tar.gz
go-tangerine-b0ae84aa0dae65f00492f981bb61887331def2a5.tar.zst
go-tangerine-b0ae84aa0dae65f00492f981bb61887331def2a5.zip
multiple contract source for solidity compiler: returns contract array if multiple contracts. fixes #1023
Diffstat (limited to 'rpc/api_test.go')
-rw-r--r--rpc/api_test.go24
1 files changed, 14 insertions, 10 deletions
diff --git a/rpc/api_test.go b/rpc/api_test.go
index 263e9666d..d1dcad266 100644
--- a/rpc/api_test.go
+++ b/rpc/api_test.go
@@ -2,14 +2,11 @@ package rpc
import (
"encoding/json"
- // "sync"
- "testing"
- // "time"
- // "fmt"
- "io/ioutil"
"strconv"
+ "testing"
"github.com/ethereum/go-ethereum/common/compiler"
+ "github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/xeth"
)
@@ -58,7 +55,7 @@ func TestCompileSolidity(t *testing.T) {
expLanguageVersion := "0"
expSource := source
- api := NewEthereumApi(&xeth.XEth{})
+ api := NewEthereumApi(xeth.NewTest(&eth.Ethereum{}, nil))
var req RpcRequest
json.Unmarshal([]byte(jsonstr), &req)
@@ -73,12 +70,18 @@ func TestCompileSolidity(t *testing.T) {
t.Errorf("expected no error, got %v", err)
}
- var contract = compiler.Contract{}
- err = json.Unmarshal(respjson, &contract)
+ var contracts = make(map[string]*compiler.Contract)
+ err = json.Unmarshal(respjson, &contracts)
if err != nil {
t.Errorf("expected no error, got %v", err)
}
+ if len(contracts) != 1 {
+ t.Errorf("expected one contract, got %v", len(contracts))
+ }
+
+ contract := contracts["test"]
+
if contract.Code != expCode {
t.Errorf("Expected \n%s got \n%s", expCode, contract.Code)
}
@@ -86,12 +89,15 @@ func TestCompileSolidity(t *testing.T) {
if strconv.Quote(contract.Info.Source) != `"`+expSource+`"` {
t.Errorf("Expected \n'%s' got \n'%s'", expSource, strconv.Quote(contract.Info.Source))
}
+
if contract.Info.Language != expLanguage {
t.Errorf("Expected %s got %s", expLanguage, contract.Info.Language)
}
+
if contract.Info.LanguageVersion != expLanguageVersion {
t.Errorf("Expected %s got %s", expLanguageVersion, contract.Info.LanguageVersion)
}
+
if contract.Info.CompilerVersion != expCompilerVersion {
t.Errorf("Expected %s got %s", expCompilerVersion, contract.Info.CompilerVersion)
}
@@ -114,8 +120,6 @@ func TestCompileSolidity(t *testing.T) {
if string(abidef) != expAbiDefinition {
t.Errorf("Expected \n'%s' got \n'%s'", expAbiDefinition, string(abidef))
}
- ioutil.WriteFile("/tmp/abidef", []byte(string(abidef)), 0700)
- ioutil.WriteFile("/tmp/expabidef", []byte(expAbiDefinition), 0700)
if string(userdoc) != expUserDoc {
t.Errorf("Expected \n'%s' got \n'%s'", expUserDoc, string(userdoc))