Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
dajuguan committed Oct 30, 2024
1 parent 4a3f017 commit 58eef2a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
37 changes: 34 additions & 3 deletions op-challenger2/game/fault/solver/game_rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package solver
import (
"testing"

faultTypes "github.com/ethereum-optimism/optimism/op-challenger/game/fault/types"
"github.com/ethereum-optimism/optimism/op-challenger2/game/fault/types"
gameTypes "github.com/ethereum-optimism/optimism/op-challenger2/game/types"
"github.com/ethereum-optimism/optimism/op-dispute-mon/mon"
Expand Down Expand Up @@ -83,7 +84,22 @@ func verifyChallengerNeverCountersAClaimTwice(t *testing.T, tree *disputeTypes.B
func enrichClaims(claims []types.Claim) []disputeTypes.EnrichedClaim {
enriched := make([]disputeTypes.EnrichedClaim, len(claims))
for i, claim := range claims {
enriched[i] = disputeTypes.EnrichedClaim{Claim: claim}
castedClaim := faultTypes.Claim{
ClaimData: faultTypes.ClaimData{
Value: claim.ClaimData.Value,
Bond: claim.ClaimData.Bond,
Position: faultTypes.NewPosition(faultTypes.Depth(claim.ClaimData.Position.Depth()), claim.ClaimData.Position.IndexAtDepth()),
},
CounteredBy: claim.CounteredBy,
Claimant: claim.Claimant,
Clock: faultTypes.Clock{
Duration: claim.Clock.Duration,
Timestamp: claim.Clock.Timestamp,
},
ContractIndex: claim.ContractIndex,
ParentContractIndex: claim.ParentContractIndex,
}
enriched[i] = disputeTypes.EnrichedClaim{Claim: castedClaim}
}
return enriched
}
Expand All @@ -93,7 +109,22 @@ func gameResult(game types.Game) (gameTypes.GameStatus, *disputeTypes.Bidirectio
result := mon.Resolve(tree)
resolvedClaims := make([]types.Claim, 0, len(tree.Claims))
for _, claim := range tree.Claims {
resolvedClaims = append(resolvedClaims, *claim.Claim)
castedClaim := types.Claim{
ClaimData: types.ClaimData{
Value: claim.Claim.ClaimData.Value,
Bond: claim.Claim.ClaimData.Bond,
Position: types.NewPosition(types.Depth(claim.Claim.ClaimData.Position.Depth()), claim.Claim.ClaimData.Position.IndexAtDepth()),
},
CounteredBy: claim.Claim.CounteredBy,
Claimant: claim.Claim.Claimant,
Clock: types.Clock{
Duration: claim.Claim.Clock.Duration,
Timestamp: claim.Claim.Clock.Timestamp,
},
ContractIndex: claim.Claim.ContractIndex,
ParentContractIndex: claim.Claim.ParentContractIndex,
}
resolvedClaims = append(resolvedClaims, castedClaim)
}
return result, tree, types.NewGameState(resolvedClaims, game.MaxDepth())
return gameTypes.GameStatusToOPChallenger2GameStatus(result), tree, types.NewGameState(resolvedClaims, game.MaxDepth())
}
10 changes: 5 additions & 5 deletions op-challenger2/game/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ type GameMetadata struct {
Proxy common.Address
}

func GameStatusToOPChallenger2GameStatus(claim gameTypes.GameStatus) GameStatus {
var castedClaim GameStatus
jsonBytes, _ := json.Marshal(claim)
json.Unmarshal(jsonBytes, &castedClaim)
return castedClaim
func GameStatusToOPChallenger2GameStatus(s gameTypes.GameStatus) GameStatus {
var castedStatus GameStatus
jsonBytes, _ := json.Marshal(s)
json.Unmarshal(jsonBytes, &castedStatus)
return castedStatus
}

0 comments on commit 58eef2a

Please sign in to comment.