test: handle null blocks in TestForkRefuseCall
Otherwise, this fails on rare occasions.
This commit is contained in:
parent
81d614a607
commit
cf81c897df
@ -297,22 +297,26 @@ func TestForkRefuseCall(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pts, err := cg.ChainStore().LoadTipSet(ts.TipSet.TipSet().Parents())
|
||||||
|
require.NoError(t, err)
|
||||||
|
parentHeight := pts.Height()
|
||||||
|
currentHeight := ts.TipSet.TipSet().Height()
|
||||||
|
|
||||||
|
// CallWithGas calls _at_ the current tipset.
|
||||||
ret, err := sm.CallWithGas(ctx, m, nil, ts.TipSet.TipSet())
|
ret, err := sm.CallWithGas(ctx, m, nil, ts.TipSet.TipSet())
|
||||||
switch ts.TipSet.TipSet().Height() {
|
if parentHeight <= testForkHeight && currentHeight >= testForkHeight {
|
||||||
case testForkHeight, testForkHeight + 1:
|
|
||||||
// If I had a fork, or I _will_ have a fork, it should fail.
|
// If I had a fork, or I _will_ have a fork, it should fail.
|
||||||
require.Equal(t, ErrExpensiveFork, err)
|
require.Equal(t, ErrExpensiveFork, err)
|
||||||
default:
|
} else {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.True(t, ret.MsgRct.ExitCode.IsSuccess())
|
require.True(t, ret.MsgRct.ExitCode.IsSuccess())
|
||||||
}
|
}
|
||||||
// Call just runs on the parent state for a tipset, so we only
|
|
||||||
// expect an error at the fork height.
|
// Call always applies the message to the "next block" after the tipset's parent state.
|
||||||
ret, err = sm.Call(ctx, m, ts.TipSet.TipSet())
|
ret, err = sm.Call(ctx, m, ts.TipSet.TipSet())
|
||||||
switch ts.TipSet.TipSet().Height() {
|
if parentHeight == testForkHeight {
|
||||||
case testForkHeight + 1:
|
|
||||||
require.Equal(t, ErrExpensiveFork, err)
|
require.Equal(t, ErrExpensiveFork, err)
|
||||||
default:
|
} else {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.True(t, ret.MsgRct.ExitCode.IsSuccess())
|
require.True(t, ret.MsgRct.ExitCode.IsSuccess())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user