mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 13:16:42 +00:00
triedb/path: rename
This commit is contained in:
parent
a3cd3d946e
commit
2bccfcd2c4
3 changed files with 19 additions and 19 deletions
|
|
@ -180,7 +180,7 @@ func TestBatchIndexerWrite(t *testing.T) {
|
|||
var (
|
||||
db = rawdb.NewMemoryDatabase()
|
||||
batch = newBatchIndexer(db, false)
|
||||
histories = makeHistories(10)
|
||||
histories = makeStateHistories(10)
|
||||
)
|
||||
for i, h := range histories {
|
||||
if err := batch.process(h, uint64(i+1)); err != nil {
|
||||
|
|
@ -257,7 +257,7 @@ func TestBatchIndexerDelete(t *testing.T) {
|
|||
var (
|
||||
db = rawdb.NewMemoryDatabase()
|
||||
bw = newBatchIndexer(db, false)
|
||||
histories = makeHistories(10)
|
||||
histories = makeStateHistories(10)
|
||||
)
|
||||
// Index histories
|
||||
for i, h := range histories {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ func TestHistoryIndexerShortenDeadlock(t *testing.T) {
|
|||
freezer, _ := rawdb.NewStateFreezer(t.TempDir(), false, false)
|
||||
defer freezer.Close()
|
||||
|
||||
histories := makeHistories(100)
|
||||
histories := makeStateHistories(100)
|
||||
for i, h := range histories {
|
||||
accountData, storageData, accountIndex, storageIndex := h.encode()
|
||||
rawdb.WriteStateHistory(freezer, uint64(i+1), h.meta.encode(), accountIndex, storageIndex, accountData, storageData)
|
||||
|
|
|
|||
|
|
@ -49,12 +49,12 @@ func randomStateSet(n int) (map[common.Address][]byte, map[common.Address]map[co
|
|||
return accounts, storages
|
||||
}
|
||||
|
||||
func makeHistory(rawStorageKey bool) *stateHistory {
|
||||
func makeStateHistory(rawStorageKey bool) *stateHistory {
|
||||
accounts, storages := randomStateSet(3)
|
||||
return newStateHistory(testrand.Hash(), types.EmptyRootHash, 0, accounts, storages, rawStorageKey)
|
||||
}
|
||||
|
||||
func makeHistories(n int) []*stateHistory {
|
||||
func makeStateHistories(n int) []*stateHistory {
|
||||
var (
|
||||
parent = types.EmptyRootHash
|
||||
result []*stateHistory
|
||||
|
|
@ -69,16 +69,16 @@ func makeHistories(n int) []*stateHistory {
|
|||
return result
|
||||
}
|
||||
|
||||
func TestEncodeDecodeHistory(t *testing.T) {
|
||||
testEncodeDecodeHistory(t, false)
|
||||
testEncodeDecodeHistory(t, true)
|
||||
func TestEncodeDecodeStateHistory(t *testing.T) {
|
||||
testEncodeDecodeStateHistory(t, false)
|
||||
testEncodeDecodeStateHistory(t, true)
|
||||
}
|
||||
|
||||
func testEncodeDecodeHistory(t *testing.T, rawStorageKey bool) {
|
||||
func testEncodeDecodeStateHistory(t *testing.T, rawStorageKey bool) {
|
||||
var (
|
||||
m meta
|
||||
dec stateHistory
|
||||
obj = makeHistory(rawStorageKey)
|
||||
obj = makeStateHistory(rawStorageKey)
|
||||
)
|
||||
// check if meta data can be correctly encode/decode
|
||||
blob := obj.meta.encode()
|
||||
|
|
@ -108,7 +108,7 @@ func testEncodeDecodeHistory(t *testing.T, rawStorageKey bool) {
|
|||
}
|
||||
}
|
||||
|
||||
func checkHistory(t *testing.T, db ethdb.KeyValueReader, freezer ethdb.AncientReader, id uint64, root common.Hash, exist bool) {
|
||||
func checkStateHistory(t *testing.T, db ethdb.KeyValueReader, freezer ethdb.AncientReader, id uint64, root common.Hash, exist bool) {
|
||||
blob := rawdb.ReadStateHistoryMeta(freezer, id)
|
||||
if exist && len(blob) == 0 {
|
||||
t.Fatalf("Failed to load trie history, %d", id)
|
||||
|
|
@ -126,14 +126,14 @@ func checkHistory(t *testing.T, db ethdb.KeyValueReader, freezer ethdb.AncientRe
|
|||
|
||||
func checkHistoriesInRange(t *testing.T, db ethdb.KeyValueReader, freezer ethdb.AncientReader, from, to uint64, roots []common.Hash, exist bool) {
|
||||
for i, j := from, 0; i <= to; i, j = i+1, j+1 {
|
||||
checkHistory(t, db, freezer, i, roots[j], exist)
|
||||
checkStateHistory(t, db, freezer, i, roots[j], exist)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTruncateHeadHistory(t *testing.T) {
|
||||
func TestTruncateHeadStateHistory(t *testing.T) {
|
||||
var (
|
||||
roots []common.Hash
|
||||
hs = makeHistories(10)
|
||||
hs = makeStateHistories(10)
|
||||
db = rawdb.NewMemoryDatabase()
|
||||
freezer, _ = rawdb.NewStateFreezer(t.TempDir(), false, false)
|
||||
)
|
||||
|
|
@ -158,10 +158,10 @@ func TestTruncateHeadHistory(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestTruncateTailHistory(t *testing.T) {
|
||||
func TestTruncateTailStateHistory(t *testing.T) {
|
||||
var (
|
||||
roots []common.Hash
|
||||
hs = makeHistories(10)
|
||||
hs = makeStateHistories(10)
|
||||
db = rawdb.NewMemoryDatabase()
|
||||
freezer, _ = rawdb.NewStateFreezer(t.TempDir(), false, false)
|
||||
)
|
||||
|
|
@ -183,7 +183,7 @@ func TestTruncateTailHistory(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestTruncateTailHistories(t *testing.T) {
|
||||
func TestTruncateTailStateHistories(t *testing.T) {
|
||||
var cases = []struct {
|
||||
limit uint64
|
||||
expPruned int
|
||||
|
|
@ -204,7 +204,7 @@ func TestTruncateTailHistories(t *testing.T) {
|
|||
for i, c := range cases {
|
||||
var (
|
||||
roots []common.Hash
|
||||
hs = makeHistories(10)
|
||||
hs = makeStateHistories(10)
|
||||
db = rawdb.NewMemoryDatabase()
|
||||
freezer, _ = rawdb.NewStateFreezer(t.TempDir()+fmt.Sprintf("%d", i), false, false)
|
||||
)
|
||||
|
|
@ -232,7 +232,7 @@ func TestTruncateTailHistories(t *testing.T) {
|
|||
|
||||
func TestTruncateOutOfRange(t *testing.T) {
|
||||
var (
|
||||
hs = makeHistories(10)
|
||||
hs = makeStateHistories(10)
|
||||
db = rawdb.NewMemoryDatabase()
|
||||
freezer, _ = rawdb.NewStateFreezer(t.TempDir(), false, false)
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue