Fixed unit test for penalty feature.

This commit is contained in:
AnilChinchwale 2018-11-07 10:46:09 +05:30
parent f5152bf0cf
commit 551fd57271
16 changed files with 26 additions and 26 deletions

View file

@ -77,7 +77,7 @@ var daoProForkGenesis = `{
}
}`
var daoGenesisHash = common.HexToHash("f2ea0466bf5a07cb7407474d9fbaae6e275127f038ca57a673b833234204f4fd")
var daoGenesisHash = common.HexToHash("e99f371cb126efa0a5bf4dc0660114a607ee3b5458c7c82b044164923f61069e")
var daoGenesisForkBlock = big.NewInt(314)
// TestDAOForkBlockNewChain tests that the DAO hard-fork number and the nodes support/opposition is correctly
@ -127,7 +127,7 @@ func testDAOForkBlockNewChain(t *testing.T, test int, genesis string, expectBloc
}
defer db.Close()
genesisHash := common.HexToHash("2efa267fef46877ac2659209e2299f97b0afc2a797ee8672db21920a5151e0aa")
genesisHash := common.HexToHash("205f64c83f065fe851db5703843304e46115c42c96434da316ce567ab9d5cc22")
if genesis != "" {
genesisHash = daoGenesisHash
}

View file

@ -690,7 +690,7 @@ func (bc *BlockChain) procFutureBlocks() {
// Insert one by one as chain insertion needs contiguous ancestry between blocks
for i := range blocks {
bc.InsertChain(blocks[i: i+1])
bc.InsertChain(blocks[i : i+1])
}
}
}
@ -699,9 +699,9 @@ func (bc *BlockChain) procFutureBlocks() {
type WriteStatus byte
const (
NonStatTy WriteStatus = iota
CanonStatTy
SideStatTy
NonStatTy WriteStatus = iota
CanonStatTy
SideStatTy
)
// Rollback is designed to remove a chain of links from the database that aren't
@ -1243,7 +1243,7 @@ func (st *insertStats) report(chain []*types.Block, index int, cache common.Stor
if index == len(chain)-1 || elapsed >= statsReportLimit {
var (
end = chain[index]
txs = countTransactions(chain[st.lastIndex: index+1])
txs = countTransactions(chain[st.lastIndex : index+1])
)
context := []interface{}{
"blocks", st.processed, "txs", txs, "mgas", float64(st.usedGas) / 1000000,

View file

@ -42,7 +42,7 @@ func TestDefaultGenesisBlock(t *testing.T) {
func TestSetupGenesis(t *testing.T) {
var (
customghash = common.HexToHash("0xa1cd36b0c6db6940b1184a28cea11f4f74d823589c6a7e7f1398a5c176835598")
customghash = common.HexToHash("0xaca4cb4e674345d92cee5c9e311a132161a5d6d0a997989394d66f2cbb18be49")
customg = Genesis{
Config: &params.ChainConfig{HomesteadBlock: big.NewInt(3)},
Alloc: GenesisAlloc{

View file

@ -85,7 +85,7 @@ type Header struct {
MixDigest common.Hash `json:"mixHash" gencodec:"required"`
Nonce BlockNonce `json:"nonce" gencodec:"required"`
Validators []byte `json:"validators" gencodec:"required"`
Penalties []byte `json:"penalties" gencodec:"required"`
Penalties []byte `json:"penalties" gencodec:"required"`
}
// field type overrides for gencodec

View file

@ -29,7 +29,7 @@ import (
// from bcValidBlockTest.json, "SimpleTx"
func TestBlockEncoding(t *testing.T) {
blockEnc := common.FromHex("f90261f901faa00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a05fe50b260da6308036625b850b5d6ced6d0a9f814c0688bc91ffb7b7a3a54b67a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000080832fefd8825208845506eb0780a0bd4472abb6659ebe3ee06ee4d7b72a00a9f4d001caca51342001075469aff49888a13a5a8c8f2bb1c480f861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba09bea4c4daac7c7c52e093e6a4c35dbbcf8856f1af7b059ba20253e70848d094fa08a8fae537ce25ed8cb5af9adac3f141af69bd515bd2ba031522df09b97dd72b1c0")
blockEnc := common.FromHex("f90265f901fea00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000832fefd8832fefd8825208845506eb0780a0bd4472abb6659ebe3ee06ee4d7b72a00a9f4d001caca51342001075469aff49888a13a5a8c8f2bb1c48080f861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba09bea4c4daac7c7c52e093e6a4c35dbbcf8856f1af7b059ba20253e70848d094fa08a8fae537ce25ed8cb5af9adac3f141af69bd515bd2ba031522df09b97dd72b1c0")
var block Block
if err := rlp.DecodeBytes(blockEnc, &block); err != nil {
t.Fatal("decode error: ", err)
@ -46,7 +46,7 @@ func TestBlockEncoding(t *testing.T) {
check("Coinbase", block.Coinbase(), common.HexToAddress("8888f1f195afa192cfee860698584c030f4c9db1"))
check("MixDigest", block.MixDigest(), common.HexToHash("bd4472abb6659ebe3ee06ee4d7b72a00a9f4d001caca51342001075469aff498"))
check("Root", block.Root(), common.HexToHash("ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017"))
check("Hash", block.Hash(), common.HexToHash("ed8e5b071b309a4c965a2b4aabd1f8f7818276627331ca37e753a3e97ec87081"))
check("Hash", block.Hash(), common.HexToHash("4f6c7eff9b02b689c1f99f81656dad19dfbc0d9f163f900ddfa940974aea72cb"))
check("Nonce", block.Nonce(), uint64(0xa13a5a8c8f2bb1c4))
check("Time", block.Time(), big.NewInt(1426516743))
check("Size", block.Size(), common.StorageSize(len(blockEnc)))
@ -58,7 +58,7 @@ func TestBlockEncoding(t *testing.T) {
fmt.Println(tx1.data)
fmt.Println(tx1.Hash())
check("len(Transactions)", len(block.Transactions()), 1)
check("Transactions[0].Hash", block.Transactions()[0].Hash(), tx1.Hash())
check("Transactions[0].Hash", block.Transactions()[0].Hash().String(), tx1.Hash().String())
ourBlockEnc, err := rlp.EncodeToBytes(&block)
if err != nil {

View file

@ -26,7 +26,7 @@
"chainId": 3,
"daoForkSupport": true,
"eip150Block": 0,
"eip150Hash": "0xfc673c99f7650df67bf769ab5b923ef60deefdbb49a6fe0dea14420f6790736a",
"eip150Hash": "0x62e0fde86e34c263e250fbcd5ca4598ba8ca10a1d166c8526bb127e10b313311",
"eip155Block": 10,
"eip158Block": 10,
"ethash": {},

View file

@ -89,7 +89,7 @@
"chainId": 3,
"daoForkSupport": true,
"eip150Block": 0,
"eip150Hash": "0xfc673c99f7650df67bf769ab5b923ef60deefdbb49a6fe0dea14420f6790736a",
"eip150Hash": "0x62e0fde86e34c263e250fbcd5ca4598ba8ca10a1d166c8526bb127e10b313311 ",
"eip155Block": 10,
"eip158Block": 10,
"ethash": {},

View file

@ -42,7 +42,7 @@
"chainId": 3,
"daoForkSupport": true,
"eip150Block": 0,
"eip150Hash": "0xfc673c99f7650df67bf769ab5b923ef60deefdbb49a6fe0dea14420f6790736a",
"eip150Hash": "0x62e0fde86e34c263e250fbcd5ca4598ba8ca10a1d166c8526bb127e10b313311",
"eip155Block": 10,
"eip158Block": 10,
"ethash": {},

View file

@ -34,7 +34,7 @@
"chainId": 3,
"daoForkSupport": true,
"eip150Block": 0,
"eip150Hash": "0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d",
"eip150Hash": "0x62e0fde86e34c263e250fbcd5ca4598ba8ca10a1d166c8526bb127e10b313311",
"eip155Block": 10,
"eip158Block": 10,
"ethash": {},

View file

@ -37,7 +37,7 @@
"chainId": 3,
"daoForkSupport": true,
"eip150Block": 0,
"eip150Hash": "0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d",
"eip150Hash": "0x62e0fde86e34c263e250fbcd5ca4598ba8ca10a1d166c8526bb127e10b313311",
"eip155Block": 10,
"eip158Block": 10,
"ethash": {},

View file

@ -28,7 +28,7 @@
"chainId": 3,
"daoForkSupport": true,
"eip150Block": 0,
"eip150Hash": "0xfc673c99f7650df67bf769ab5b923ef60deefdbb49a6fe0dea14420f6790736a",
"eip150Hash": "0x62e0fde86e34c263e250fbcd5ca4598ba8ca10a1d166c8526bb127e10b313311",
"eip155Block": 10,
"eip158Block": 10,
"ethash": {},

View file

@ -26,7 +26,7 @@
"chainId": 3,
"daoForkSupport": true,
"eip150Block": 0,
"eip150Hash": "0xfc673c99f7650df67bf769ab5b923ef60deefdbb49a6fe0dea14420f6790736a",
"eip150Hash": "0x62e0fde86e34c263e250fbcd5ca4598ba8ca10a1d166c8526bb127e10b313311",
"eip155Block": 10,
"eip158Block": 10,
"ethash": {},

View file

@ -37,7 +37,7 @@
"chainId": 3,
"daoForkSupport": true,
"eip150Block": 0,
"eip150Hash": "0xfc673c99f7650df67bf769ab5b923ef60deefdbb49a6fe0dea14420f6790736a",
"eip150Hash": "0x62e0fde86e34c263e250fbcd5ca4598ba8ca10a1d166c8526bb127e10b313311",
"eip155Block": 10,
"eip158Block": 10,
"ethash": {},

View file

@ -30,7 +30,7 @@
"chainId": 3,
"daoForkSupport": true,
"eip150Block": 0,
"eip150Hash": "0xfc673c99f7650df67bf769ab5b923ef60deefdbb49a6fe0dea14420f6790736a",
"eip150Hash": "0x62e0fde86e34c263e250fbcd5ca4598ba8ca10a1d166c8526bb127e10b313311",
"eip155Block": 10,
"eip158Block": 10,
"ethash": {},

View file

@ -24,8 +24,8 @@ import (
)
var (
MainnetGenesisHash = common.HexToHash("2efa267fef46877ac2659209e2299f97b0afc2a797ee8672db21920a5151e0aa") // Mainnet genesis hash to enforce below configs on
TestnetGenesisHash = common.HexToHash("fc673c99f7650df67bf769ab5b923ef60deefdbb49a6fe0dea14420f6790736a") // Testnet genesis hash to enforce below configs on
MainnetGenesisHash = common.HexToHash("205f64c83f065fe851db5703843304e46115c42c96434da316ce567ab9d5cc22") // Mainnet genesis hash to enforce below configs on
TestnetGenesisHash = common.HexToHash("62e0fde86e34c263e250fbcd5ca4598ba8ca10a1d166c8526bb127e10b313311") // Testnet genesis hash to enforce below configs on
)
var (
@ -51,7 +51,7 @@ var (
DAOForkBlock: nil,
DAOForkSupport: true,
EIP150Block: big.NewInt(0),
EIP150Hash: common.HexToHash("0xfc673c99f7650df67bf769ab5b923ef60deefdbb49a6fe0dea14420f6790736a"),
EIP150Hash: common.HexToHash("0x62e0fde86e34c263e250fbcd5ca4598ba8ca10a1d166c8526bb127e10b313311"),
EIP155Block: big.NewInt(10),
EIP158Block: big.NewInt(10),
ByzantiumBlock: big.NewInt(1700000),

View file

@ -104,10 +104,10 @@ func (t *BlockTest) Run() error {
return err
}
if gblock.Hash() != t.json.Genesis.Hash {
return fmt.Errorf("genesis block hash doesn't match test: computed=%x, test=%x\n", gblock.Hash().Bytes()[:6], t.json.Genesis.Hash[:6])
return fmt.Errorf("genesis block hash doesn't match test: computed=%x, test=%x\n", gblock.Hash().Bytes(), t.json.Genesis.Hash)
}
if gblock.Root() != t.json.Genesis.StateRoot {
return fmt.Errorf("genesis block state root does not match test: computed=%x, test=%x", gblock.Root().Bytes()[:6], t.json.Genesis.StateRoot[:6])
return fmt.Errorf("genesis block state root does not match test: computed=%x, test=%x", gblock.Root().Bytes(), t.json.Genesis.StateRoot)
}
chain, err := core.NewBlockChain(db, nil, config, ethash.NewShared(), vm.Config{})