Commit 9d51d103 authored by Adrian Sutton's avatar Adrian Sutton

op-e2e: Expect the challenger to resolve the game

parent 4bad280b
......@@ -2,6 +2,7 @@ package disputegame
import (
"context"
"fmt"
"math"
"math/big"
"testing"
......@@ -134,10 +135,18 @@ func (g *FaultGameHelper) Resolve(ctx context.Context) {
g.require.NoError(err)
}
func (g *FaultGameHelper) AssertStatusEquals(ctx context.Context, expected Status) {
func (g *FaultGameHelper) WaitForGameStatus(ctx context.Context, expected Status) {
ctx, cancel := context.WithTimeout(ctx, 1*time.Minute)
defer cancel()
err := utils.WaitFor(ctx, 1*time.Second, func() (bool, error) {
ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
defer cancel()
status, err := g.game.Status(&bind.CallOpts{Context: ctx})
g.require.NoError(err)
g.require.Equal(expected, Status(status))
if err != nil {
return false, fmt.Errorf("game status unavailable: %w", err)
}
return expected == Status(status), nil
})
g.require.NoError(err, "wait for game status")
}
......@@ -32,7 +32,7 @@ func TestResolveDisputeGame(t *testing.T) {
game := disputeGameFactory.StartAlphabetGame(ctx, "zyxwvut")
require.NotNil(t, game)
game.AssertStatusEquals(ctx, disputegame.StatusInProgress)
game.WaitForGameStatus(ctx, disputegame.StatusInProgress)
honest := game.StartChallenger(ctx, sys.NodeEndpoint("l1"), "honestAlice", func(c *config.Config) {
c.AgreeWithProposedOutput = true // Agree with the proposed output, so disagree with the root claim
......@@ -46,8 +46,7 @@ func TestResolveDisputeGame(t *testing.T) {
sys.TimeTravelClock.AdvanceTime(gameDuration)
require.NoError(t, utils.WaitNextBlock(ctx, l1Client))
game.Resolve(ctx)
game.AssertStatusEquals(ctx, disputegame.StatusChallengerWins)
// Challenger should resolve the game now that the clocks have expired.
game.WaitForGameStatus(ctx, disputegame.StatusChallengerWins)
require.NoError(t, honest.Close())
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment