multi_test.go 1.46 KB
Newer Older
1 2 3 4 5 6 7
package faultproofs

import (
	"context"
	"testing"

	op_e2e "github.com/ethereum-optimism/optimism/op-e2e"
8

9 10 11 12 13 14
	"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/challenger"
	"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/disputegame"
	"github.com/ethereum/go-ethereum/common"
)

func TestMultipleGameTypes(t *testing.T) {
15
	op_e2e.InitParallel(t, op_e2e.UsesCannon)
16 17

	ctx := context.Background()
18
	sys, _ := StartFaultDisputeSystem(t)
19 20
	t.Cleanup(sys.Close)

21
	gameFactory := disputegame.NewFactoryHelper(t, ctx, sys)
22 23

	game1 := gameFactory.StartOutputCannonGame(ctx, "sequencer", 1, common.Hash{0x01, 0xaa})
24
	game2 := gameFactory.StartOutputAlphabetGame(ctx, "sequencer", 1, common.Hash{0xbb})
25 26 27
	latestClaim1 := game1.DisputeLastBlock(ctx)
	latestClaim2 := game2.DisputeLastBlock(ctx)

28
	// Start a challenger with both cannon and alphabet support
29
	gameFactory.StartChallenger(ctx, "TowerDefense",
30
		challenger.WithCannon(t, sys),
31
		challenger.WithAlphabet(),
32 33 34 35
		challenger.WithPrivKey(sys.Cfg.Secrets.Alice),
	)

	// Wait for the challenger to respond to both games
36 37
	counter1 := latestClaim1.WaitForCounterClaim(ctx)
	counter2 := latestClaim2.WaitForCounterClaim(ctx)
38
	// The alphabet game always posts the same traces, so if they're different they can't both be from the alphabet.
39 40 41
	// We're contesting the same block with different VMs, so if the challenger was just playing two cannon or alphabet
	// games the responses would be equal.
	counter1.RequireDifferentClaimValue(counter2)
42
}