Commit cfa5e24a authored by OptimismBot's avatar OptimismBot Committed by GitHub

Merge pull request #6970 from ethereum-optimism/aj/delete-files-e2e

op-e2e: Assert deletion of game data in fault proof e2e tests
parents 85f8e844 0cc332d7
......@@ -24,6 +24,8 @@ import (
type Helper struct {
log log.Logger
require *require.Assertions
dir string
cancel func()
errors chan error
}
......@@ -106,6 +108,8 @@ func NewChallenger(t *testing.T, ctx context.Context, l1Endpoint string, name st
}()
return &Helper{
log: log,
require: require.New(t),
dir: cfg.Datadir,
cancel: cancel,
errors: errCh,
}
......@@ -155,3 +159,25 @@ func (h *Helper) Close() error {
return nil
}
}
type GameAddr interface {
Addr() common.Address
}
func (h *Helper) VerifyGameDataExists(games ...GameAddr) {
for _, game := range games {
addr := game.Addr()
h.require.DirExistsf(h.gameDataDir(addr), "should have data for game %v", addr)
}
}
func (h *Helper) VerifyNoGameDataExists(games ...GameAddr) {
for _, game := range games {
addr := game.Addr()
h.require.NoDirExistsf(h.gameDataDir(addr), "should have data for game %v", addr)
}
}
func (h *Helper) gameDataDir(addr common.Address) string {
return filepath.Join(h.dir, addr.Hex())
}
......@@ -26,6 +26,10 @@ type FaultGameHelper struct {
addr common.Address
}
func (g *FaultGameHelper) Addr() common.Address {
return g.addr
}
func (g *FaultGameHelper) GameDuration(ctx context.Context) time.Duration {
duration, err := g.game.GAMEDURATION(&bind.CallOpts{Context: ctx})
g.require.NoError(err, "failed to get game duration")
......
......@@ -58,7 +58,7 @@ func TestMultipleCannonGames(t *testing.T) {
gameFactory := disputegame.NewFactoryHelper(t, ctx, sys.cfg.L1Deployments, l1Client)
// Start a challenger with the correct alphabet trace
gameFactory.StartChallenger(ctx, sys.NodeEndpoint("l1"), "TowerDefense",
challenger := gameFactory.StartChallenger(ctx, sys.NodeEndpoint("l1"), "TowerDefense",
challenger.WithCannon(t, sys.RollupConfig, sys.L2GenesisCfg, sys.NodeEndpoint("sequencer")),
challenger.WithPrivKey(sys.cfg.Secrets.Alice),
challenger.WithAgreeProposedOutput(true),
......@@ -74,6 +74,9 @@ func TestMultipleCannonGames(t *testing.T) {
game2Claim := game2.GetClaimValue(ctx, 1)
require.NotEqual(t, game1Claim, game2Claim, "games should have different cannon traces")
// Check that the helper finds the game directories correctly
challenger.VerifyGameDataExists(game1, game2)
// Push both games down to the step function
maxDepth := game1.MaxDepth(ctx)
for claimCount := int64(1); claimCount <= maxDepth; {
......@@ -97,8 +100,9 @@ func TestMultipleCannonGames(t *testing.T) {
game1.WaitForGameStatus(ctx, disputegame.StatusChallengerWins)
game2.WaitForGameStatus(ctx, disputegame.StatusChallengerWins)
game1.LogGameData(ctx)
game2.LogGameData(ctx)
// Check that the game directories are removed
challenger.VerifyNoGameDataExists(game1, game2)
}
func TestResolveDisputeGame(t *testing.T) {
......
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