|
|
@ -4,12 +4,15 @@ import ( |
|
|
|
"testing" |
|
|
|
"testing" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common" |
|
|
|
"github.com/ethereum/go-ethereum/common" |
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/ethdb" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
var addr = common.BytesToAddress([]byte("test")) |
|
|
|
var addr = common.BytesToAddress([]byte("test")) |
|
|
|
|
|
|
|
|
|
|
|
func create() (*ManagedState, *account) { |
|
|
|
func create() (*ManagedState, *account) { |
|
|
|
ms := ManageState(&StateDB{stateObjects: make(map[string]*StateObject)}) |
|
|
|
db, _ := ethdb.NewMemDatabase() |
|
|
|
|
|
|
|
statedb := New(common.Hash{}, db) |
|
|
|
|
|
|
|
ms := ManageState(statedb) |
|
|
|
so := &StateObject{address: addr, nonce: 100} |
|
|
|
so := &StateObject{address: addr, nonce: 100} |
|
|
|
ms.StateDB.stateObjects[addr.Str()] = so |
|
|
|
ms.StateDB.stateObjects[addr.Str()] = so |
|
|
|
ms.accounts[addr.Str()] = newAccount(so) |
|
|
|
ms.accounts[addr.Str()] = newAccount(so) |
|
|
@ -95,13 +98,13 @@ func TestSetNonce(t *testing.T) { |
|
|
|
ms.SetNonce(addr, 10) |
|
|
|
ms.SetNonce(addr, 10) |
|
|
|
|
|
|
|
|
|
|
|
if ms.GetNonce(addr) != 10 { |
|
|
|
if ms.GetNonce(addr) != 10 { |
|
|
|
t.Errorf("Expected nonce of 10, got", ms.GetNonce(addr)) |
|
|
|
t.Error("Expected nonce of 10, got", ms.GetNonce(addr)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
addr[0] = 1 |
|
|
|
addr[0] = 1 |
|
|
|
ms.StateDB.SetNonce(addr, 1) |
|
|
|
ms.StateDB.SetNonce(addr, 1) |
|
|
|
|
|
|
|
|
|
|
|
if ms.GetNonce(addr) != 1 { |
|
|
|
if ms.GetNonce(addr) != 1 { |
|
|
|
t.Errorf("Expected nonce of 1, got", ms.GetNonce(addr)) |
|
|
|
t.Error("Expected nonce of 1, got", ms.GetNonce(addr)) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|