diff options
author | obscuren <geffobscura@gmail.com> | 2015-03-14 00:47:00 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-03-14 00:47:00 +0800 |
commit | a0266489b4592af751d87c59087ed25a32899de6 (patch) | |
tree | 4adeaf731ad8d2a0c20a7738caf25ef3a086248a /state/managed_state_test.go | |
parent | b663e8b29a7451a79b909c017f8a244d23c8fef4 (diff) | |
download | go-tangerine-a0266489b4592af751d87c59087ed25a32899de6.tar go-tangerine-a0266489b4592af751d87c59087ed25a32899de6.tar.gz go-tangerine-a0266489b4592af751d87c59087ed25a32899de6.tar.bz2 go-tangerine-a0266489b4592af751d87c59087ed25a32899de6.tar.lz go-tangerine-a0266489b4592af751d87c59087ed25a32899de6.tar.xz go-tangerine-a0266489b4592af751d87c59087ed25a32899de6.tar.zst go-tangerine-a0266489b4592af751d87c59087ed25a32899de6.zip |
Make remote dominant
Diffstat (limited to 'state/managed_state_test.go')
-rw-r--r-- | state/managed_state_test.go | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/state/managed_state_test.go b/state/managed_state_test.go index ae374f728..da52ab270 100644 --- a/state/managed_state_test.go +++ b/state/managed_state_test.go @@ -1,12 +1,18 @@ package state -import "testing" +import ( + "testing" -var addr = []byte("test") + "github.com/ethereum/go-ethereum/ethutil" +) + +var addr = ethutil.Address([]byte("test")) func create() (*ManagedState, *account) { - ms := ManageState(nil) - ms.accounts[string(addr)] = newAccount(&StateObject{nonce: 100}) + ms := ManageState(&StateDB{stateObjects: make(map[string]*StateObject)}) + so := &StateObject{address: addr, nonce: 100} + ms.StateDB.stateObjects[string(addr)] = so + ms.accounts[string(addr)] = newAccount(so) return ms, ms.accounts[string(addr)] } @@ -16,6 +22,11 @@ func TestNewNonce(t *testing.T) { nonce := ms.NewNonce(addr) if nonce != 100 { + t.Error("expected nonce 100. got", nonce) + } + + nonce = ms.NewNonce(addr) + if nonce != 101 { t.Error("expected nonce 101. got", nonce) } } @@ -52,3 +63,19 @@ func TestReuse(t *testing.T) { t.Error("expected nonce to be 105. got", nonce) } } + +func TestRemoteNonceChange(t *testing.T) { + ms, account := create() + nn := make([]bool, 10) + for i, _ := range nn { + nn[i] = true + } + account.nonces = append(account.nonces, nn...) + nonce := ms.NewNonce(addr) + + ms.StateDB.stateObjects[string(addr)].nonce = 200 + nonce = ms.NewNonce(addr) + if nonce != 200 { + t.Error("expected nonce after remote update to be", 201, "got", nonce) + } +} |