Commit 192f0a4d authored by Andreas Bigger's avatar Andreas Bigger

Refactor position construction

parent 8003fe0f
...@@ -141,6 +141,11 @@ func (g *FaultGameHelper) getClaim(ctx context.Context, claimIdx int64) Contract ...@@ -141,6 +141,11 @@ func (g *FaultGameHelper) getClaim(ctx context.Context, claimIdx int64) Contract
return claimData return claimData
} }
// getClaimPosition retrieves the [types.Position] of a claim at a specific index.
func (g *FaultGameHelper) getClaimPosition(ctx context.Context, claimIdx int64) types.Position {
return types.NewPositionFromGIndex(g.getClaim(ctx, claimIdx).Position.Uint64())
}
func (g *FaultGameHelper) WaitForClaimAtDepth(ctx context.Context, depth int) { func (g *FaultGameHelper) WaitForClaimAtDepth(ctx context.Context, depth int) {
g.waitForClaim( g.waitForClaim(
ctx, ctx,
......
...@@ -44,8 +44,7 @@ func (h *HonestHelper) Defend(ctx context.Context, claimIdx int64) { ...@@ -44,8 +44,7 @@ func (h *HonestHelper) Defend(ctx context.Context, claimIdx int64) {
func (h *HonestHelper) StepFails(ctx context.Context, claimIdx int64, isAttack bool) { func (h *HonestHelper) StepFails(ctx context.Context, claimIdx int64, isAttack bool) {
ctx, cancel := context.WithTimeout(ctx, 2*time.Minute) ctx, cancel := context.WithTimeout(ctx, 2*time.Minute)
defer cancel() defer cancel()
claim := h.game.getClaim(ctx, claimIdx) pos := h.game.getClaimPosition(ctx, claimIdx)
pos := types.NewPositionFromGIndex(claim.Position.Uint64())
if !isAttack { if !isAttack {
// If we're defending, then the step will be from the trace to the next one // If we're defending, then the step will be from the trace to the next one
pos = pos.MoveRight() pos = pos.MoveRight()
......
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