cmd/devp2p: better testcase failure output for ethtests (#22482)

This commit is contained in:
Martin Holst Swende 2021-03-13 21:33:30 +01:00 committed by GitHub
parent 6387c520b7
commit 3f74c8e0e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -273,14 +273,15 @@ loop:
for { for {
switch msg := c.Read().(type) { switch msg := c.Read().(type) {
case *Status: case *Status:
if msg.Head != chain.blocks[chain.Len()-1].Hash() { if have, want := msg.Head, chain.blocks[chain.Len()-1].Hash(); have != want {
t.Fatalf("wrong head block in status: %s", msg.Head.String()) t.Fatalf("wrong head block in status, want: %#x (block %d) have %#x",
want, chain.blocks[chain.Len()-1].NumberU64(), have)
} }
if msg.TD.Cmp(chain.TD(chain.Len())) != 0 { if have, want := msg.TD.Cmp(chain.TD(chain.Len())), 0; have != want {
t.Fatalf("wrong TD in status: %v", msg.TD) t.Fatalf("wrong TD in status: have %v want %v", have, want)
} }
if !reflect.DeepEqual(msg.ForkID, chain.ForkID()) { if have, want := msg.ForkID, chain.ForkID(); !reflect.DeepEqual(have, want) {
t.Fatalf("wrong fork ID in status: %v", msg.ForkID) t.Fatalf("wrong fork ID in status: have %v, want %v", have, want)
} }
message = msg message = msg
break loop break loop