Skip to content

Commit

Permalink
chore(op-challenger): address comment & cosmetic
Browse files Browse the repository at this point in the history
  • Loading branch information
dajuguan committed Oct 27, 2024
1 parent 94a6133 commit 425ac92
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ func TestGetSubClaims(t *testing.T) {
require.NoError(t, err)
packed, err := tx.MarshalBinary()
require.NoError(t, err)
stubRpc.SetTxResponse(txHash, packed)
stubRpc.SetGetTxByHashResponse(txHash, packed)

claims, err := game.GetSubClaims(context.Background(), block, &claim0)
require.NoError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions op-service/sources/batching/test/abi_stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ func (l *AbiBasedRpc) SetFilterLogResponse(topics [][]common.Hash, to common.Add
})
}

func (l *AbiBasedRpc) SetTxResponse(txHash common.Hash, output []byte) {
func (l *AbiBasedRpc) SetGetTxByHashResponse(txHash common.Hash, output []byte) {
if output == nil {
output = []byte{}
}
l.AddExpectedCall(&expectedTxCall{txHash: txHash, outputs: output})
l.AddExpectedCall(&expectedGetTxByHashCall{txHash: txHash, outputs: output})
}

func (l *AbiBasedRpc) VerifyTxCandidate(candidate txmgr.TxCandidate) {
Expand Down
2 changes: 1 addition & 1 deletion op-service/sources/batching/test/event_stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (c *expectedFilterLogsCall) Matches(rpcMethod string, args ...interface{})
func (c *expectedFilterLogsCall) Execute(t *testing.T, out interface{}) error {
j, err := json.Marshal(c.outputs)
require.NoError(t, err)
json.Unmarshal(j, out)
require.NoError(t, json.Unmarshal(j, out))
return c.err
}

Expand Down
10 changes: 5 additions & 5 deletions op-service/sources/batching/test/tx_stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (
"github.com/stretchr/testify/require"
)

type expectedTxCall struct {
type expectedGetTxByHashCall struct {
txHash common.Hash
outputs []byte
err error
}

func (c *expectedTxCall) Matches(rpcMethod string, args ...interface{}) error {
func (c *expectedGetTxByHashCall) Matches(rpcMethod string, args ...interface{}) error {
if rpcMethod != "eth_getTransactionByHash" {
return fmt.Errorf("expected rpcMethod eth_getTransactionByHash but was %v", rpcMethod)
}
Expand All @@ -30,13 +30,13 @@ func (c *expectedTxCall) Matches(rpcMethod string, args ...interface{}) error {
return c.err
}

func (c *expectedTxCall) Execute(t *testing.T, out interface{}) error {
func (c *expectedGetTxByHashCall) Execute(t *testing.T, out interface{}) error {
j, err := json.Marshal(hexutil.Bytes(c.outputs))
require.NoError(t, err)
json.Unmarshal(j, out)
require.NoError(t, json.Unmarshal(j, out))
return c.err
}

func (c *expectedTxCall) String() string {
func (c *expectedGetTxByHashCall) String() string {
return fmt.Sprintf("{txHash: %v, outputs: %v}", c.txHash, c.outputs)
}

0 comments on commit 425ac92

Please sign in to comment.