Skip to content

Commit bf879ef

Browse files
author
Gustav Simonsson
committed
core/state: test formatting adhering to Go convention
1 parent 004ed78 commit bf879ef

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

core/state/state_test.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func TestSnapshot2(t *testing.T) {
170170
so0Restored := state.GetStateObject(stateobjaddr0)
171171
so1Restored := state.GetStateObject(stateobjaddr1)
172172
// non-deleted is equal (restored)
173-
compareStateObjects(so0, so0Restored, t)
173+
compareStateObjects(so0Restored, so0, t)
174174
// deleted should be nil, both before and after restore of state copy
175175
if so1Restored != nil {
176176
t.Fatalf("deleted object not nil after restoring snapshot")
@@ -179,45 +179,45 @@ func TestSnapshot2(t *testing.T) {
179179

180180
func compareStateObjects(so0, so1 *StateObject, t *testing.T) {
181181
if so0.address != so1.address {
182-
t.Fatalf("\nexpected %v\ngot %v", so0.address, so1.address)
182+
t.Fatalf("Address mismatch: have %v, want %v", so0.address, so1.address)
183183
}
184184
if so0.balance.Cmp(so1.balance) != 0 {
185-
t.Fatalf("\nexpected %v\ngot %v", so0.balance, so1.balance)
185+
t.Fatalf("Balance mismatch: have %v, want %v", so0.balance, so1.balance)
186186
}
187187
if so0.nonce != so1.nonce {
188-
t.Fatalf("\nexpected %v\ngot %v", so0.nonce, so1.nonce)
188+
t.Fatalf("Nonce mismatch: have %v, want %v", so0.nonce, so1.nonce)
189189
}
190190
if !bytes.Equal(so0.codeHash, so1.codeHash) {
191-
t.Fatalf("\nexpected %v\ngot %v", so0.codeHash, so1.codeHash)
191+
t.Fatalf("CodeHash mismatch: have %v, want %v", so0.codeHash, so1.codeHash)
192192
}
193193
if !bytes.Equal(so0.code, so1.code) {
194-
t.Fatalf("\nexpected %v\ngot %v", so0.code, so1.code)
194+
t.Fatalf("Code mismatch: have %v, want %v", so0.code, so1.code)
195195
}
196196
if !bytes.Equal(so0.initCode, so1.initCode) {
197-
t.Fatalf("\nexpected %v\ngot %v", so0.initCode, so1.initCode)
197+
t.Fatalf("InitCode mismatch: have %v, want %v", so0.initCode, so1.initCode)
198198
}
199199

200-
for k, v := range so0.storage {
201-
if so1.storage[k] != v {
202-
t.Fatalf("\nstorage key %s:\nexpected %v\ngot %v", k, v, so1.storage[k])
203-
}
204-
}
205200
for k, v := range so1.storage {
206201
if so0.storage[k] != v {
207-
t.Fatalf("\nunexpected k,v : %v, %v", k, v)
202+
t.Fatalf("Storage key %s mismatch: have %v, want %v", k, so0.storage[k], v)
203+
}
204+
}
205+
for k, v := range so0.storage {
206+
if so1.storage[k] != v {
207+
t.Fatalf("Storage key %s mismatch: have %v, want none.", k, v)
208208
}
209209
}
210210

211211
if so0.gasPool.Cmp(so1.gasPool) != 0 {
212-
t.Fatalf("\nexpected %v\ngot %v", so0.gasPool, so1.gasPool)
212+
t.Fatalf("GasPool mismatch: have %v, want %v", so0.gasPool, so1.gasPool)
213213
}
214214
if so0.remove != so1.remove {
215-
t.Fatalf("\nexpected %v\ngot %v", so0.remove, so1.remove)
215+
t.Fatalf("Remove mismatch: have %v, want %v", so0.remove, so1.remove)
216216
}
217217
if so0.deleted != so1.deleted {
218-
t.Fatalf("\nexpected %v\ngot %v", so0.deleted, so1.deleted)
218+
t.Fatalf("Deleted mismatch: have %v, want %v", so0.deleted, so1.deleted)
219219
}
220220
if so0.dirty != so1.dirty {
221-
t.Fatalf("\nexpected %v\ngot %v", so0.dirty, so1.dirty)
221+
t.Fatalf("Dirty mismatch: have %v, want %v", so0.dirty, so1.dirty)
222222
}
223223
}

0 commit comments

Comments
 (0)