Skip to content

Commit

Permalink
test(consensus): update taiko consensus tests (ethereum#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha authored Apr 27, 2023
1 parent f148090 commit c6fcb71
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions consensus/taiko/consensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ var (

func init() {
config := params.TestChainConfig
config.LondonBlock = nil
config.GrayGlacierBlock = nil
config.ArrowGlacierBlock = nil
config.Ethash = nil
Expand All @@ -45,6 +44,7 @@ func init() {
ExtraData: []byte("test genesis"),
Timestamp: 9000,
Difficulty: common.Big0,
BaseFee: big.NewInt(params.InitialBaseFee),
}

txs = []*types.Transaction{
Expand Down Expand Up @@ -139,15 +139,17 @@ func TestVerifyHeader(t *testing.T) {
}

err := testEngine.VerifyHeader(ethService.BlockChain(), &types.Header{
Number: common.Big1,
Time: uint64(time.Now().Unix()),
Number: common.Big1,
Time: uint64(time.Now().Unix()),
BaseFee: big.NewInt(params.InitialBaseFee),
}, true)
assert.ErrorIs(t, err, consensus.ErrUnknownAncestor, "VerifyHeader should thorw ErrUnknownAncestor when parentHash is unknown")

err = testEngine.VerifyHeader(ethService.BlockChain(), &types.Header{
ParentHash: blocks[len(blocks)-1].Hash(),
Number: common.Big0,
Time: uint64(time.Now().Unix()),
BaseFee: big.NewInt(params.InitialBaseFee),
}, true)
assert.ErrorIs(t, err, consensus.ErrInvalidNumber, "VerifyHeader should thorw ErrInvalidNumber when the block number is wrong")

Expand All @@ -156,6 +158,7 @@ func TestVerifyHeader(t *testing.T) {
Number: new(big.Int).SetInt64(int64(len(blocks))),
Time: uint64(time.Now().Unix()),
Extra: bytes.Repeat([]byte{1}, int(params.MaximumExtraDataSize+1)),
BaseFee: big.NewInt(params.InitialBaseFee),
}, true)
assert.ErrorContains(t, err, "extra-data too long", "VerifyHeader should thorw ErrExtraDataTooLong when the block has too much extra data")

Expand All @@ -164,6 +167,7 @@ func TestVerifyHeader(t *testing.T) {
Number: new(big.Int).SetInt64(int64(len(blocks))),
Time: uint64(time.Now().Unix()),
Difficulty: common.Big1,
BaseFee: big.NewInt(params.InitialBaseFee),
}, true)
assert.ErrorContains(t, err, "invalid difficulty", "VerifyHeader should thorw ErrInvalidDifficulty when difficulty is not 0")

Expand All @@ -172,6 +176,7 @@ func TestVerifyHeader(t *testing.T) {
Number: new(big.Int).SetInt64(int64(len(blocks))),
Time: uint64(time.Now().Unix()),
GasLimit: params.MaxGasLimit + 1,
BaseFee: big.NewInt(params.InitialBaseFee),
}, true)
assert.ErrorContains(t, err, "invalid gasLimi", "VerifyHeader should thorw ErrInvalidGasLimit when gasLimit is higher than the limit")
}

0 comments on commit c6fcb71

Please sign in to comment.