aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/geth/js_test.go
diff options
context:
space:
mode:
authorzelig <viktor.tron@gmail.com>2015-05-18 22:31:26 +0800
committerzelig <viktor.tron@gmail.com>2015-05-20 09:47:13 +0800
commitf9abcee0f9185d41c71cc24af1303133497ebeb0 (patch)
tree7e33bf08ba0a501257dcbf3bc4c5d2ab55b7ad11 /cmd/geth/js_test.go
parent79042223dc5f2ae5d4a2ed73d18907440a963093 (diff)
downloaddexon-f9abcee0f9185d41c71cc24af1303133497ebeb0.tar
dexon-f9abcee0f9185d41c71cc24af1303133497ebeb0.tar.gz
dexon-f9abcee0f9185d41c71cc24af1303133497ebeb0.tar.bz2
dexon-f9abcee0f9185d41c71cc24af1303133497ebeb0.tar.lz
dexon-f9abcee0f9185d41c71cc24af1303133497ebeb0.tar.xz
dexon-f9abcee0f9185d41c71cc24af1303133497ebeb0.tar.zst
dexon-f9abcee0f9185d41c71cc24af1303133497ebeb0.zip
fix solc tests unskip
Diffstat (limited to 'cmd/geth/js_test.go')
-rw-r--r--cmd/geth/js_test.go33
1 files changed, 19 insertions, 14 deletions
diff --git a/cmd/geth/js_test.go b/cmd/geth/js_test.go
index 6368efbfc..2f29612d3 100644
--- a/cmd/geth/js_test.go
+++ b/cmd/geth/js_test.go
@@ -24,7 +24,7 @@ import (
const (
testSolcPath = ""
- solcVersion = "0.9.17"
+ solcVersion = "0.9.23"
testKey = "e6fab74a43941f82d89cb7faa408e227cdad3153c4720e540e855c19b15e6674"
testAddress = "0x8605cdbbdb6d264aa742e77020dcbc58fcdce182"
@@ -34,6 +34,7 @@ const (
)
var (
+ versionRE = regexp.MustCompile(strconv.Quote(`"compilerVersion":"` + solcVersion + `"`))
testGenesis = `{"` + testAddress[2:] + `": {"balance": "` + testBalance + `"}}`
)
@@ -246,7 +247,6 @@ func TestSignature(t *testing.T) {
}
func TestContract(t *testing.T) {
- t.Skip()
tmp, repl, ethereum := testJEthRE(t)
if err := ethereum.Start(); err != nil {
@@ -259,7 +259,9 @@ func TestContract(t *testing.T) {
var txc uint64
coinbase := common.HexToAddress(testAddress)
resolver.New(repl.xeth).CreateContracts(coinbase)
+ // time.Sleep(1000 * time.Millisecond)
+ // checkEvalJSON(t, repl, `eth.getBlock("pending", true).transactions.length`, `2`)
source := `contract test {\n` +
" /// @notice Will multiply `a` by 7." + `\n` +
` function multiply(uint a) returns(uint d) {\n` +
@@ -279,10 +281,9 @@ func TestContract(t *testing.T) {
// if solc is found with right version, test it, otherwise read from file
sol, err := compiler.New("")
if err != nil {
- t.Logf("solc not found: skipping compiler test")
+ t.Logf("solc not found: mocking contract compilation step")
} else if sol.Version() != solcVersion {
- err = fmt.Errorf("solc wrong version found (%v, expect %v): skipping compiler test", sol.Version(), solcVersion)
- t.Log(err)
+ t.Logf("WARNING: solc different version found (%v, test written for %v, may need to update)", sol.Version(), solcVersion)
}
if err != nil {
@@ -298,7 +299,7 @@ func TestContract(t *testing.T) {
checkEvalJSON(t, repl, `contract = eth.compile.solidity(source)`, string(contractInfo))
}
- checkEvalJSON(t, repl, `contract.code`, `"605280600c6000396000f3006000357c010000000000000000000000000000000000000000000000000000000090048063c6888fa114602e57005b60376004356041565b8060005260206000f35b6000600782029050604d565b91905056"`)
+ checkEvalJSON(t, repl, `contract.code`, `"0x605880600c6000396000f3006000357c010000000000000000000000000000000000000000000000000000000090048063c6888fa114602e57005b603d6004803590602001506047565b8060005260206000f35b60006007820290506053565b91905056"`)
checkEvalJSON(
t, repl,
@@ -310,13 +311,14 @@ func TestContract(t *testing.T) {
Multiply7 = eth.contract(abiDef);
multiply7 = new Multiply7(contractaddress);
`
-
+ // time.Sleep(1500 * time.Millisecond)
_, err = repl.re.Run(callSetup)
if err != nil {
- t.Errorf("unexpected error registering, got %v", err)
+ t.Errorf("unexpected error setting up contract, got %v", err)
}
- // updatespec
+ // checkEvalJSON(t, repl, `eth.getBlock("pending", true).transactions.length`, `3`)
+
// why is this sometimes failing?
// checkEvalJSON(t, repl, `multiply7.multiply.call(6)`, `42`)
expNotice := ""
@@ -324,20 +326,23 @@ multiply7 = new Multiply7(contractaddress);
t.Errorf("incorrect confirmation message: expected %v, got %v", expNotice, repl.lastConfirm)
}
- // why 0?
- checkEvalJSON(t, repl, `eth.getBlock("pending", true).transactions.length`, `0`)
-
txc, repl.xeth = repl.xeth.ApplyTestTxs(repl.stateDb, coinbase, txc)
checkEvalJSON(t, repl, `admin.contractInfo.start()`, `true`)
checkEvalJSON(t, repl, `multiply7.multiply.sendTransaction(6, { from: primary, gas: "1000000", gasPrice: "100000" })`, `undefined`)
- expNotice = `About to submit transaction (no NatSpec info found for contract: content hash not found for '0x4a6c99e127191d2ee302e42182c338344b39a37a47cdbb17ab0f26b6802eb4d1'): {"params":[{"to":"0x5dcaace5982778b409c524873b319667eba5d074","data": "0xc6888fa10000000000000000000000000000000000000000000000000000000000000006"}]}`
+ expNotice = `About to submit transaction (no NatSpec info found for contract: content hash not found for '0x87e2802265838c7f14bb69eecd2112911af6767907a702eeaa445239fb20711b'): {"params":[{"to":"0x5dcaace5982778b409c524873b319667eba5d074","data": "0xc6888fa10000000000000000000000000000000000000000000000000000000000000006"}]}`
if repl.lastConfirm != expNotice {
t.Errorf("incorrect confirmation message: expected %v, got %v", expNotice, repl.lastConfirm)
}
+ var contenthash = `"0x86d2b7cf1e72e9a7a3f8d96601f0151742a2f780f1526414304fbe413dc7f9bd"`
+ if sol != nil {
+ modContractInfo := versionRE.ReplaceAll(contractInfo, []byte(`"compilerVersion":"`+sol.Version()+`"`))
+ _ = modContractInfo
+ // contenthash = crypto.Sha3(modContractInfo)
+ }
checkEvalJSON(t, repl, `filename = "/tmp/info.json"`, `"/tmp/info.json"`)
- checkEvalJSON(t, repl, `contenthash = admin.contractInfo.register(primary, contractaddress, contract, filename)`, `"0x0d067e2dd99a4d8f0c0279738b17130dd415a89f24a23f0e7cf68c546ae3089d"`)
+ checkEvalJSON(t, repl, `contenthash = admin.contractInfo.register(primary, contractaddress, contract, filename)`, contenthash)
checkEvalJSON(t, repl, `admin.contractInfo.registerUrl(primary, contenthash, "file://"+filename)`, `true`)
if err != nil {
t.Errorf("unexpected error registering, got %v", err)