Skip to content

Commit

Permalink
mock OutputV0AtBlock in server_test
Browse files Browse the repository at this point in the history
  • Loading branch information
Inphi committed Jul 25, 2023
1 parent e3b54b0 commit 9c1d614
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
20 changes: 6 additions & 14 deletions op-node/node/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"

"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/metrics"
"github.com/ethereum-optimism/optimism/op-node/rollup"
Expand Down Expand Up @@ -84,17 +83,6 @@ func TestOutputAtBlock(t *testing.T) {
}

l2Client := &testutils.MockL2Client{}
info := &testutils.MockBlockInfo{
InfoHash: header.Hash(),
InfoParentHash: header.ParentHash,
InfoCoinbase: header.Coinbase,
InfoRoot: header.Root,
InfoNum: header.Number.Uint64(),
InfoTime: header.Time,
InfoMixDigest: header.MixDigest,
InfoBaseFee: header.BaseFee,
InfoReceiptRoot: header.ReceiptHash,
}
ref := eth.L2BlockRef{
Hash: header.Hash(),
Number: header.Number.Uint64(),
Expand All @@ -103,8 +91,12 @@ func TestOutputAtBlock(t *testing.T) {
L1Origin: eth.BlockID{},
SequenceNumber: 0,
}
l2Client.ExpectInfoByHash(common.HexToHash("0x8512bee03061475e4b069171f7b406097184f16b22c3f5c97c0abfc49591c524"), info, nil)
l2Client.ExpectGetProof(predeploys.L2ToL1MessagePasserAddr, []common.Hash{}, "0x8512bee03061475e4b069171f7b406097184f16b22c3f5c97c0abfc49591c524", &result, nil)
output := &eth.OutputV0{
StateRoot: eth.Bytes32(header.Root),
BlockHash: ref.Hash,
MessagePasserStorageRoot: eth.Bytes32(result.StorageHash),
}
l2Client.ExpectOutputV0AtBlock(common.HexToHash("0x8512bee03061475e4b069171f7b406097184f16b22c3f5c97c0abfc49591c524"), output, nil)

drClient := &mockDriverClient{}
status := randomSyncStatus(rand.New(rand.NewSource(123)))
Expand Down
3 changes: 1 addition & 2 deletions op-node/testutils/mock_l2.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ func (m *MockL2Client) ExpectSystemConfigByL2Hash(hash common.Hash, cfg eth.Syst
}

func (m *MockL2Client) OutputV0AtBlock(ctx context.Context, blockHash common.Hash) (*eth.OutputV0, error) {
out := m.Mock.MethodCalled("OutputV0AtBlock", blockHash)
return out[0].(*eth.OutputV0), *out[1].(*error)
return m.Mock.MethodCalled("OutputV0AtBlock", blockHash).Get(0).(*eth.OutputV0), nil
}

func (m *MockL2Client) ExpectOutputV0AtBlock(blockHash common.Hash, output *eth.OutputV0, err error) {
Expand Down

0 comments on commit 9c1d614

Please sign in to comment.