From 551fd5727118fbcd3e7385c2673a6957f37d6175 Mon Sep 17 00:00:00 2001 From: AnilChinchwale Date: Wed, 7 Nov 2018 10:46:09 +0530 Subject: [PATCH] Fixed unit test for penalty feature. --- cmd/XDC/dao_test.go | 4 ++-- core/blockchain.go | 10 +++++----- core/genesis_test.go | 2 +- core/types/block.go | 2 +- core/types/block_test.go | 6 +++--- eth/tracers/testdata/call_tracer_create.json | 2 +- eth/tracers/testdata/call_tracer_deep_calls.json | 2 +- eth/tracers/testdata/call_tracer_delegatecall.json | 2 +- .../call_tracer_inner_create_oog_outer_throw.json | 2 +- .../testdata/call_tracer_inner_throw_outer_revert.json | 2 +- eth/tracers/testdata/call_tracer_oog.json | 2 +- eth/tracers/testdata/call_tracer_revert.json | 2 +- eth/tracers/testdata/call_tracer_simple.json | 2 +- eth/tracers/testdata/call_tracer_throw.json | 2 +- params/config.go | 6 +++--- tests/block_test_util.go | 4 ++-- 16 files changed, 26 insertions(+), 26 deletions(-) diff --git a/cmd/XDC/dao_test.go b/cmd/XDC/dao_test.go index 983713b827..9b361f7199 100644 --- a/cmd/XDC/dao_test.go +++ b/cmd/XDC/dao_test.go @@ -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 } diff --git a/core/blockchain.go b/core/blockchain.go index 04451a9006..5b7396dc4a 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -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, diff --git a/core/genesis_test.go b/core/genesis_test.go index a67b042ded..61d16115d4 100644 --- a/core/genesis_test.go +++ b/core/genesis_test.go @@ -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: ¶ms.ChainConfig{HomesteadBlock: big.NewInt(3)}, Alloc: GenesisAlloc{ diff --git a/core/types/block.go b/core/types/block.go index e226d61fd5..2a16a15729 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -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 diff --git a/core/types/block_test.go b/core/types/block_test.go index a7dd5d9218..bf20d85bcc 100644 --- a/core/types/block_test.go +++ b/core/types/block_test.go @@ -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 { diff --git a/eth/tracers/testdata/call_tracer_create.json b/eth/tracers/testdata/call_tracer_create.json index 984d0bce11..28503d729a 100644 --- a/eth/tracers/testdata/call_tracer_create.json +++ b/eth/tracers/testdata/call_tracer_create.json @@ -26,7 +26,7 @@ "chainId": 3, "daoForkSupport": true, "eip150Block": 0, - "eip150Hash": "0xfc673c99f7650df67bf769ab5b923ef60deefdbb49a6fe0dea14420f6790736a", + "eip150Hash": "0x62e0fde86e34c263e250fbcd5ca4598ba8ca10a1d166c8526bb127e10b313311", "eip155Block": 10, "eip158Block": 10, "ethash": {}, diff --git a/eth/tracers/testdata/call_tracer_deep_calls.json b/eth/tracers/testdata/call_tracer_deep_calls.json index cfeb5e79e3..f44eb79943 100644 --- a/eth/tracers/testdata/call_tracer_deep_calls.json +++ b/eth/tracers/testdata/call_tracer_deep_calls.json @@ -89,7 +89,7 @@ "chainId": 3, "daoForkSupport": true, "eip150Block": 0, - "eip150Hash": "0xfc673c99f7650df67bf769ab5b923ef60deefdbb49a6fe0dea14420f6790736a", + "eip150Hash": "0x62e0fde86e34c263e250fbcd5ca4598ba8ca10a1d166c8526bb127e10b313311 ", "eip155Block": 10, "eip158Block": 10, "ethash": {}, diff --git a/eth/tracers/testdata/call_tracer_delegatecall.json b/eth/tracers/testdata/call_tracer_delegatecall.json index 416c866d1d..6b7ba42f8c 100644 --- a/eth/tracers/testdata/call_tracer_delegatecall.json +++ b/eth/tracers/testdata/call_tracer_delegatecall.json @@ -42,7 +42,7 @@ "chainId": 3, "daoForkSupport": true, "eip150Block": 0, - "eip150Hash": "0xfc673c99f7650df67bf769ab5b923ef60deefdbb49a6fe0dea14420f6790736a", + "eip150Hash": "0x62e0fde86e34c263e250fbcd5ca4598ba8ca10a1d166c8526bb127e10b313311", "eip155Block": 10, "eip158Block": 10, "ethash": {}, diff --git a/eth/tracers/testdata/call_tracer_inner_create_oog_outer_throw.json b/eth/tracers/testdata/call_tracer_inner_create_oog_outer_throw.json index b8a4cdd233..4b80abd572 100644 --- a/eth/tracers/testdata/call_tracer_inner_create_oog_outer_throw.json +++ b/eth/tracers/testdata/call_tracer_inner_create_oog_outer_throw.json @@ -34,7 +34,7 @@ "chainId": 3, "daoForkSupport": true, "eip150Block": 0, - "eip150Hash": "0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d", + "eip150Hash": "0x62e0fde86e34c263e250fbcd5ca4598ba8ca10a1d166c8526bb127e10b313311", "eip155Block": 10, "eip158Block": 10, "ethash": {}, diff --git a/eth/tracers/testdata/call_tracer_inner_throw_outer_revert.json b/eth/tracers/testdata/call_tracer_inner_throw_outer_revert.json index edd80e5b84..ff34e9848f 100644 --- a/eth/tracers/testdata/call_tracer_inner_throw_outer_revert.json +++ b/eth/tracers/testdata/call_tracer_inner_throw_outer_revert.json @@ -37,7 +37,7 @@ "chainId": 3, "daoForkSupport": true, "eip150Block": 0, - "eip150Hash": "0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d", + "eip150Hash": "0x62e0fde86e34c263e250fbcd5ca4598ba8ca10a1d166c8526bb127e10b313311", "eip155Block": 10, "eip158Block": 10, "ethash": {}, diff --git a/eth/tracers/testdata/call_tracer_oog.json b/eth/tracers/testdata/call_tracer_oog.json index b765ee9064..99bb10d7f1 100644 --- a/eth/tracers/testdata/call_tracer_oog.json +++ b/eth/tracers/testdata/call_tracer_oog.json @@ -28,7 +28,7 @@ "chainId": 3, "daoForkSupport": true, "eip150Block": 0, - "eip150Hash": "0xfc673c99f7650df67bf769ab5b923ef60deefdbb49a6fe0dea14420f6790736a", + "eip150Hash": "0x62e0fde86e34c263e250fbcd5ca4598ba8ca10a1d166c8526bb127e10b313311", "eip155Block": 10, "eip158Block": 10, "ethash": {}, diff --git a/eth/tracers/testdata/call_tracer_revert.json b/eth/tracers/testdata/call_tracer_revert.json index 26e00d031d..39931b9b72 100644 --- a/eth/tracers/testdata/call_tracer_revert.json +++ b/eth/tracers/testdata/call_tracer_revert.json @@ -26,7 +26,7 @@ "chainId": 3, "daoForkSupport": true, "eip150Block": 0, - "eip150Hash": "0xfc673c99f7650df67bf769ab5b923ef60deefdbb49a6fe0dea14420f6790736a", + "eip150Hash": "0x62e0fde86e34c263e250fbcd5ca4598ba8ca10a1d166c8526bb127e10b313311", "eip155Block": 10, "eip158Block": 10, "ethash": {}, diff --git a/eth/tracers/testdata/call_tracer_simple.json b/eth/tracers/testdata/call_tracer_simple.json index 5ae54756ab..68aeca3678 100644 --- a/eth/tracers/testdata/call_tracer_simple.json +++ b/eth/tracers/testdata/call_tracer_simple.json @@ -37,7 +37,7 @@ "chainId": 3, "daoForkSupport": true, "eip150Block": 0, - "eip150Hash": "0xfc673c99f7650df67bf769ab5b923ef60deefdbb49a6fe0dea14420f6790736a", + "eip150Hash": "0x62e0fde86e34c263e250fbcd5ca4598ba8ca10a1d166c8526bb127e10b313311", "eip155Block": 10, "eip158Block": 10, "ethash": {}, diff --git a/eth/tracers/testdata/call_tracer_throw.json b/eth/tracers/testdata/call_tracer_throw.json index 46cd3e3b47..9c6a2f48cf 100644 --- a/eth/tracers/testdata/call_tracer_throw.json +++ b/eth/tracers/testdata/call_tracer_throw.json @@ -30,7 +30,7 @@ "chainId": 3, "daoForkSupport": true, "eip150Block": 0, - "eip150Hash": "0xfc673c99f7650df67bf769ab5b923ef60deefdbb49a6fe0dea14420f6790736a", + "eip150Hash": "0x62e0fde86e34c263e250fbcd5ca4598ba8ca10a1d166c8526bb127e10b313311", "eip155Block": 10, "eip158Block": 10, "ethash": {}, diff --git a/params/config.go b/params/config.go index 2599a8cb56..8933f181ec 100644 --- a/params/config.go +++ b/params/config.go @@ -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), diff --git a/tests/block_test_util.go b/tests/block_test_util.go index beba484833..bb8a4b58fc 100644 --- a/tests/block_test_util.go +++ b/tests/block_test_util.go @@ -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{})