Skip to content

Commit

Permalink
eth/catalyst: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusVanDerWijden committed Jan 17, 2022
1 parent 0ab6a0d commit 1189cbe
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion eth/catalyst/api_test.go
Expand Up @@ -184,6 +184,31 @@ func checkLogEvents(t *testing.T, logsCh <-chan []*types.Log, rmLogsCh <-chan co
}
}

func TestInvalidPayloadTimestamp(t *testing.T) {
genesis, preMergeBlocks := generatePreMergeChain(10)
n, ethservice := startEthService(t, genesis, preMergeBlocks)
ethservice.Merger().ReachTTD()
defer n.Close()
var (
api = NewConsensusAPI(ethservice, nil)
parent = ethservice.BlockChain().CurrentBlock()
)
params := PayloadAttributesV1{
Timestamp: parent.Time() - 1,
Random: crypto.Keccak256Hash([]byte{byte(123)}),
SuggestedFeeRecipient: parent.Coinbase(),
}
fcState := ForkchoiceStateV1{
HeadBlockHash: parent.Hash(),
SafeBlockHash: common.Hash{},
FinalizedBlockHash: common.Hash{},
}
_, err := api.ForkchoiceUpdatedV1(fcState, &params)
if err == nil {
t.Fatalf("expected error preparing payload with invalid timestamp, err=%v", err)
}
}

func TestEth2NewBlock(t *testing.T) {
genesis, preMergeBlocks := generatePreMergeChain(10)
n, ethservice := startEthService(t, genesis, preMergeBlocks)
Expand Down Expand Up @@ -413,6 +438,5 @@ func TestFullAPI(t *testing.T) {
t.Fatalf("Chain head should be updated")
}
parent = ethservice.BlockChain().CurrentBlock()

}
}

0 comments on commit 1189cbe

Please sign in to comment.