Commit d8bde214 authored by amber guru's avatar amber guru Committed by GitHub

op-e2e: Replace errors import with errutil in correct case (#10844)

* Replace errors import with errutil in correct case

* fix after goimports -w .
parent f3da9a53
...@@ -5,7 +5,7 @@ import ( ...@@ -5,7 +5,7 @@ import (
"fmt" "fmt"
"os" "os"
"github.com/ethereum-optimism/optimism/op-preimage" preimage "github.com/ethereum-optimism/optimism/op-preimage"
) )
type rawHint string type rawHint string
......
...@@ -3,7 +3,6 @@ package disputegame ...@@ -3,7 +3,6 @@ package disputegame
import ( import (
"context" "context"
"crypto/ecdsa" "crypto/ecdsa"
"errors"
"fmt" "fmt"
"math/big" "math/big"
"testing" "testing"
...@@ -19,6 +18,7 @@ import ( ...@@ -19,6 +18,7 @@ import (
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/transactions" "github.com/ethereum-optimism/optimism/op-e2e/e2eutils/transactions"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait" "github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait"
preimage "github.com/ethereum-optimism/optimism/op-preimage" preimage "github.com/ethereum-optimism/optimism/op-preimage"
"github.com/ethereum-optimism/optimism/op-service/errutil"
"github.com/ethereum-optimism/optimism/op-service/eth" "github.com/ethereum-optimism/optimism/op-service/eth"
"github.com/ethereum-optimism/optimism/op-service/sources/batching/rpcblock" "github.com/ethereum-optimism/optimism/op-service/sources/batching/rpcblock"
"github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/abi/bind"
...@@ -578,20 +578,15 @@ func (g *OutputGameHelper) hasClaim(ctx context.Context, parentIdx int64, pos ty ...@@ -578,20 +578,15 @@ func (g *OutputGameHelper) hasClaim(ctx context.Context, parentIdx int64, pos ty
return false return false
} }
type ErrWithData interface {
ErrorData() interface{}
}
// StepFails attempts to call step and verifies that it fails with ValidStep() // StepFails attempts to call step and verifies that it fails with ValidStep()
func (g *OutputGameHelper) StepFails(ctx context.Context, claimIdx int64, isAttack bool, stateData []byte, proof []byte) { func (g *OutputGameHelper) StepFails(ctx context.Context, claimIdx int64, isAttack bool, stateData []byte, proof []byte) {
g.T.Logf("Attempting step against claim %v isAttack: %v", claimIdx, isAttack) g.T.Logf("Attempting step against claim %v isAttack: %v", claimIdx, isAttack)
candidate, err := g.Game.StepTx(uint64(claimIdx), isAttack, stateData, proof) candidate, err := g.Game.StepTx(uint64(claimIdx), isAttack, stateData, proof)
g.Require.NoError(err, "Failed to create tx candidate") g.Require.NoError(err, "Failed to create tx candidate")
_, _, err = transactions.SendTx(ctx, g.Client, candidate, g.PrivKey, transactions.WithReceiptFail()) _, _, err = transactions.SendTx(ctx, g.Client, candidate, g.PrivKey, transactions.WithReceiptFail())
var errData ErrWithData err = errutil.TryAddRevertReason(err)
ok := errors.As(err, &errData) g.Require.Error(err, "Transaction should fail")
g.Require.Truef(ok, "Error should provide ErrorData method: %v", err) g.Require.Contains(err.Error(), "0xfb4e40dd", "Revert reason should be abi encoded ValidStep()")
g.Require.Equal("0xfb4e40dd", errData.ErrorData(), "Revert reason should be abi encoded ValidStep()")
} }
// ResolveClaim resolves a single subgame // ResolveClaim resolves a single subgame
......
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