mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 21:08:10 -05:00
Fix setNodeAndParentValidated (#11302)
* Fix setNodeAndParentValidated * fix tests
This commit is contained in:
@@ -3009,7 +3009,7 @@ func TestStore_NoViableHead_Reboot_DoublyLinkedTree(t *testing.T) {
|
||||
// The node is optimistic now.
|
||||
optimistic, err := service.IsOptimistic(ctx)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, true, optimistic)
|
||||
require.Equal(t, false, optimistic)
|
||||
require.Equal(t, false, service.ForkChoicer().AllTipsAreInvalid())
|
||||
|
||||
// Check that the node's justified checkpoint does not agree with the
|
||||
@@ -3233,7 +3233,7 @@ func TestStore_NoViableHead_Reboot_Protoarray(t *testing.T) {
|
||||
// The node is optimistic now
|
||||
optimistic, err := service.IsOptimistic(ctx)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, true, optimistic)
|
||||
require.Equal(t, false, optimistic)
|
||||
require.Equal(t, false, service.ForkChoicer().AllTipsAreInvalid())
|
||||
|
||||
// Check that the node's justified checkpoint does not agree with the
|
||||
|
||||
@@ -116,10 +116,13 @@ func (n *Node) setNodeAndParentValidated(ctx context.Context) error {
|
||||
return ctx.Err()
|
||||
}
|
||||
|
||||
if !n.optimistic || n.parent == nil {
|
||||
if !n.optimistic {
|
||||
return nil
|
||||
}
|
||||
|
||||
n.optimistic = false
|
||||
|
||||
if n.parent == nil {
|
||||
return nil
|
||||
}
|
||||
return n.parent.setNodeAndParentValidated(ctx)
|
||||
}
|
||||
|
||||
@@ -389,3 +389,14 @@ func TestSetOptimisticToInvalid_ForkAtMerge_bis(t *testing.T) {
|
||||
})
|
||||
require.DeepEqual(t, roots, [][32]byte{{'b'}, {'c'}, {'d'}, {'e'}})
|
||||
}
|
||||
|
||||
func TestSetOptimisticToValid(t *testing.T) {
|
||||
f := setup(1, 1)
|
||||
op, err := f.IsOptimistic([32]byte{})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, true, op)
|
||||
require.NoError(t, f.SetOptimisticToValid(context.Background(), [32]byte{}))
|
||||
op, err = f.IsOptimistic([32]byte{})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, false, op)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user