mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
beacon/light/sync: add comments to validated head test
This commit is contained in:
parent
c2b8cb226e
commit
324ce86955
1 changed files with 9 additions and 1 deletions
|
|
@ -53,10 +53,12 @@ func TestValidatedHead(t *testing.T) {
|
||||||
ts.AddServer(testServer1, 1)
|
ts.AddServer(testServer1, 1)
|
||||||
ts.ServerEvent(EvNewSignedHead, testServer1, testSHead1)
|
ts.ServerEvent(EvNewSignedHead, testServer1, testSHead1)
|
||||||
ts.Run(1, nil, nil)
|
ts.Run(1, nil, nil)
|
||||||
|
// announced head should be queued because of uninitialized chain
|
||||||
ht.ExpValidated(t, 1, nil)
|
ht.ExpValidated(t, 1, nil)
|
||||||
|
|
||||||
chain.SetNextSyncPeriod(0)
|
chain.SetNextSyncPeriod(0) // initialize chain
|
||||||
ts.Run(2, nil, nil)
|
ts.Run(2, nil, nil)
|
||||||
|
// expect previously queued head to be validated
|
||||||
ht.ExpValidated(t, 2, []types.SignedHeader{testSHead1})
|
ht.ExpValidated(t, 2, []types.SignedHeader{testSHead1})
|
||||||
|
|
||||||
chain.SetNextSyncPeriod(1)
|
chain.SetNextSyncPeriod(1)
|
||||||
|
|
@ -64,28 +66,34 @@ func TestValidatedHead(t *testing.T) {
|
||||||
ts.AddServer(testServer2, 1)
|
ts.AddServer(testServer2, 1)
|
||||||
ts.ServerEvent(EvNewSignedHead, testServer2, testSHead2)
|
ts.ServerEvent(EvNewSignedHead, testServer2, testSHead2)
|
||||||
ts.Run(3, nil, nil)
|
ts.Run(3, nil, nil)
|
||||||
|
// expect both head announcements to be validated instantly
|
||||||
ht.ExpValidated(t, 3, []types.SignedHeader{testSHead2, testSHead2})
|
ht.ExpValidated(t, 3, []types.SignedHeader{testSHead2, testSHead2})
|
||||||
|
|
||||||
ts.ServerEvent(EvNewSignedHead, testServer1, testSHead3)
|
ts.ServerEvent(EvNewSignedHead, testServer1, testSHead3)
|
||||||
ts.AddServer(testServer3, 1)
|
ts.AddServer(testServer3, 1)
|
||||||
ts.ServerEvent(EvNewSignedHead, testServer3, testSHead4)
|
ts.ServerEvent(EvNewSignedHead, testServer3, testSHead4)
|
||||||
ts.Run(4, nil, nil)
|
ts.Run(4, nil, nil)
|
||||||
|
// future period annonced heads should be queued
|
||||||
ht.ExpValidated(t, 4, nil)
|
ht.ExpValidated(t, 4, nil)
|
||||||
|
|
||||||
chain.SetNextSyncPeriod(2)
|
chain.SetNextSyncPeriod(2)
|
||||||
ts.Run(5, nil, nil)
|
ts.Run(5, nil, nil)
|
||||||
|
// testSHead3 can be validated now but not testSHead4
|
||||||
ht.ExpValidated(t, 5, []types.SignedHeader{testSHead3})
|
ht.ExpValidated(t, 5, []types.SignedHeader{testSHead3})
|
||||||
|
|
||||||
|
// server 3 disconnected without proving period 3, its announced head should be dropped
|
||||||
ts.RemoveServer(testServer3)
|
ts.RemoveServer(testServer3)
|
||||||
ts.Run(6, nil, nil)
|
ts.Run(6, nil, nil)
|
||||||
ht.ExpValidated(t, 6, nil)
|
ht.ExpValidated(t, 6, nil)
|
||||||
|
|
||||||
chain.SetNextSyncPeriod(3)
|
chain.SetNextSyncPeriod(3)
|
||||||
ts.Run(7, nil, nil)
|
ts.Run(7, nil, nil)
|
||||||
|
// testSHead4 could be validated now but it's not queued by any registered server
|
||||||
ht.ExpValidated(t, 7, nil)
|
ht.ExpValidated(t, 7, nil)
|
||||||
|
|
||||||
ts.ServerEvent(EvNewSignedHead, testServer2, testSHead4)
|
ts.ServerEvent(EvNewSignedHead, testServer2, testSHead4)
|
||||||
ts.Run(8, nil, nil)
|
ts.Run(8, nil, nil)
|
||||||
|
// now testSHead4 should be validated
|
||||||
ht.ExpValidated(t, 8, []types.SignedHeader{testSHead4})
|
ht.ExpValidated(t, 8, []types.SignedHeader{testSHead4})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue