MCPcopy Create free account
hub / github.com/CPChain/chain / compareStateObjects

Function compareStateObjects

core/state/state_test.go:191–231  ·  view source on GitHub ↗
(so0, so1 *stateObject, t *testing.T)

Source from the content-addressed store, hash-verified

189}
190
191func compareStateObjects(so0, so1 *stateObject, t *testing.T) {
192 if so0.Address() != so1.Address() {
193 t.Fatalf("Address mismatch: have %v, want %v", so0.address, so1.address)
194 }
195 if so0.Balance().Cmp(so1.Balance()) != 0 {
196 t.Fatalf("Balance mismatch: have %v, want %v", so0.Balance(), so1.Balance())
197 }
198 if so0.Nonce() != so1.Nonce() {
199 t.Fatalf("Nonce mismatch: have %v, want %v", so0.Nonce(), so1.Nonce())
200 }
201 if so0.data.Root != so1.data.Root {
202 t.Errorf("StateRoot mismatch: have %x, want %x", so0.data.Root[:], so1.data.Root[:])
203 }
204 if !bytes.Equal(so0.CodeHash(), so1.CodeHash()) {
205 t.Fatalf("CodeHash mismatch: have %v, want %v", so0.CodeHash(), so1.CodeHash())
206 }
207 if !bytes.Equal(so0.code, so1.code) {
208 t.Fatalf("Code mismatch: have %v, want %v", so0.code, so1.code)
209 }
210
211 if len(so1.cachedStorage) != len(so0.cachedStorage) {
212 t.Errorf("Storage size mismatch: have %d, want %d", len(so1.cachedStorage), len(so0.cachedStorage))
213 }
214 for k, v := range so1.cachedStorage {
215 if so0.cachedStorage[k] != v {
216 t.Errorf("Storage key %x mismatch: have %v, want %v", k, so0.cachedStorage[k], v)
217 }
218 }
219 for k, v := range so0.cachedStorage {
220 if so1.cachedStorage[k] != v {
221 t.Errorf("Storage key %x mismatch: have %v, want none.", k, v)
222 }
223 }
224
225 if so0.suicided != so1.suicided {
226 t.Fatalf("suicided mismatch: have %v, want %v", so0.suicided, so1.suicided)
227 }
228 if so0.deleted != so1.deleted {
229 t.Fatalf("Deleted mismatch: have %v, want %v", so0.deleted, so1.deleted)
230 }
231}

Callers 1

TestSnapshot2Function · 0.85

Calls 6

CmpMethod · 0.80
CodeHashMethod · 0.80
AddressMethod · 0.65
NonceMethod · 0.65
EqualMethod · 0.65
BalanceMethod · 0.45

Tested by

no test coverage detected