Skip to content

Commit d939231

Browse files
committed
sync
1 parent 6c8f7d6 commit d939231

File tree

1 file changed

+0
-57
lines changed

1 file changed

+0
-57
lines changed

cmd/mel-replay/txs_fetcher_test.go

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,13 @@ package main
22

33
import (
44
"context"
5-
"fmt"
65
"math/big"
76
"testing"
87

98
"github.com/stretchr/testify/require"
109

1110
"github.com/ethereum/go-ethereum/common"
1211
"github.com/ethereum/go-ethereum/core/types"
13-
"github.com/ethereum/go-ethereum/crypto"
14-
"github.com/ethereum/go-ethereum/trie"
15-
16-
"github.com/offchainlabs/nitro/arbutil"
1712
)
1813

1914
func TestFetchTransactionsForBlockHeader_DynamicFeeTxs(t *testing.T) {
@@ -80,55 +75,3 @@ func TestFetchTransactionsForBlockHeader_LegacyTxs(t *testing.T) {
8075
require.Equal(t, uint64(i), tx.Nonce()) // #nosec G115
8176
}
8277
}
83-
84-
type mockPreimageResolver struct {
85-
preimages map[common.Hash][]byte
86-
}
87-
88-
func (m *mockPreimageResolver) ResolveTypedPreimage(preimageType arbutil.PreimageType, hash common.Hash) ([]byte, error) {
89-
if preimage, exists := m.preimages[hash]; exists {
90-
return preimage, nil
91-
}
92-
return nil, fmt.Errorf("preimage not found for hash: %s", hash.Hex())
93-
}
94-
95-
// Implements a hasher that captures preimages of hashes as it computes them.
96-
type preimageRecordingHasher struct {
97-
trie *trie.StackTrie
98-
preimages map[common.Hash][]byte
99-
}
100-
101-
func newRecordingHasher() *preimageRecordingHasher {
102-
h := &preimageRecordingHasher{
103-
preimages: make(map[common.Hash][]byte),
104-
}
105-
// OnTrieNode callback captures all trie nodes.
106-
onTrieNode := func(path []byte, hash common.Hash, blob []byte) {
107-
// Deep copy the blob since the callback warns contents may change, so this is required.
108-
h.preimages[hash] = common.CopyBytes(blob)
109-
}
110-
111-
h.trie = trie.NewStackTrie(onTrieNode)
112-
return h
113-
}
114-
115-
func (h *preimageRecordingHasher) Reset() {
116-
onTrieNode := func(path []byte, hash common.Hash, blob []byte) {
117-
h.preimages[hash] = common.CopyBytes(blob)
118-
}
119-
h.trie = trie.NewStackTrie(onTrieNode)
120-
}
121-
122-
func (h *preimageRecordingHasher) Update(key, value []byte) error {
123-
valueHash := crypto.Keccak256Hash(value)
124-
h.preimages[valueHash] = common.CopyBytes(value)
125-
return h.trie.Update(key, value)
126-
}
127-
128-
func (h *preimageRecordingHasher) Hash() common.Hash {
129-
return h.trie.Hash()
130-
}
131-
132-
func (h *preimageRecordingHasher) GetPreimages() map[common.Hash][]byte {
133-
return h.preimages
134-
}

0 commit comments

Comments
 (0)