Commit 2fe54ab2 authored by Jeffrey Wilcke's avatar Jeffrey Wilcke

Merge pull request #779 from Gustav-Simonsson/block_tests_reloaded

Block tests reloaded
parents 0071fbed 49da462e
......@@ -219,14 +219,21 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (logs st
// can be used by light clients to make sure they've received the correct Txs
txSha := types.DeriveSha(block.Transactions())
if txSha != header.TxHash {
err = fmt.Errorf("validating transaction root. received=%x got=%x", header.TxHash, txSha)
err = fmt.Errorf("invalid transaction root hash. received=%x calculated=%x", header.TxHash, txSha)
return
}
// Tre receipt Trie's root (R = (Tr [[H1, R1], ... [Hn, R1]]))
receiptSha := types.DeriveSha(receipts)
if receiptSha != header.ReceiptHash {
err = fmt.Errorf("validating receipt root. received=%x got=%x", header.ReceiptHash, receiptSha)
err = fmt.Errorf("invalid receipt root hash. received=%x calculated=%x", header.ReceiptHash, receiptSha)
return
}
// Verify UncleHash before running other uncle validations
unclesSha := block.CalculateUnclesHash()
if unclesSha != header.UncleHash {
err = fmt.Errorf("invalid uncles root hash. received=%x calculated=%x", header.UncleHash, unclesSha)
return
}
......
......@@ -209,6 +209,10 @@ func (self *Block) Uncles() []*Header {
return self.uncles
}
func (self *Block) CalculateUnclesHash() common.Hash {
return rlpHash(self.uncles)
}
func (self *Block) SetUncles(uncleHeaders []*Header) {
self.uncles = uncleHeaders
self.header.UncleHash = rlpHash(uncleHeaders)
......
......@@ -29,22 +29,12 @@ func TestBcUncleHeaderValidityTests(t *testing.T) {
func TestBcInvalidHeaderTests(t *testing.T) {
t.Skip("Skipped in lieu of performance fixes.")
snafus := []string{
"wrongUncleHash", // TODO: why does this fail?
}
runBlockTestsInFile("files/BlockTests/bcInvalidHeaderTest.json", snafus, t)
runBlockTestsInFile("files/BlockTests/bcInvalidHeaderTest.json", []string{}, t)
}
func TestBcInvalidRLPTests(t *testing.T) {
t.Skip("Skipped in lieu of performance fixes.")
snafus := []string{
// TODO: why does these fail?
"TRANSCT__ZeroByteAtTheEnd",
"TRANSCT__RandomByteAtTheEnd",
"BLOCK__ZeroByteAtTheEnd",
"BLOCK__RandomByteAtTheEnd",
}
runBlockTestsInFile("files/BlockTests/bcInvalidRLPTest.json", snafus, t)
runBlockTestsInFile("files/BlockTests/bcInvalidRLPTest.json", []string{}, t)
}
func TestBcJSAPITests(t *testing.T) {
......
......@@ -226,10 +226,10 @@ func mustConvertHeader(in btHeader) *types.Header {
UncleHash: mustConvertHash(in.UncleHash),
ParentHash: mustConvertHash(in.ParentHash),
Extra: mustConvertBytes(in.ExtraData),
GasUsed: mustConvertBigInt(in.GasUsed, 10),
GasLimit: mustConvertBigInt(in.GasLimit, 10),
Difficulty: mustConvertBigInt(in.Difficulty, 10),
Time: mustConvertUint(in.Timestamp, 10),
GasUsed: mustConvertBigInt(in.GasUsed, 16),
GasLimit: mustConvertBigInt(in.GasLimit, 16),
Difficulty: mustConvertBigInt(in.Difficulty, 16),
Time: mustConvertUint(in.Timestamp, 16),
}
// XXX cheats? :-)
header.SetNonce(mustConvertUint(in.Nonce, 16))
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -2,7 +2,7 @@
"RLPLengthOfLengthWithFirstZeros" : {
"blocks" : [
{
"rlp" : "0xfa000260f901f9a02a3c692012a15502ba9c39f3aebb36694eed978c74b52e6c0cf210d301dbf325a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a0b6c9fd1447d0b414a1f05957927746f58ef5a2ebde17db631d460eaf6a93b18da0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd8825208845509814280a00451dd53d9c09f3cfb627b51d9d80632ed801f6330ee584bffc26caac9b9249f88c7bffe5ebd94cc2ff861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba098c3a099885a281885f487fd37550de16436e8c47874cd213531b10fe751617fa044b6b81011ce57bffcaf610bf728fb8a7237ad261ea2d937423d78eb9e137076c0"
"rlp" : "0xfb00000260f901f9a02a3c692012a15502ba9c39f3aebb36694eed978c74b52e6c0cf210d301dbf325a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a0b6c9fd1447d0b414a1f05957927746f58ef5a2ebde17db631d460eaf6a93b18da0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd8825208845509814280a00451dd53d9c09f3cfb627b51d9d80632ed801f6330ee584bffc26caac9b9249f88c7bffe5ebd94cc2ff861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba098c3a099885a281885f487fd37550de16436e8c47874cd213531b10fe751617fa044b6b81011ce57bffcaf610bf728fb8a7237ad261ea2d937423d78eb9e137076c0"
}
],
"genesisBlockHeader" : {
......
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 diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -15,7 +15,7 @@
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "0x0de0b6b3a764000a",
"code" : "0x600040600055600540600155600440600255",
"nonce" : "0x",
"nonce" : "0x00",
"storage" : {
"0x" : "0x044852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d",
"0x02" : "0x13600b294191fc92924bb3ce4b969c1e7e2bab8f4c93c3fc6d0a51733df3c060"
......@@ -24,7 +24,7 @@
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "0x01021e",
"code" : "0x",
"nonce" : "0x",
"nonce" : "0x00",
"storage" : {
}
},
......@@ -41,23 +41,23 @@
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "0x0de0b6b3a7640000",
"code" : "0x600040600055600540600155600440600255",
"nonce" : "0x",
"nonce" : "0x00",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "0x0f4240",
"code" : "0x",
"nonce" : "0x",
"nonce" : "0x00",
"storage" : {
}
}
},
"transaction" : {
"data" : "0x",
"data" : "",
"gasLimit" : "0x045948",
"gasPrice" : "0x01",
"nonce" : "0x",
"nonce" : "0x00",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "0x0a"
......@@ -79,7 +79,7 @@
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "0x0de0b6b3a764000a",
"code" : "0x60014060005560024060015561010040600255",
"nonce" : "0x",
"nonce" : "0x00",
"storage" : {
"0x" : "0xc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6",
"0x01" : "0xad7c5bef027816a800da1736444fb58a807ef4c9603b7848673f7e3a68eb14a5",
......@@ -89,7 +89,7 @@
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "0x013cb6",
"code" : "0x",
"nonce" : "0x",
"nonce" : "0x00",
"storage" : {
}
},
......@@ -106,23 +106,23 @@
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "0x0de0b6b3a7640000",
"code" : "0x60014060005560024060015561010040600255",
"nonce" : "0x",
"nonce" : "0x00",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "0x0f4240",
"code" : "0x",
"nonce" : "0x",
"nonce" : "0x00",
"storage" : {
}
}
},
"transaction" : {
"data" : "0x",
"data" : "",
"gasLimit" : "0x045948",
"gasPrice" : "0x01",
"nonce" : "0x",
"nonce" : "0x00",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "0x0a"
......@@ -144,14 +144,14 @@
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "0x0de0b6b3a7640000",
"code" : "0x600040600055610101406001557fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff40600255",
"nonce" : "0x",
"nonce" : "0x00",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "0x0f4240",
"code" : "0x",
"nonce" : "0x",
"nonce" : "0x00",
"storage" : {
}
}
......@@ -161,23 +161,23 @@
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "0x0de0b6b3a7640000",
"code" : "0x600040600055610101406001557fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff40600255",
"nonce" : "0x",
"nonce" : "0x00",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "0x0f4240",
"code" : "0x",
"nonce" : "0x",
"nonce" : "0x00",
"storage" : {
}
}
},
"transaction" : {
"data" : "0x",
"data" : "",
"gasLimit" : "0x2b7cd0",
"gasPrice" : "0x01",
"nonce" : "0x",
"nonce" : "0x00",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "0x0a"
......
......@@ -4,7 +4,7 @@
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "0x0100",
"currentGasLimit" : "0x0f4240",
"currentNumber" : "0x",
"currentNumber" : "0x00",
"currentTimestamp" : "0x01",
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
......@@ -15,7 +15,7 @@
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "0x0de0b6b3a76586a0",
"code" : "0x6001600101600055",
"nonce" : "0x",
"nonce" : "0x00",
"storage" : {
"0x" : "0x02"
}
......@@ -23,7 +23,7 @@
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "0xa034",
"code" : "0x",
"nonce" : "0x",
"nonce" : "0x00",
"storage" : {
}
},
......@@ -40,23 +40,23 @@
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "0x0de0b6b3a7640000",
"code" : "0x6001600101600055",
"nonce" : "0x",
"nonce" : "0x00",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "0x0de0b6b3a7640000",
"code" : "0x",
"nonce" : "0x",
"nonce" : "0x00",
"storage" : {
}
}
},
"transaction" : {
"data" : "0x",
"data" : "",
"gasLimit" : "0x061a80",
"gasPrice" : "0x01",
"nonce" : "0x",
"nonce" : "0x00",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "0x0186a0"
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -4,7 +4,7 @@
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "0x0100",
"currentGasLimit" : "0x989680",
"currentNumber" : "0x",
"currentNumber" : "0x00",
"currentTimestamp" : "0x01",
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
......@@ -13,7 +13,7 @@
"out" : "0x",
"post" : {
"04110d816c380812a427968ece99b1c963dfbce6" : {
"balance" : "0x",
"balance" : "0x00",
"code" : "0x",
"nonce" : "0x01",
"storage" : {
......@@ -27,7 +27,7 @@
}
},
"24dd378f51adc67a50e339e8031fe9bd4aafab36" : {
"balance" : "0x",
"balance" : "0x00",
"code" : "0x",
"nonce" : "0x01",
"storage" : {
......@@ -36,54 +36,54 @@
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "0x071948",
"code" : "0x",
"nonce" : "0x",
"nonce" : "0x00",
"storage" : {
}
},
"2cf5732f017b0cf1b1f13a1478e10239716bf6b5" : {
"balance" : "0x",
"balance" : "0x00",
"code" : "0x",
"nonce" : "0x01",
"storage" : {
}
},
"37f998764813b136ddf5a754f34063fd03065e36" : {
"balance" : "0x",
"balance" : "0x00",
"code" : "0x",
"nonce" : "0x01",
"storage" : {
}
},
"37fa399a749c121f8a15ce77e3d9f9bec8020d7a" : {
"balance" : "0x",
"balance" : "0x00",
"code" : "0x",
"nonce" : "0x01",
"storage" : {
}
},
"62c01474f089b07dae603491675dc5b5748f7049" : {
"balance" : "0x",
"balance" : "0x00",
"code" : "0x",
"nonce" : "0x01",
"storage" : {
}
},
"83e3e5a16d3b696a0314b30b2534804dd5e11197" : {
"balance" : "0x",
"balance" : "0x00",
"code" : "0x",
"nonce" : "0x01",
"storage" : {
}
},
"8703df2417e0d7c59d063caa9583cb10a4d20532" : {
"balance" : "0x",
"balance" : "0x00",
"code" : "0x",
"nonce" : "0x01",
"storage" : {
}
},
"99b2fcba8120bedd048fe79f5262a6690ed38c39" : {
"balance" : "0x",
"balance" : "0x00",
"code" : "0x",
"nonce" : "0x01",
"storage" : {
......@@ -97,21 +97,21 @@
}
},
"a9647f4a0a14042d91dc33c0328030a7157c93ae" : {
"balance" : "0x",
"balance" : "0x00",
"code" : "0x",
"nonce" : "0x01",
"storage" : {
}
},
"aae4a2e3c51c04606dcb3723456e58f3ed214f45" : {
"balance" : "0x",
"balance" : "0x00",
"code" : "0x",
"nonce" : "0x01",
"storage" : {
}
},
"d2571607e241ecf590ed94b12d87c94babe36db6" : {
"balance" : "0x",
"balance" : "0x00",
"code" : "0x",
"nonce" : "0x01",
"storage" : {
......@@ -123,23 +123,23 @@
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "0x01312d00",
"code" : "0x60206000600039602060006000f0",
"nonce" : "0x",
"nonce" : "0x00",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "0x0de0b6b3a7640000",
"code" : "0x",
"nonce" : "0x",
"nonce" : "0x00",
"storage" : {
}
}
},
"transaction" : {
"data" : "0x",
"data" : "",
"gasLimit" : "0x071948",
"gasPrice" : "0x01",
"nonce" : "0x",
"nonce" : "0x00",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "0x0186a0"
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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