Browse Source

more block tests + bugfix for longer chains

cl-refactor
CJentzsch 10 years ago
committed by Gav Wood
parent
commit
9ce2393e0e
  1. 15
      test/bcBlockChainTestFiller.json
  2. 171
      test/bcInvalidHeaderTestFiller.json
  3. 98
      test/bcValidBlockTestFiller.json
  4. 45
      test/blockchain.cpp

15
test/bcBlockChainTestFiller.json

@ -39,6 +39,21 @@
], ],
"uncleHeaders" : [ "uncleHeaders" : [
] ]
},
{
"transactions" : [
{
"data" : "",
"gasLimit" : "8000000",
"gasPrice" : "0",
"nonce" : "1",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "10"
}
],
"uncleHeaders" : [
]
} }
] ]
} }

171
test/blInvalidHeaderTestFiller.json → test/bcInvalidHeaderTestFiller.json

@ -1,8 +1,5 @@
{ {
"log1_wrongBlockNumber" : { "log1_wrongBlockNumber" : {
"blockHeader" : {
"number" : "2"
},
"genesisBlockHeader" : { "genesisBlockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1",
@ -33,10 +30,15 @@
"storage": {} "storage": {}
} }
}, },
"blocks" : [
{
"blockHeader" : {
"number" : "2"
},
"transactions" : [ "transactions" : [
{ {
"data" : "", "data" : "",
"gasLimit" : "5000", "gasLimit" : "50000",
"gasPrice" : "10", "gasPrice" : "10",
"nonce" : "0", "nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
@ -46,12 +48,12 @@
], ],
"uncleHeaders" : [ "uncleHeaders" : [
] ]
}
]
}, },
"log1_wrongBloom" : { "log1_wrongBloom" : {
"blockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
},
"genesisBlockHeader" : { "genesisBlockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1",
@ -68,6 +70,7 @@
"transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
}, },
"pre" : { "pre" : {
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "10000000000", "balance" : "10000000000",
@ -82,10 +85,15 @@
"storage": {} "storage": {}
} }
}, },
"blocks" : [
{
"blockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
},
"transactions" : [ "transactions" : [
{ {
"data" : "", "data" : "",
"gasLimit" : "5000", "gasLimit" : "50000",
"gasPrice" : "10", "gasPrice" : "10",
"nonce" : "0", "nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
@ -95,12 +103,11 @@
], ],
"uncleHeaders" : [ "uncleHeaders" : [
] ]
}
]
}, },
"wrongCoinbase" : { "wrongCoinbase" : {
"blockHeader" : {
"coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1"
},
"genesisBlockHeader" : { "genesisBlockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1",
@ -131,10 +138,15 @@
"storage": {} "storage": {}
} }
}, },
"blocks" : [
{
"blockHeader" : {
"coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1"
},
"transactions" : [ "transactions" : [
{ {
"data" : "", "data" : "",
"gasLimit" : "5000", "gasLimit" : "50000",
"gasPrice" : "10", "gasPrice" : "10",
"nonce" : "0", "nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
@ -144,12 +156,11 @@
], ],
"uncleHeaders" : [ "uncleHeaders" : [
] ]
}
]
}, },
"wrongDifficulty" : { "wrongDifficulty" : {
"blockHeader" : {
"difficulty" : "10000"
},
"genesisBlockHeader" : { "genesisBlockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1",
@ -180,10 +191,15 @@
"storage": {} "storage": {}
} }
}, },
"blocks" : [
{
"blockHeader" : {
"difficulty" : "10000"
},
"transactions" : [ "transactions" : [
{ {
"data" : "", "data" : "",
"gasLimit" : "5000", "gasLimit" : "50000",
"gasPrice" : "10", "gasPrice" : "10",
"nonce" : "0", "nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
@ -193,12 +209,11 @@
], ],
"uncleHeaders" : [ "uncleHeaders" : [
] ]
}
]
}, },
"DifferentExtraData" : { "DifferentExtraData" : {
"blockHeader" : {
"extraData" : "42"
},
"genesisBlockHeader" : { "genesisBlockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1",
@ -229,10 +244,15 @@
"storage": {} "storage": {}
} }
}, },
"blocks" : [
{
"blockHeader" : {
"extraData" : "42"
},
"transactions" : [ "transactions" : [
{ {
"data" : "", "data" : "",
"gasLimit" : "5000", "gasLimit" : "50000",
"gasPrice" : "10", "gasPrice" : "10",
"nonce" : "0", "nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
@ -242,12 +262,11 @@
], ],
"uncleHeaders" : [ "uncleHeaders" : [
] ]
}
]
}, },
"wrongGasLimit" : { "wrongGasLimit" : {
"blockHeader" : {
"gasLimit" : "100000"
},
"genesisBlockHeader" : { "genesisBlockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1",
@ -278,10 +297,15 @@
"storage": {} "storage": {}
} }
}, },
"blocks" : [
{
"blockHeader" : {
"gasLimit" : "100000"
},
"transactions" : [ "transactions" : [
{ {
"data" : "", "data" : "",
"gasLimit" : "5000", "gasLimit" : "50000",
"gasPrice" : "10", "gasPrice" : "10",
"nonce" : "0", "nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
@ -291,12 +315,12 @@
], ],
"uncleHeaders" : [ "uncleHeaders" : [
] ]
}
]
}, },
"wrongGasUsed" : { "wrongGasUsed" : {
"blockHeader" : {
"gasUsed" : "0"
},
"genesisBlockHeader" : { "genesisBlockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1",
@ -327,10 +351,15 @@
"storage": {} "storage": {}
} }
}, },
"blocks" : [
{
"blockHeader" : {
"gasUsed" : "0"
},
"transactions" : [ "transactions" : [
{ {
"data" : "", "data" : "",
"gasLimit" : "5000", "gasLimit" : "50000",
"gasPrice" : "10", "gasPrice" : "10",
"nonce" : "0", "nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
@ -340,12 +369,11 @@
], ],
"uncleHeaders" : [ "uncleHeaders" : [
] ]
}
]
}, },
"wrongNumber" : { "wrongNumber" : {
"blockHeader" : {
"number" : "0"
},
"genesisBlockHeader" : { "genesisBlockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1",
@ -376,10 +404,15 @@
"storage": {} "storage": {}
} }
}, },
"blocks" : [
{
"blockHeader" : {
"number" : "0"
},
"transactions" : [ "transactions" : [
{ {
"data" : "", "data" : "",
"gasLimit" : "5000", "gasLimit" : "50000",
"gasPrice" : "10", "gasPrice" : "10",
"nonce" : "0", "nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
@ -389,12 +422,11 @@
], ],
"uncleHeaders" : [ "uncleHeaders" : [
] ]
}
]
}, },
"wrongParentHash" : { "wrongParentHash" : {
"blockHeader" : {
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000"
},
"genesisBlockHeader" : { "genesisBlockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1",
@ -425,10 +457,15 @@
"storage": {} "storage": {}
} }
}, },
"blocks" : [
{
"blockHeader" : {
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000"
},
"transactions" : [ "transactions" : [
{ {
"data" : "", "data" : "",
"gasLimit" : "5000", "gasLimit" : "50000",
"gasPrice" : "10", "gasPrice" : "10",
"nonce" : "0", "nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
@ -438,12 +475,11 @@
], ],
"uncleHeaders" : [ "uncleHeaders" : [
] ]
}
]
}, },
"wrongReceiptTrie" : { "wrongReceiptTrie" : {
"blockHeader" : {
"receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
},
"genesisBlockHeader" : { "genesisBlockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1",
@ -474,10 +510,15 @@
"storage": {} "storage": {}
} }
}, },
"blocks" : [
{
"blockHeader" : {
"receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
},
"transactions" : [ "transactions" : [
{ {
"data" : "", "data" : "",
"gasLimit" : "5000", "gasLimit" : "50000",
"gasPrice" : "10", "gasPrice" : "10",
"nonce" : "0", "nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
@ -487,12 +528,11 @@
], ],
"uncleHeaders" : [ "uncleHeaders" : [
] ]
}
]
}, },
"wrongStateRoot" : { "wrongStateRoot" : {
"blockHeader" : {
"stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a"
},
"genesisBlockHeader" : { "genesisBlockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1",
@ -523,10 +563,15 @@
"storage": {} "storage": {}
} }
}, },
"blocks" : [
{
"blockHeader" : {
"stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a"
},
"transactions" : [ "transactions" : [
{ {
"data" : "", "data" : "",
"gasLimit" : "5000", "gasLimit" : "50000",
"gasPrice" : "10", "gasPrice" : "10",
"nonce" : "0", "nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
@ -536,12 +581,11 @@
], ],
"uncleHeaders" : [ "uncleHeaders" : [
] ]
}
]
}, },
"wrongTimestamp" : { "wrongTimestamp" : {
"blockHeader" : {
"timestamp" : "0x54c98c80"
},
"genesisBlockHeader" : { "genesisBlockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1",
@ -572,10 +616,15 @@
"storage": {} "storage": {}
} }
}, },
"blocks" : [
{
"blockHeader" : {
"timestamp" : "0x54c98c80"
},
"transactions" : [ "transactions" : [
{ {
"data" : "", "data" : "",
"gasLimit" : "5000", "gasLimit" : "50000",
"gasPrice" : "10", "gasPrice" : "10",
"nonce" : "0", "nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
@ -585,12 +634,11 @@
], ],
"uncleHeaders" : [ "uncleHeaders" : [
] ]
}
]
}, },
"wrongTransactionsTrie" : { "wrongTransactionsTrie" : {
"blockHeader" : {
"transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
},
"genesisBlockHeader" : { "genesisBlockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1",
@ -621,10 +669,15 @@
"storage": {} "storage": {}
} }
}, },
"blocks" : [
{
"blockHeader" : {
"transactionsTrie" : "0x55e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
},
"transactions" : [ "transactions" : [
{ {
"data" : "", "data" : "",
"gasLimit" : "5000", "gasLimit" : "50000",
"gasPrice" : "10", "gasPrice" : "10",
"nonce" : "0", "nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
@ -634,12 +687,11 @@
], ],
"uncleHeaders" : [ "uncleHeaders" : [
] ]
}
]
}, },
"wrongUncleHash" : { "wrongUncleHash" : {
"blockHeader" : {
"uncleHash" : "0x0dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
},
"genesisBlockHeader" : { "genesisBlockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1",
@ -670,10 +722,15 @@
"storage": {} "storage": {}
} }
}, },
"blocks" : [
{
"blockHeader" : {
"uncleHash" : "0x0dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
},
"transactions" : [ "transactions" : [
{ {
"data" : "", "data" : "",
"gasLimit" : "5000", "gasLimit" : "50000",
"gasPrice" : "10", "gasPrice" : "10",
"nonce" : "0", "nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
@ -684,4 +741,6 @@
"uncleHeaders" : [ "uncleHeaders" : [
] ]
} }
]
}
} }

98
test/blValidBlockTestFiller.json → test/bcValidBlockTestFiller.json

@ -1,43 +1,4 @@
{ {
"diffTooLowToChange" : {
"genesisBlockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1",
"difficulty" : "1023",
"extraData" : "42",
"gasLimit" : "100000",
"gasUsed" : "0",
"nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d",
"number" : "0",
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a",
"timestamp" : "0x54c98c81",
"transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
},
"pre" : {
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "10000000000",
"nonce" : "0",
"code" : "",
"storage": {}
}
},
"transactions" : [
{
"data" : "",
"gasLimit" : "850",
"gasPrice" : "1",
"nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "10"
}
],
"uncleHeaders" : [
]
},
"diff1024" : { "diff1024" : {
"genesisBlockHeader" : { "genesisBlockHeader" : {
@ -64,6 +25,8 @@
"storage": {} "storage": {}
} }
}, },
"blocks" : [
{
"transactions" : [ "transactions" : [
{ {
"data" : "", "data" : "",
@ -77,6 +40,9 @@
], ],
"uncleHeaders" : [ "uncleHeaders" : [
] ]
}
]
}, },
"gasPrice0" : { "gasPrice0" : {
@ -104,10 +70,12 @@
"storage": {} "storage": {}
} }
}, },
"blocks" : [
{
"transactions" : [ "transactions" : [
{ {
"data" : "", "data" : "",
"gasLimit" : "850", "gasLimit" : "85000",
"gasPrice" : "0", "gasPrice" : "0",
"nonce" : "0", "nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
@ -117,6 +85,8 @@
], ],
"uncleHeaders" : [ "uncleHeaders" : [
] ]
}
]
}, },
"gasLimitTooHigh" : { "gasLimitTooHigh" : {
@ -144,19 +114,23 @@
"storage": {} "storage": {}
} }
}, },
"blocks" : [
{
"transactions" : [ "transactions" : [
{ {
"data" : "", "data" : "",
"gasLimit" : "850", "gasLimit" : "1000001",
"gasPrice" : "0", "gasPrice" : "0",
"nonce" : "0", "nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "10" "value" : "0"
} }
], ],
"uncleHeaders" : [ "uncleHeaders" : [
] ]
}
]
}, },
"SimpleTx" : { "SimpleTx" : {
@ -184,6 +158,8 @@
"storage": {} "storage": {}
} }
}, },
"blocks" : [
{
"transactions" : [ "transactions" : [
{ {
"data" : "", "data" : "",
@ -197,6 +173,8 @@
], ],
"uncleHeaders" : [ "uncleHeaders" : [
] ]
}
]
}, },
"txOrder" : { "txOrder" : {
@ -224,10 +202,12 @@
"storage": {} "storage": {}
} }
}, },
"blocks" : [
{
"transactions" : [ "transactions" : [
{ {
"data" : "", "data" : "",
"gasLimit" : "500", "gasLimit" : "50000",
"gasPrice" : "10", "gasPrice" : "10",
"nonce" : "0", "nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
@ -236,7 +216,7 @@
}, },
{ {
"data" : "", "data" : "",
"gasLimit" : "500", "gasLimit" : "50000",
"gasPrice" : "10", "gasPrice" : "10",
"nonce" : "0", "nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
@ -246,6 +226,8 @@
], ],
"uncleHeaders" : [ "uncleHeaders" : [
] ]
}
]
}, },
"txEqualValue" : { "txEqualValue" : {
@ -273,10 +255,12 @@
"storage": {} "storage": {}
} }
}, },
"blocks" : [
{
"transactions" : [ "transactions" : [
{ {
"data" : "", "data" : "",
"gasLimit" : "500", "gasLimit" : "50000",
"gasPrice" : "10", "gasPrice" : "10",
"nonce" : "0", "nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
@ -285,7 +269,7 @@
}, },
{ {
"data" : "", "data" : "",
"gasLimit" : "500", "gasLimit" : "50000",
"gasPrice" : "9", "gasPrice" : "9",
"nonce" : "0", "nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
@ -295,6 +279,8 @@
], ],
"uncleHeaders" : [ "uncleHeaders" : [
] ]
}
]
}, },
"log1_correct" : { "log1_correct" : {
@ -328,10 +314,12 @@
"storage": {} "storage": {}
} }
}, },
"blocks" : [
{
"transactions" : [ "transactions" : [
{ {
"data" : "", "data" : "",
"gasLimit" : "5000", "gasLimit" : "50000",
"gasPrice" : "10", "gasPrice" : "10",
"nonce" : "0", "nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
@ -340,10 +328,13 @@
} }
], ],
"uncleHeaders" : [ "uncleHeaders" : [
], ]
}
]
},
"firstBlockTest" : { "dataTx" : {
"block" : { "genesisBlockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1",
"difficulty" : "023101", "difficulty" : "023101",
@ -361,6 +352,8 @@
}, },
"pre" : { "pre" : {
}, },
"blocks" : [
{
"transactions" : [ "transactions" : [
{ {
"data" : "0x60056013565b6101918061001d6000396000f35b3360008190555056006001600060e060020a6000350480630a874df61461003a57806341c0e1b514610058578063a02b161e14610066578063dbbdf0831461007757005b610045600435610149565b80600160a060020a031660005260206000f35b610060610161565b60006000f35b6100716004356100d4565b60006000f35b61008560043560243561008b565b60006000f35b600054600160a060020a031632600160a060020a031614156100ac576100b1565b6100d0565b8060018360005260205260406000208190555081600060005260206000a15b5050565b600054600160a060020a031633600160a060020a031614158015610118575033600160a060020a0316600182600052602052604060002054600160a060020a031614155b61012157610126565b610146565b600060018260005260205260406000208190555080600060005260206000a15b50565b60006001826000526020526040600020549050919050565b600054600160a060020a031633600160a060020a0316146101815761018f565b600054600160a060020a0316ff5b56", "data" : "0x60056013565b6101918061001d6000396000f35b3360008190555056006001600060e060020a6000350480630a874df61461003a57806341c0e1b514610058578063a02b161e14610066578063dbbdf0831461007757005b610045600435610149565b80600160a060020a031660005260206000f35b610060610161565b60006000f35b6100716004356100d4565b60006000f35b61008560043560243561008b565b60006000f35b600054600160a060020a031632600160a060020a031614156100ac576100b1565b6100d0565b8060018360005260205260406000208190555081600060005260206000a15b5050565b600054600160a060020a031633600160a060020a031614158015610118575033600160a060020a0316600182600052602052604060002054600160a060020a031614155b61012157610126565b610146565b600060018260005260205260406000208190555080600060005260206000a15b50565b60006001826000526020526040600020549050919050565b600054600160a060020a031633600160a060020a0316146101815761018f565b600054600160a060020a0316ff5b56",
@ -374,8 +367,11 @@
"value" : "" "value" : ""
} }
], ],
"uncleHeaders" : [
]
} }
]
} }
} }

45
test/blockchain.cpp

@ -81,7 +81,7 @@ bytes createBlockRLPFromFields(mObject& _tObj)
return rlpStream.out(); return rlpStream.out();
} }
void doBlockTests(json_spirit::mValue& _v, bool _fillin) void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
{ {
for (auto& i: _v.get_obj()) for (auto& i: _v.get_obj())
{ {
@ -271,7 +271,6 @@ void doBlockTests(json_spirit::mValue& _v, bool _fillin)
if (tmp != current_BlockHeader) if (tmp != current_BlockHeader)
{ {
current_BlockHeader = tmp; current_BlockHeader = tmp;
cout << "new header!\n";
ProofOfWork pow; ProofOfWork pow;
MineInfo ret; MineInfo ret;
while (!ProofOfWork::verify(current_BlockHeader.headerHash(WithoutNonce), current_BlockHeader.nonce, current_BlockHeader.difficulty)) while (!ProofOfWork::verify(current_BlockHeader.headerHash(WithoutNonce), current_BlockHeader.nonce, current_BlockHeader.difficulty))
@ -343,14 +342,9 @@ void doBlockTests(json_spirit::mValue& _v, bool _fillin)
try try
{ {
ImportTest importerTmp(o["pre"].get_obj()); state.sync(bc);
State stateTmp(Address(), OverlayDB(), BaseState::Empty); bc.import(block2.out(), state.db());
importerTmp.importState(o["pre"].get_obj(), stateTmp); state.sync(bc);
stateTmp.commit();
BlockChain bcTmp(block.out(), getDataDir() + "/tmpBlockChain.bc", true);
stateTmp.sync(bcTmp);
bc.import(block2.out(), stateTmp.db());
stateTmp.sync(bcTmp);
} }
// if exception is thrown, RLP is invalid and no blockHeader, Transaction list, or Uncle list should be given // if exception is thrown, RLP is invalid and no blockHeader, Transaction list, or Uncle list should be given
catch (...) catch (...)
@ -505,32 +499,23 @@ BOOST_AUTO_TEST_SUITE(BlockChainTests)
BOOST_AUTO_TEST_CASE(bcBlockChainTest) BOOST_AUTO_TEST_CASE(bcBlockChainTest)
{ {
dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockTests); dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockchainTests);
} }
//BOOST_AUTO_TEST_CASE(blValidBlockTest) BOOST_AUTO_TEST_CASE(bcValidBlockTest)
//{ {
// dev::test::executeTests("blValidBlockTest", "/BlockTests", dev::test::doBlockTests); dev::test::executeTests("bcValidBlockTest", "/BlockTests", dev::test::doBlockchainTests);
//} }
//BOOST_AUTO_TEST_CASE(blInvalidTransactionRLP)
//{
// dev::test::executeTests("blInvalidTransactionRLP", "/BlockTests", dev::test::doBlockTests);
//}
//BOOST_AUTO_TEST_CASE(blInvalidHeaderTest) BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest)
//{ {
// dev::test::executeTests("blInvalidHeaderTest", "/BlockTests", dev::test::doBlockTests); dev::test::executeTests("bcInvalidHeaderTest", "/BlockTests", dev::test::doBlockchainTests);
//} }
//BOOST_AUTO_TEST_CASE(blForkBlocks)
//{
// dev::test::executeTests("blForkBlocks", "/BlockTests", dev::test::doBlockTests);
//}
BOOST_AUTO_TEST_CASE(userDefinedFileBl) BOOST_AUTO_TEST_CASE(userDefinedFileBc)
{ {
dev::test::userDefinedTest("--bltest", dev::test::doBlockTests); dev::test::userDefinedTest("--bctest", dev::test::doBlockchainTests);
} }
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

Loading…
Cancel
Save