Skip to content

Commit

Permalink
op-e2e: Expose fields for asterisc e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
pcw109550 committed Apr 19, 2024
1 parent 1bc41f2 commit afe3725
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions op-e2e/e2eutils/disputegame/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,27 @@ func (s Status) String() string {
}
}

type gameCfg struct {
type GameCfg struct {
allowFuture bool
allowUnsafe bool
}
type GameOpt interface {
Apply(cfg *gameCfg)
Apply(cfg *GameCfg)
}
type gameOptFn func(c *gameCfg)
type gameOptFn func(c *GameCfg)

func (g gameOptFn) Apply(cfg *gameCfg) {
func (g gameOptFn) Apply(cfg *GameCfg) {
g(cfg)
}

func WithUnsafeProposal() GameOpt {
return gameOptFn(func(c *gameCfg) {
return gameOptFn(func(c *GameCfg) {
c.allowUnsafe = true
})
}

func WithFutureProposal() GameOpt {
return gameOptFn(func(c *gameCfg) {
return gameOptFn(func(c *GameCfg) {
c.allowFuture = true
})
}
Expand Down Expand Up @@ -146,8 +146,8 @@ func (h *FactoryHelper) PreimageHelper(ctx context.Context) *preimage.Helper {
return preimage.NewHelper(h.T, h.Opts, h.Client, oracleAddr)
}

func NewGameCfg(opts ...GameOpt) *gameCfg {
cfg := &gameCfg{}
func NewGameCfg(opts ...GameOpt) *GameCfg {
cfg := &GameCfg{}
for _, opt := range opts {
opt.Apply(cfg)
}
Expand Down Expand Up @@ -257,15 +257,15 @@ func (h *FactoryHelper) StartOutputAlphabetGame(ctx context.Context, l2Node stri
}
}

func (h *FactoryHelper) CreateBisectionGameExtraData(l2Node string, l2BlockNumber uint64, cfg *gameCfg) []byte {
func (h *FactoryHelper) CreateBisectionGameExtraData(l2Node string, l2BlockNumber uint64, cfg *GameCfg) []byte {
h.WaitForBlock(l2Node, l2BlockNumber, cfg)
h.T.Logf("Creating game with l2 block number: %v", l2BlockNumber)
extraData := make([]byte, 32)
binary.BigEndian.PutUint64(extraData[24:], l2BlockNumber)
return extraData
}

func (h *FactoryHelper) WaitForBlock(l2Node string, l2BlockNumber uint64, cfg *gameCfg) {
func (h *FactoryHelper) WaitForBlock(l2Node string, l2BlockNumber uint64, cfg *GameCfg) {
if cfg.allowFuture {
// Proposing a block that doesn't exist yet, so don't perform any checks
return
Expand Down

0 comments on commit afe3725

Please sign in to comment.