Skip to content

Commit

Permalink
fix UT of parallel slotDB
Browse files Browse the repository at this point in the history
  • Loading branch information
sunny2022da committed Aug 16, 2024
1 parent 973a89a commit 02f0ba7
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion core/state/statedb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1207,6 +1207,7 @@ func TestSuicide(t *testing.T) {
unconfirmedDBs := new(sync.Map)

state.PrepareForParallel()
state.CreateParallelDBManager(1)
slotDb := NewSlotDB(state, 0, 0, unconfirmedDBs, false)

addr := common.BytesToAddress([]byte("so"))
Expand Down Expand Up @@ -1241,6 +1242,7 @@ func TestSetAndGetState(t *testing.T) {
state.SetBalance(addr, big.NewInt(1))
unconfirmedDBs := new(sync.Map)
state.PrepareForParallel()
state.CreateParallelDBManager(1)
slotDb := NewSlotDB(state, 0, 0, unconfirmedDBs, false)
slotDb.SetState(addr, common.BytesToHash([]byte("test key")), common.BytesToHash([]byte("test store")))

Expand Down Expand Up @@ -1278,6 +1280,7 @@ func TestSetAndGetCode(t *testing.T) {
state.PrepareForParallel()

unconfirmedDBs := new(sync.Map)
state.CreateParallelDBManager(1)
slotDb := NewSlotDB(state, 0, 0, unconfirmedDBs, false)
if _, ok := slotDb.parallel.dirtiedStateObjectsInSlot[addr]; ok {
t.Fatalf("address should not exist in dirtiedStateObjectsInSlot")
Expand Down Expand Up @@ -1313,6 +1316,7 @@ func TestGetCodeSize(t *testing.T) {
state.PrepareForParallel()

unconfirmedDBs := new(sync.Map)
state.CreateParallelDBManager(1)
slotDb := NewSlotDB(state, 0, 0, unconfirmedDBs, false)
slotDb.SetCode(addr, []byte("test code"))

Expand All @@ -1335,6 +1339,7 @@ func TestGetCodeHash(t *testing.T) {
state.SetBalance(addr, big.NewInt(1))
state.PrepareForParallel()
unconfirmedDBs := new(sync.Map)
state.CreateParallelDBManager(1)
slotDb := NewSlotDB(state, 0, 0, unconfirmedDBs, false)

slotDb.SetCode(addr, []byte("test code"))
Expand All @@ -1360,6 +1365,7 @@ func TestSetNonce(t *testing.T) {
state.PrepareForParallel()

unconfirmedDBs := new(sync.Map)
state.CreateParallelDBManager(1)
slotDb := NewSlotDB(state, 0, 0, unconfirmedDBs, false)
slotDb.SetNonce(addr, 2)

Expand All @@ -1386,6 +1392,7 @@ func TestSetAndGetBalance(t *testing.T) {
state.SetBalance(addr, big.NewInt(1))
state.PrepareForParallel()
unconfirmedDBs := new(sync.Map)
state.CreateParallelDBManager(1)
slotDb := NewSlotDB(state, 0, 0, unconfirmedDBs, false)

slotDb.SetBalance(addr, big.NewInt(2))
Expand Down Expand Up @@ -1422,6 +1429,7 @@ func TestSubBalance(t *testing.T) {

state.PrepareForParallel()
unconfirmedDBs := new(sync.Map)
state.CreateParallelDBManager(1)
slotDb := NewSlotDB(state, 0, 0, unconfirmedDBs, false)
slotDb.SubBalance(addr, big.NewInt(1))

Expand Down Expand Up @@ -1456,6 +1464,7 @@ func TestAddBalance(t *testing.T) {
state.SetBalance(addr, big.NewInt(2))
state.PrepareForParallel()
unconfirmedDBs := new(sync.Map)
state.CreateParallelDBManager(1)
slotDb := NewSlotDB(state, 0, 0, unconfirmedDBs, false)
slotDb.AddBalance(addr, big.NewInt(1))

Expand Down Expand Up @@ -1491,6 +1500,7 @@ func TestEmpty(t *testing.T) {
state.PrepareForParallel()

unconfirmedDBs := new(sync.Map)
state.CreateParallelDBManager(1)
slotDb := NewSlotDB(state, 0, 0, unconfirmedDBs, false)

empty := slotDb.Empty(addr)
Expand All @@ -1511,6 +1521,7 @@ func TestExist(t *testing.T) {
state.SetBalance(addr, big.NewInt(2))
state.PrepareForParallel()
unconfirmedDBs := new(sync.Map)
state.CreateParallelDBManager(1)
slotDb := NewSlotDB(state, 0, 0, unconfirmedDBs, false)

exist := slotDb.Exist(addr)
Expand All @@ -1529,7 +1540,7 @@ func TestMergeSlotDB(t *testing.T) {
state, _ := New(common.Hash{}, db, nil)
state.PrepareForParallel()
unconfirmedDBs := new(sync.Map)

state.CreateParallelDBManager(1)
oldSlotDb := NewSlotDB(state, 0, 0, unconfirmedDBs, false)

newSlotDb := NewSlotDB(state, 0, 0, unconfirmedDBs, false)
Expand Down

0 comments on commit 02f0ba7

Please sign in to comment.