beacon/light/sync: add comments to validated head test

This commit is contained in:
Zsolt Felfoldi 2024-01-17 17:52:19 +01:00 committed by Felix Lange
parent c2b8cb226e
commit 324ce86955

View file

@ -53,10 +53,12 @@ func TestValidatedHead(t *testing.T) {
ts.AddServer(testServer1, 1)
ts.ServerEvent(EvNewSignedHead, testServer1, testSHead1)
ts.Run(1, nil, nil)
// announced head should be queued because of uninitialized chain
ht.ExpValidated(t, 1, nil)
chain.SetNextSyncPeriod(0)
chain.SetNextSyncPeriod(0) // initialize chain
ts.Run(2, nil, nil)
// expect previously queued head to be validated
ht.ExpValidated(t, 2, []types.SignedHeader{testSHead1})
chain.SetNextSyncPeriod(1)
@ -64,28 +66,34 @@ func TestValidatedHead(t *testing.T) {
ts.AddServer(testServer2, 1)
ts.ServerEvent(EvNewSignedHead, testServer2, testSHead2)
ts.Run(3, nil, nil)
// expect both head announcements to be validated instantly
ht.ExpValidated(t, 3, []types.SignedHeader{testSHead2, testSHead2})
ts.ServerEvent(EvNewSignedHead, testServer1, testSHead3)
ts.AddServer(testServer3, 1)
ts.ServerEvent(EvNewSignedHead, testServer3, testSHead4)
ts.Run(4, nil, nil)
// future period annonced heads should be queued
ht.ExpValidated(t, 4, nil)
chain.SetNextSyncPeriod(2)
ts.Run(5, nil, nil)
// testSHead3 can be validated now but not testSHead4
ht.ExpValidated(t, 5, []types.SignedHeader{testSHead3})
// server 3 disconnected without proving period 3, its announced head should be dropped
ts.RemoveServer(testServer3)
ts.Run(6, nil, nil)
ht.ExpValidated(t, 6, nil)
chain.SetNextSyncPeriod(3)
ts.Run(7, nil, nil)
// testSHead4 could be validated now but it's not queued by any registered server
ht.ExpValidated(t, 7, nil)
ts.ServerEvent(EvNewSignedHead, testServer2, testSHead4)
ts.Run(8, nil, nil)
// now testSHead4 should be validated
ht.ExpValidated(t, 8, []types.SignedHeader{testSHead4})
}