mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-30 00:23:46 +00:00
feat: add test for sync method
This commit is contained in:
parent
0cc10d5436
commit
9077ad49dd
2 changed files with 23 additions and 0 deletions
|
|
@ -101,6 +101,14 @@ func NewConsensusLightClient(api ConsensusAPI, config *Config, checkpointBlockRo
|
|||
return client, nil
|
||||
}
|
||||
|
||||
func (c *ConsensusLightClient) GetHeader() *common.BeaconBlockHeader {
|
||||
return c.Store.OptimisticHeader
|
||||
}
|
||||
|
||||
func (c *ConsensusLightClient) GetFinalityHeader() *common.BeaconBlockHeader {
|
||||
return c.Store.FinalizedHeader
|
||||
}
|
||||
|
||||
func (c *ConsensusLightClient) Sync() error {
|
||||
err := c.bootstrap()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ func getClient(strictCheckpointAge bool, t *testing.T) (*ConsensusLightClient, e
|
|||
Chain: baseConfig.Chain,
|
||||
Spec: baseConfig.Spec,
|
||||
StrictCheckpointAge: strictCheckpointAge,
|
||||
MaxCheckpointAge: 123123123,
|
||||
}
|
||||
|
||||
checkpoint := common.Root(hexutil.MustDecode("0xc62aa0de55e6f21230fa63713715e1a6c13e73005e89f6389da271955d819bde"))
|
||||
|
|
@ -161,3 +162,17 @@ func TestVerifyOptimisticUpdate(t *testing.T) {
|
|||
err = client.VerifyOptimisticUpdate(update)
|
||||
require.Error(t, err)
|
||||
}
|
||||
|
||||
func TestSync(t *testing.T) {
|
||||
client, err := getClient(false, t)
|
||||
require.NoError(t, err)
|
||||
|
||||
err = client.Sync()
|
||||
require.NoError(t, err)
|
||||
|
||||
header := client.GetHeader()
|
||||
require.Equal(t, header.Slot, common.Slot(7358726))
|
||||
|
||||
finalizedHead := client.GetFinalityHeader()
|
||||
require.Equal(t, finalizedHead.Slot, common.Slot(7358656))
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue