Skip to content

Commit f088c65

Browse files
fjlkaralabe
authored andcommitted
all: replace t.Log(); t.FailNow() with t.Fatal() (#19849)
1 parent 9466b9e commit f088c65

File tree

4 files changed

+56
-116
lines changed

4 files changed

+56
-116
lines changed

accounts/abi/abi_test.go

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"bytes"
2121
"encoding/hex"
2222
"fmt"
23-
"log"
2423
"math/big"
2524
"reflect"
2625
"strings"
@@ -102,8 +101,7 @@ func TestReader(t *testing.T) {
102101
func TestTestNumbers(t *testing.T) {
103102
abi, err := JSON(strings.NewReader(jsondata2))
104103
if err != nil {
105-
t.Error(err)
106-
t.FailNow()
104+
t.Fatal(err)
107105
}
108106

109107
if _, err := abi.Pack("balance"); err != nil {
@@ -140,8 +138,7 @@ func TestTestNumbers(t *testing.T) {
140138
func TestTestString(t *testing.T) {
141139
abi, err := JSON(strings.NewReader(jsondata2))
142140
if err != nil {
143-
t.Error(err)
144-
t.FailNow()
141+
t.Fatal(err)
145142
}
146143

147144
if _, err := abi.Pack("string", "hello world"); err != nil {
@@ -152,8 +149,7 @@ func TestTestString(t *testing.T) {
152149
func TestTestBool(t *testing.T) {
153150
abi, err := JSON(strings.NewReader(jsondata2))
154151
if err != nil {
155-
t.Error(err)
156-
t.FailNow()
152+
t.Fatal(err)
157153
}
158154

159155
if _, err := abi.Pack("bool", true); err != nil {
@@ -164,8 +160,7 @@ func TestTestBool(t *testing.T) {
164160
func TestTestSlice(t *testing.T) {
165161
abi, err := JSON(strings.NewReader(jsondata2))
166162
if err != nil {
167-
t.Error(err)
168-
t.FailNow()
163+
t.Fatal(err)
169164
}
170165

171166
slice := make([]uint64, 2)
@@ -221,8 +216,7 @@ func TestMethodSignature(t *testing.T) {
221216
func TestMultiPack(t *testing.T) {
222217
abi, err := JSON(strings.NewReader(jsondata2))
223218
if err != nil {
224-
t.Error(err)
225-
t.FailNow()
219+
t.Fatal(err)
226220
}
227221

228222
sig := crypto.Keccak256([]byte("bar(uint32,uint16)"))[:4]
@@ -232,10 +226,8 @@ func TestMultiPack(t *testing.T) {
232226

233227
packed, err := abi.Pack("bar", uint32(10), uint16(11))
234228
if err != nil {
235-
t.Error(err)
236-
t.FailNow()
229+
t.Fatal(err)
237230
}
238-
239231
if !bytes.Equal(packed, sig) {
240232
t.Errorf("expected %x got %x", sig, packed)
241233
}
@@ -246,11 +238,11 @@ func ExampleJSON() {
246238

247239
abi, err := JSON(strings.NewReader(definition))
248240
if err != nil {
249-
log.Fatalln(err)
241+
panic(err)
250242
}
251243
out, err := abi.Pack("isBar", common.HexToAddress("01"))
252244
if err != nil {
253-
log.Fatalln(err)
245+
panic(err)
254246
}
255247

256248
fmt.Printf("%x\n", out)

core/types/transaction_test.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,15 @@ func TestRecipientEmpty(t *testing.T) {
8989
_, addr := defaultTestKey()
9090
tx, err := decodeTx(common.Hex2Bytes("f8498080808080011ca09b16de9d5bdee2cf56c28d16275a4da68cd30273e2525f3959f5d62557489921a0372ebd8fb3345f7db7b5a86d42e24d36e983e259b0664ceb8c227ec9af572f3d"))
9191
if err != nil {
92-
t.Error(err)
93-
t.FailNow()
92+
t.Fatal(err)
9493
}
9594

9695
from, err := Sender(HomesteadSigner{}, tx)
9796
if err != nil {
98-
t.Error(err)
99-
t.FailNow()
97+
t.Fatal(err)
10098
}
10199
if addr != from {
102-
t.Error("derived address doesn't match")
100+
t.Fatal("derived address doesn't match")
103101
}
104102
}
105103

@@ -108,18 +106,15 @@ func TestRecipientNormal(t *testing.T) {
108106

109107
tx, err := decodeTx(common.Hex2Bytes("f85d80808094000000000000000000000000000000000000000080011ca0527c0d8f5c63f7b9f41324a7c8a563ee1190bcbf0dac8ab446291bdbf32f5c79a0552c4ef0a09a04395074dab9ed34d3fbfb843c2f2546cc30fe89ec143ca94ca6"))
110108
if err != nil {
111-
t.Error(err)
112-
t.FailNow()
109+
t.Fatal(err)
113110
}
114111

115112
from, err := Sender(HomesteadSigner{}, tx)
116113
if err != nil {
117-
t.Error(err)
118-
t.FailNow()
114+
t.Fatal(err)
119115
}
120-
121116
if addr != from {
122-
t.Error("derived address doesn't match")
117+
t.Fatal("derived address doesn't match")
123118
}
124119
}
125120

0 commit comments

Comments
 (0)