Commit 98998534 authored by Jeffrey Wilcke's avatar Jeffrey Wilcke

Merge pull request #995 from Gustav-Simonsson/update_state_tests_and_vm_create_return

Update state tests and vm create return
parents 164ba56a 619e8a4f
...@@ -205,6 +205,7 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er ...@@ -205,6 +205,7 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er
if err := self.UseGas(dataGas); err == nil { if err := self.UseGas(dataGas); err == nil {
ref.SetCode(ret) ref.SetCode(ret)
} else { } else {
ret = nil // does not affect consensus but useful for StateTests validations
glog.V(logger.Core).Infoln("Insufficient gas for creating code. Require", dataGas, "and have", self.gas) glog.V(logger.Core).Infoln("Insufficient gas for creating code. Require", dataGas, "and have", self.gas)
} }
} }
......
{
"GithubWikiTest": {
"args": [
291,
[
1110,
1929
],
"1234567890",
"Hello, world!"
],
"result": "00000000000000000000000000000000000000000000000000000000000001230000000000000000000000000000000000000000000000000000000000000080313233343536373839300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000004560000000000000000000000000000000000000000000000000000000000000789000000000000000000000000000000000000000000000000000000000000000d48656c6c6f2c20776f726c642100000000000000000000000000000000000000",
"types": [
"uint256",
"uint32[]",
"bytes10",
"bytes"
]
},
"SingleInteger": {
"args": [
98127491
],
"result": "0000000000000000000000000000000000000000000000000000000005d94e83",
"types": [
"uint256"
]
},
"IntegerAndAddress": {
"args": [
324124,
"cd2a3d9f938e13cd947ec05abc7fe734df8dd826"
],
"result": "000000000000000000000000000000000000000000000000000000000004f21c000000000000000000000000cd2a3d9f938e13cd947ec05abc7fe734df8dd826",
"types": [
"uint256",
"address"
]
}
}
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
...@@ -996,6 +996,188 @@ ...@@ -996,6 +996,188 @@
"value" : "0x0186a0" "value" : "0x0186a0"
} }
}, },
"createNameRegistratorPerTxs" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "0x0100",
"currentGasLimit" : "0x02540be400",
"currentNumber" : "0x00",
"currentTimestamp" : "0x01",
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"logs" : [
],
"out" : "0x396000f3006000355415600957005b60",
"post" : {
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "0xb44e",
"code" : "0x",
"nonce" : "0x00",
"storage" : {
}
},
"6295ee1b4f6dd65047762f924ecd367c17eabf8f" : {
"balance" : "0x0186a0",
"code" : "0x396000f3006000355415600957005b60",
"nonce" : "0x00",
"storage" : {
"0x01" : "0x01"
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "0x0de0b6b3a761c512",
"code" : "0x",
"nonce" : "0x01",
"storage" : {
}
}
},
"postStateRoot" : "e0911f5b8035d9192581b3a82ddb0a32955e880088c49e92936789be2310ef90",
"pre" : {
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "0x0de0b6b3a7640000",
"code" : "0x",
"nonce" : "0x00",
"storage" : {
}
}
},
"transaction" : {
"data" : "0x6001600155601080600c6000396000f3006000355415600957005b60203560003555",
"gasLimit" : "0xb44e",
"gasPrice" : "0x01",
"nonce" : "0x00",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "",
"value" : "0x0186a0"
}
},
"createNameRegistratorPerTxsNotEnoughGas" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "0x0100",
"currentGasLimit" : "0x02540be400",
"currentNumber" : "0x00",
"currentTimestamp" : "0x01",
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"logs" : [
],
"out" : "0x",
"post" : {
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "0xa7ce",
"code" : "0x",
"nonce" : "0x00",
"storage" : {
}
},
"6295ee1b4f6dd65047762f924ecd367c17eabf8f" : {
"balance" : "0x0186a0",
"code" : "0x",
"nonce" : "0x00",
"storage" : {
"0x01" : "0x01"
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "0x0de0b6b3a761d192",
"code" : "0x",
"nonce" : "0x01",
"storage" : {
}
}
},
"postStateRoot" : "6dcd1874a8295fa628ca7c100e9fa6248e74b92afd9a7b8511879078dfc2f007",
"pre" : {
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "0x0de0b6b3a7640000",
"code" : "0x",
"nonce" : "0x00",
"storage" : {
}
}
},
"transaction" : {
"data" : "0x6001600155601080600c6000396000f3006000355415600957005b60203560003555",
"gasLimit" : "0xb44d",
"gasPrice" : "0x01",
"nonce" : "0x00",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "",
"value" : "0x0186a0"
}
},
"createNameRegistratorPreStore1NotEnoughGas" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "0x0100",
"currentGasLimit" : "0x05f5e100",
"currentNumber" : "0x00",
"currentTimestamp" : "0x01",
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"logs" : [
],
"out" : "0x",
"post" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "0x0de0b6b3a7658689",
"code" : "0x7f6001600155601080600c6000396000f3006000355415600957005b602035600060005260356020536055602153602260006017f0",
"nonce" : "0x01",
"storage" : {
}
},
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "0x011d70",
"code" : "0x",
"nonce" : "0x00",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "0x0de0b6b3a7615bf0",
"code" : "0x",
"nonce" : "0x01",
"storage" : {
}
},
"d2571607e241ecf590ed94b12d87c94babe36db6" : {
"balance" : "0x17",
"code" : "0x",
"nonce" : "0x00",
"storage" : {
"0x01" : "0x01"
}
}
},
"postStateRoot" : "86a4e893a117e2e38a77247e6b01a29680bb0e0fc68807885231f527720d18c0",
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "0x0de0b6b3a7640000",
"code" : "0x7f6001600155601080600c6000396000f3006000355415600957005b602035600060005260356020536055602153602260006017f0",
"nonce" : "0x00",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "0x0de0b6b3a7640000",
"code" : "0x",
"nonce" : "0x00",
"storage" : {
}
}
},
"transaction" : {
"data" : "",
"gasLimit" : "0x0129ef",
"gasPrice" : "0x01",
"nonce" : "0x00",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "0x0186a0"
}
},
"createNameRegistratorendowmentTooHigh" : { "createNameRegistratorendowmentTooHigh" : {
"env" : { "env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -163,6 +163,7 @@ func RunState(statedb *state.StateDB, env, tx map[string]string) ([]byte, state. ...@@ -163,6 +163,7 @@ func RunState(statedb *state.StateDB, env, tx map[string]string) ([]byte, state.
gas = common.Big(tx["gasLimit"]) gas = common.Big(tx["gasLimit"])
price = common.Big(tx["gasPrice"]) price = common.Big(tx["gasPrice"])
value = common.Big(tx["value"]) value = common.Big(tx["value"])
nonce = common.Big(tx["nonce"]).Uint64()
caddr = common.HexToAddress(env["currentCoinbase"]) caddr = common.HexToAddress(env["currentCoinbase"])
) )
...@@ -178,7 +179,7 @@ func RunState(statedb *state.StateDB, env, tx map[string]string) ([]byte, state. ...@@ -178,7 +179,7 @@ func RunState(statedb *state.StateDB, env, tx map[string]string) ([]byte, state.
coinbase := statedb.GetOrNewStateObject(caddr) coinbase := statedb.GetOrNewStateObject(caddr)
coinbase.SetGasPool(common.Big(env["currentGasLimit"])) coinbase.SetGasPool(common.Big(env["currentGasLimit"]))
message := NewMessage(common.BytesToAddress(keyPair.Address()), to, data, value, gas, price) message := NewMessage(common.BytesToAddress(keyPair.Address()), to, data, value, gas, price, nonce)
vmenv := NewEnvFromMap(statedb, env, tx) vmenv := NewEnvFromMap(statedb, env, tx)
vmenv.origin = common.BytesToAddress(keyPair.Address()) vmenv.origin = common.BytesToAddress(keyPair.Address())
ret, _, err := core.ApplyMessage(vmenv, message, coinbase) ret, _, err := core.ApplyMessage(vmenv, message, coinbase)
...@@ -195,10 +196,11 @@ type Message struct { ...@@ -195,10 +196,11 @@ type Message struct {
to *common.Address to *common.Address
value, gas, price *big.Int value, gas, price *big.Int
data []byte data []byte
nonce uint64
} }
func NewMessage(from common.Address, to *common.Address, data []byte, value, gas, price *big.Int) Message { func NewMessage(from common.Address, to *common.Address, data []byte, value, gas, price *big.Int, nonce uint64) Message {
return Message{from, to, value, gas, price, data} return Message{from, to, value, gas, price, data, nonce}
} }
func (self Message) Hash() []byte { return nil } func (self Message) Hash() []byte { return nil }
...@@ -207,5 +209,5 @@ func (self Message) To() *common.Address { return self.to } ...@@ -207,5 +209,5 @@ func (self Message) To() *common.Address { return self.to }
func (self Message) GasPrice() *big.Int { return self.price } func (self Message) GasPrice() *big.Int { return self.price }
func (self Message) Gas() *big.Int { return self.gas } func (self Message) Gas() *big.Int { return self.gas }
func (self Message) Value() *big.Int { return self.value } func (self Message) Value() *big.Int { return self.value }
func (self Message) Nonce() uint64 { return 0 } func (self Message) Nonce() uint64 { return self.nonce }
func (self Message) Data() []byte { return self.data } func (self Message) Data() []byte { return self.data }
...@@ -2,7 +2,9 @@ package vm ...@@ -2,7 +2,9 @@ package vm
import ( import (
"bytes" "bytes"
"io/ioutil"
"math/big" "math/big"
"path/filepath"
"strconv" "strconv"
"testing" "testing"
...@@ -269,8 +271,13 @@ func TestVmLog(t *testing.T) { ...@@ -269,8 +271,13 @@ func TestVmLog(t *testing.T) {
RunVmTest(fn, t) RunVmTest(fn, t)
} }
func TestInputLimits1(t *testing.T) { func TestInputLimits(t *testing.T) {
const fn = "../files/VMTests/vmInputLimits1.json" const fn = "../files/VMTests/vmInputLimits.json"
RunVmTest(fn, t)
}
func TestInputLimitsLight(t *testing.T) {
const fn = "../files/VMTests/vmInputLimitsLight.json"
RunVmTest(fn, t) RunVmTest(fn, t)
} }
...@@ -320,7 +327,6 @@ func TestStateLog(t *testing.T) { ...@@ -320,7 +327,6 @@ func TestStateLog(t *testing.T) {
} }
func TestStateTransaction(t *testing.T) { func TestStateTransaction(t *testing.T) {
t.Skip()
const fn = "../files/StateTests/stTransactionTest.json" const fn = "../files/StateTests/stTransactionTest.json"
RunVmTest(fn, t) RunVmTest(fn, t)
} }
...@@ -351,3 +357,27 @@ func TestSolidity(t *testing.T) { ...@@ -351,3 +357,27 @@ func TestSolidity(t *testing.T) {
const fn = "../files/StateTests/stSolidityTest.json" const fn = "../files/StateTests/stSolidityTest.json"
RunVmTest(fn, t) RunVmTest(fn, t)
} }
func TestWallet(t *testing.T) {
const fn = "../files/StateTests/stWalletTest.json"
RunVmTest(fn, t)
}
func TestRandom(t *testing.T) {
// TODO: fix JSON EOF bug and unskip
t.Skip()
fileNames := make([]string, 1024)
fileInfos, err := ioutil.ReadDir("../files/StateTests/RandomTests")
if err != nil {
t.Errorf("Could not read StateTests/RandomTests dir: %v", err)
return
}
for _, fileInfo := range fileInfos {
fileNames = append(fileNames, fileInfo.Name())
}
//for _, f := range fileNames {
path := filepath.Join("../files/StateTests/RandomTests/", fileNames[0])
RunVmTest(path, t)
//}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment