Commit e40b447f authored by Jeffrey Wilcke's avatar Jeffrey Wilcke

Merge pull request #1814 from Gustav-Simonsson/common_tests

tests: update common test wrappers and test files
parents b94b9b01 47ca6904
...@@ -111,25 +111,27 @@ func runOneBlockTest(ctx *cli.Context, test *tests.BlockTest) (*eth.Ethereum, er ...@@ -111,25 +111,27 @@ func runOneBlockTest(ctx *cli.Context, test *tests.BlockTest) (*eth.Ethereum, er
if err != nil { if err != nil {
return nil, err return nil, err
} }
// if err := ethereum.Start(); err != nil {
// return nil, err
// }
// import the genesis block // import the genesis block
ethereum.ResetWithGenesisBlock(test.Genesis) ethereum.ResetWithGenesisBlock(test.Genesis)
// import pre accounts // import pre accounts
statedb, err := test.InsertPreState(ethereum) _, err = test.InsertPreState(ethereum)
if err != nil { if err != nil {
return ethereum, fmt.Errorf("InsertPreState: %v", err) return ethereum, fmt.Errorf("InsertPreState: %v", err)
} }
if err := test.TryBlocksInsert(ethereum.ChainManager()); err != nil { cm := ethereum.ChainManager()
validBlocks, err := test.TryBlocksInsert(cm)
if err != nil {
return ethereum, fmt.Errorf("Block Test load error: %v", err) return ethereum, fmt.Errorf("Block Test load error: %v", err)
} }
if err := test.ValidatePostState(statedb); err != nil { newDB := cm.State()
if err := test.ValidatePostState(newDB); err != nil {
return ethereum, fmt.Errorf("post state validation failed: %v", err) return ethereum, fmt.Errorf("post state validation failed: %v", err)
} }
return ethereum, nil
return ethereum, test.ValidateImportedHeaders(cm, validBlocks)
} }
This diff is collapsed.
This diff is collapsed.
...@@ -4826,23 +4826,23 @@ ...@@ -4826,23 +4826,23 @@
"lastblockhash" : "eed1b4da708283370856fc76352d68f36d9766b7f366da372e2992ced9a1f663", "lastblockhash" : "eed1b4da708283370856fc76352d68f36d9766b7f366da372e2992ced9a1f663",
"postState" : { "postState" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : { "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "0x14", "balance" : "0x1e",
"code" : "0x", "code" : "0x",
"nonce" : "0x00", "nonce" : "0x00",
"storage" : { "storage" : {
} }
}, },
"8888f1f195afa192cfee860698584c030f4c9db1" : { "8888f1f195afa192cfee860698584c030f4c9db1" : {
"balance" : "0x8ac7230489e8a410", "balance" : "0xd255d112e1049618",
"code" : "0x", "code" : "0x",
"nonce" : "0x00", "nonce" : "0x00",
"storage" : { "storage" : {
} }
}, },
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "0x09184e71fbdc", "balance" : "0x09184e71a9ca",
"code" : "0x", "code" : "0x",
"nonce" : "0x02", "nonce" : "0x03",
"storage" : { "storage" : {
} }
} }
......
This diff is collapsed.
...@@ -4845,6 +4845,41 @@ ...@@ -4845,6 +4845,41 @@
} }
} }
}, },
"sstore_underflow" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "0x0100",
"currentGasLimit" : "0x0f4240",
"currentNumber" : "0x00",
"currentTimestamp" : "0x01"
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"code" : "0x600155",
"data" : "0x",
"gas" : "0x0186a0",
"gasPrice" : "0x5af3107a4000",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "0x0de0b6b3a7640000"
},
"expect" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"storage" : {
"0x01" : "0x00"
}
}
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "0x152d02c7e14af6800000",
"code" : "0x600155",
"nonce" : "0x00",
"storage" : {
}
}
}
},
"stack_loop" : { "stack_loop" : {
"callcreates" : [ "callcreates" : [
], ],
......
...@@ -181,9 +181,6 @@ func runStateTest(test VmTest) error { ...@@ -181,9 +181,6 @@ func runStateTest(test VmTest) error {
// check post state // check post state
for addr, account := range test.Post { for addr, account := range test.Post {
obj := statedb.GetStateObject(common.HexToAddress(addr)) obj := statedb.GetStateObject(common.HexToAddress(addr))
if obj == nil {
continue
}
if obj.Balance().Cmp(common.Big(account.Balance)) != 0 { if obj.Balance().Cmp(common.Big(account.Balance)) != 0 {
return fmt.Errorf("(%x) balance failed. Expected %v, got %v => %v\n", obj.Address().Bytes()[:4], account.Balance, obj.Balance(), new(big.Int).Sub(common.Big(account.Balance), obj.Balance())) return fmt.Errorf("(%x) balance failed. Expected %v, got %v => %v\n", obj.Address().Bytes()[:4], account.Balance, obj.Balance(), new(big.Int).Sub(common.Big(account.Balance), obj.Balance()))
......
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