Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
make it one liner
Browse files Browse the repository at this point in the history
  • Loading branch information
igorcrevar committed Sep 22, 2022
1 parent 07126a4 commit b7ef727
Showing 1 changed file with 12 additions and 24 deletions.
36 changes: 12 additions & 24 deletions state/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,13 @@ func testDeleteCommonStateRoot(t *testing.T, buildPreState buildPreState) {
txn.SetState(addr2, hash1, hash1)
txn.SetState(addr2, hash2, hash1)

objs := txn.Commit(false)
snap2, _ := snap.Commit(objs)
snap2, _ := snap.Commit(txn.Commit(false))
txn2 := newTxn(state, snap2)

txn2.SetState(addr1, hash0, hash0)
txn2.SetState(addr1, hash1, hash0)

objs = txn2.Commit(false)
snap3, _ := snap2.Commit(objs)
snap3, _ := snap2.Commit(txn2.Commit(false))

txn3 := newTxn(state, snap3)
assert.Equal(t, hash1, txn3.GetState(addr1, hash2))
Expand All @@ -148,8 +146,7 @@ func testWriteState(t *testing.T, buildPreState buildPreState) {
assert.Equal(t, hash1, txn.GetState(addr1, hash1))
assert.Equal(t, hash2, txn.GetState(addr1, hash2))

objs := txn.Commit(false)
snap, _ = snap.Commit(objs)
snap, _ = snap.Commit(txn.Commit(false))

txn = newTxn(state, snap)
assert.Equal(t, hash1, txn.GetState(addr1, hash1))
Expand All @@ -164,8 +161,7 @@ func testWriteEmptyState(t *testing.T, buildPreState buildPreState) {

// Without EIP150 the data is added
txn.SetState(addr1, hash1, hash0)
objs := txn.Commit(false)
snap, _ = snap.Commit(objs)
snap, _ = snap.Commit(txn.Commit(false))

txn = newTxn(state, snap)
assert.True(t, txn.Exist(addr1))
Expand All @@ -175,8 +171,7 @@ func testWriteEmptyState(t *testing.T, buildPreState buildPreState) {

// With EIP150 the empty data is removed
txn.SetState(addr1, hash1, hash0)
objs = txn.Commit(true)
snap, _ = snap.Commit(objs)
snap, _ = snap.Commit(txn.Commit(true))

txn = newTxn(state, snap)
assert.False(t, txn.Exist(addr1))
Expand All @@ -193,8 +188,7 @@ func testUpdateStateWithEmpty(t *testing.T, buildPreState buildPreState) {

// TODO, test with false (should not be deleted)
// TODO, test with balance on the account and nonce
objs := txn.Commit(true)
snap, _ = snap.Commit(objs)
snap, _ = snap.Commit(txn.Commit(true))

txn = newTxn(state, snap)
assert.False(t, txn.Exist(addr1))
Expand All @@ -208,8 +202,7 @@ func testSuicideAccountInPreState(t *testing.T, buildPreState buildPreState) {

txn := newTxn(state, snap)
txn.Suicide(addr1)
objs := txn.Commit(true)
snap, _ = snap.Commit(objs)
snap, _ = snap.Commit(txn.Commit(true))

txn = newTxn(state, snap)
assert.False(t, txn.Exist(addr1))
Expand All @@ -227,8 +220,7 @@ func testSuicideAccount(t *testing.T, buildPreState buildPreState) {
// Note, even if has commit suicide it still exists in the current txn
assert.True(t, txn.Exist(addr1))

objs := txn.Commit(true)
snap, _ = snap.Commit(objs)
snap, _ = snap.Commit(txn.Commit(true))

txn = newTxn(state, snap)
assert.False(t, txn.Exist(addr1))
Expand All @@ -249,8 +241,7 @@ func testSuicideAccountWithData(t *testing.T, buildPreState buildPreState) {
txn.SetState(addr1, hash1, hash1)

txn.Suicide(addr1)
objs := txn.Commit(true)
snap, _ = snap.Commit(objs)
snap, _ = snap.Commit(txn.Commit(true))

txn = newTxn(state, snap)

Expand All @@ -273,8 +264,7 @@ func testSuicideCoinbase(t *testing.T, buildPreState buildPreState) {
txn := newTxn(state, snap)
txn.Suicide(addr1)
txn.AddSealingReward(addr1, big.NewInt(10))
objs := txn.Commit(true)
snap, _ = snap.Commit(objs)
snap, _ = snap.Commit(txn.Commit(true))

txn = newTxn(state, snap)
assert.Equal(t, big.NewInt(10), txn.GetBalance(addr1))
Expand Down Expand Up @@ -328,8 +318,7 @@ func testChangePrestateAccountBalanceToZero(t *testing.T, buildPreState buildPre

txn := newTxn(state, snap)
txn.SetBalance(addr1, big.NewInt(0))
objs := txn.Commit(true)
snap, _ = snap.Commit(objs)
snap, _ = snap.Commit(txn.Commit(true))

txn = newTxn(state, snap)
assert.False(t, txn.Exist(addr1))
Expand All @@ -344,8 +333,7 @@ func testChangeAccountBalanceToZero(t *testing.T, buildPreState buildPreState) {
txn.SetBalance(addr1, big.NewInt(10))
txn.SetBalance(addr1, big.NewInt(0))

objs := txn.Commit(true)
snap, _ = snap.Commit(objs)
snap, _ = snap.Commit(txn.Commit(true))

txn = newTxn(state, snap)
assert.False(t, txn.Exist(addr1))
Expand Down

0 comments on commit b7ef727

Please sign in to comment.