test(sync): fix tipset check and re-enable checkpoint tests
We need to wait until the node _has_ the tipset, not until it doesn't. This probably only worked before due to race conditions. fixes #4716 (probably)
This commit is contained in:
parent
69da6a2a29
commit
0ad51f8a14
@ -346,12 +346,15 @@ func (tu *syncTestUtil) checkpointTs(node int, tsk types.TipSetKey) {
|
|||||||
require.NoError(tu.t, tu.nds[node].SyncCheckpoint(context.TODO(), tsk))
|
require.NoError(tu.t, tu.nds[node].SyncCheckpoint(context.TODO(), tsk))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (tu *syncTestUtil) nodeHasTs(node int, tsk types.TipSetKey) bool {
|
||||||
|
_, err := tu.nds[node].ChainGetTipSet(context.TODO(), tsk)
|
||||||
|
return err == nil
|
||||||
|
}
|
||||||
|
|
||||||
func (tu *syncTestUtil) waitUntilNodeHasTs(node int, tsk types.TipSetKey) {
|
func (tu *syncTestUtil) waitUntilNodeHasTs(node int, tsk types.TipSetKey) {
|
||||||
for {
|
for !tu.nodeHasTs(node, tsk) {
|
||||||
_, err := tu.nds[node].ChainGetTipSet(context.TODO(), tsk)
|
// Time to allow for syncing and validation
|
||||||
if err != nil {
|
time.Sleep(10 * time.Millisecond)
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Time to allow for syncing and validation
|
// Time to allow for syncing and validation
|
||||||
@ -751,8 +754,6 @@ func TestSyncInputs(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSyncCheckpointHead(t *testing.T) {
|
func TestSyncCheckpointHead(t *testing.T) {
|
||||||
t.Skip("flaky")
|
|
||||||
|
|
||||||
H := 10
|
H := 10
|
||||||
tu := prepSyncTest(t, H)
|
tu := prepSyncTest(t, H)
|
||||||
|
|
||||||
@ -790,13 +791,11 @@ func TestSyncCheckpointHead(t *testing.T) {
|
|||||||
tu.connect(p1, p2)
|
tu.connect(p1, p2)
|
||||||
tu.waitUntilNodeHasTs(p1, b.TipSet().Key())
|
tu.waitUntilNodeHasTs(p1, b.TipSet().Key())
|
||||||
p1Head := tu.getHead(p1)
|
p1Head := tu.getHead(p1)
|
||||||
require.Equal(tu.t, p1Head, a.TipSet())
|
require.True(tu.t, p1Head.Equals(a.TipSet()))
|
||||||
tu.assertBad(p1, b.TipSet())
|
tu.assertBad(p1, b.TipSet())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSyncCheckpointEarlierThanHead(t *testing.T) {
|
func TestSyncCheckpointEarlierThanHead(t *testing.T) {
|
||||||
t.Skip("flaky")
|
|
||||||
|
|
||||||
H := 10
|
H := 10
|
||||||
tu := prepSyncTest(t, H)
|
tu := prepSyncTest(t, H)
|
||||||
|
|
||||||
@ -834,6 +833,6 @@ func TestSyncCheckpointEarlierThanHead(t *testing.T) {
|
|||||||
tu.connect(p1, p2)
|
tu.connect(p1, p2)
|
||||||
tu.waitUntilNodeHasTs(p1, b.TipSet().Key())
|
tu.waitUntilNodeHasTs(p1, b.TipSet().Key())
|
||||||
p1Head := tu.getHead(p1)
|
p1Head := tu.getHead(p1)
|
||||||
require.Equal(tu.t, p1Head, a.TipSet())
|
require.True(tu.t, p1Head.Equals(a.TipSet()))
|
||||||
tu.assertBad(p1, b.TipSet())
|
tu.assertBad(p1, b.TipSet())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user