From af8cb98b2bc7fb3a7a2e495723bd9e348c331ca2 Mon Sep 17 00:00:00 2001 From: Kenneth Koski Date: Wed, 12 Sep 2018 08:40:38 -0500 Subject: [PATCH] Turn test error messages into fatal errors It doesn't make sense in our case to continue in case of an error, and it just adds noise when a few lines later there's nil pointer dereference panic. Signed-off-by: Kenneth Koski --- .../tests/seth_blockhash_test.go | 15 ++++++--------- .../tests/seth_blocknum_test.go | 12 ++++++------ .../tests/seth_chaining_test.go | 6 +++--- .../tests/seth_intkey_test.go | 16 ++++++++-------- .../tests/seth_timestamp_test.go | 12 ++++++------ 5 files changed, 29 insertions(+), 32 deletions(-) diff --git a/integration/sawtooth_integration/tests/seth_blockhash_test.go b/integration/sawtooth_integration/tests/seth_blockhash_test.go index 9d21463dd..62c4a00f2 100644 --- a/integration/sawtooth_integration/tests/seth_blockhash_test.go +++ b/integration/sawtooth_integration/tests/seth_blockhash_test.go @@ -46,40 +46,37 @@ func TestBlockHash(t *testing.T) { // Create the EOA _, err := client.CreateExternalAccount(priv, nil, nil, 0, WAIT) if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err.Error()) } nonce += 1 // Create the Contract contractCreateResult, err := client.CreateContractAccount(priv, init, nil, nonce, 1000, WAIT) if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err.Error()) } nonce += 1 cmd, _ := hex.DecodeString(BLOCKHASH_1) contractCallResult, err := client.MessageCall(priv, contractCreateResult.Address, cmd, nonce, 1000, WAIT, false) - if err != nil { - t.Fatalf(err.Error()) - } blockHash := hex.EncodeToString(contractCallResult.ReturnValue) // Get expectedBlockHash of block 1 from BlockInfo blockInfoAddr, err := NewBlockInfoAddr(1); if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err.Error()) } resp, err := http.Get(fmt.Sprintf("%s/state/%s?wait=%v", client.Url, blockInfoAddr, WAIT)) if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err.Error()) } body, err := c.ParseRespBody(resp) if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err.Error()) } buf, err := base64.StdEncoding.DecodeString(body.Data.(string)) if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err.Error()) } blockInfo := &BlockInfo{} err = proto.Unmarshal(buf, blockInfo) diff --git a/integration/sawtooth_integration/tests/seth_blocknum_test.go b/integration/sawtooth_integration/tests/seth_blocknum_test.go index a07943ee8..7fe965d52 100644 --- a/integration/sawtooth_integration/tests/seth_blocknum_test.go +++ b/integration/sawtooth_integration/tests/seth_blocknum_test.go @@ -47,14 +47,14 @@ func TestBlockNumber(t *testing.T) { // Create the EOA _, err := client.CreateExternalAccount(priv, nil, nil, 0, WAIT) if err != nil { - t.Error(err.Error()) + t.Fatal(err.Error()) } nonce += 1 // Create the Contract contractCreateResult, err := client.CreateContractAccount(priv, init, nil, nonce, 1000, WAIT) if err != nil { - t.Error(err.Error()) + t.Fatal(err.Error()) } nonce += 1 @@ -65,19 +65,19 @@ func TestBlockNumber(t *testing.T) { // Get number of current block from BlockInfo blockInfoAddr, err := NewBlockInfoAddr(2); if err != nil { - t.Error(err.Error()) + t.Fatal(err.Error()) } resp, err := http.Get(fmt.Sprintf("%s/state/%s?wait=%v", client.Url, blockInfoAddr, WAIT)) if err != nil { - t.Error(err.Error()) + t.Fatal(err.Error()) } body, err := c.ParseRespBody(resp) if err != nil { - t.Error(err.Error()) + t.Fatal(err.Error()) } buf, err := base64.StdEncoding.DecodeString(body.Data.(string)) if err != nil { - t.Error(err.Error()) + t.Fatal(err.Error()) } blockInfo := &BlockInfo{} err = proto.Unmarshal(buf, blockInfo) diff --git a/integration/sawtooth_integration/tests/seth_chaining_test.go b/integration/sawtooth_integration/tests/seth_chaining_test.go index 10a54ea4e..79d1a146b 100644 --- a/integration/sawtooth_integration/tests/seth_chaining_test.go +++ b/integration/sawtooth_integration/tests/seth_chaining_test.go @@ -46,21 +46,21 @@ func TestContractChaining(t *testing.T) { // Create the EOA _, err := client.CreateExternalAccount(priv, nil, nil, 0, WAIT) if err != nil { - t.Error(err.Error()) + t.Fatal(err.Error()) } nonce += 1 // Create callee contract _, err = client.CreateContractAccount(priv, init_callee, nil, nonce, 1000, WAIT) if err != nil { - t.Error(err.Error()) + t.Fatal(err.Error()) } nonce += 1 // Create caller contract callerContractResult, err := client.CreateContractAccount(priv, init_caller, nil, nonce, 1000, WAIT) if err != nil { - t.Error(err.Error()) + t.Fatal(err.Error()) } nonce += 1 diff --git a/integration/sawtooth_integration/tests/seth_intkey_test.go b/integration/sawtooth_integration/tests/seth_intkey_test.go index 275c539c7..73421e31c 100644 --- a/integration/sawtooth_integration/tests/seth_intkey_test.go +++ b/integration/sawtooth_integration/tests/seth_intkey_test.go @@ -44,14 +44,14 @@ func TestIntkey(t *testing.T) { // Create the EOA _, err := client.CreateExternalAccount(priv, nil, nil, 0, WAIT) if err != nil { - t.Error(err.Error()) + t.Fatal(err.Error()) } nonce += 1 // Create the Contract createContractResult, err := client.CreateContractAccount(priv, init, nil, nonce, 1000, WAIT) if err != nil { - t.Error(err.Error()) + t.Fatal(err.Error()) } nonce += 1 @@ -60,7 +60,7 @@ func TestIntkey(t *testing.T) { callSetResult, err := client.MessageCall(priv, createContractResult.Address, cmd, nonce, 1000, 300, false) if callSetResult.Events[0].Attributes[0].Key != "address" { - t.Errorf("Event was not created") + t.Fatalf("Event was not created") } nonce += 1 @@ -74,18 +74,18 @@ func TestIntkey(t *testing.T) { cmd, _ := hex.DecodeString(c) _, err = client.MessageCall(priv, createContractResult.Address, cmd, nonce, 1000, WAIT, false) if err != nil { - t.Error(err.Error()) + t.Fatal(err.Error()) } nonce += 1 } entry, err := client.Get(createContractResult.Address) if err != nil { - t.Error(err.Error()) + t.Fatal(err.Error()) } if len(entry.Storage) != 2 { - t.Errorf("Storage should have 2 keys, but has %v", len(entry.Storage)) + t.Fatalf("Storage should have 2 keys, but has %v", len(entry.Storage)) } keys := []string{ @@ -100,10 +100,10 @@ func TestIntkey(t *testing.T) { key := hex.EncodeToString(pair.GetKey()) val := hex.EncodeToString(pair.GetValue()) if key != keys[i] { - t.Errorf("Unexpected key in storage: %v", key) + t.Fatalf("Unexpected key in storage: %v", key) } if val != vals[i] { - t.Errorf("Key has unexpected value: %v = %v", key, val) + t.Fatalf("Key has unexpected value: %v = %v", key, val) } } diff --git a/integration/sawtooth_integration/tests/seth_timestamp_test.go b/integration/sawtooth_integration/tests/seth_timestamp_test.go index 1f48b8116..9442a8b4f 100644 --- a/integration/sawtooth_integration/tests/seth_timestamp_test.go +++ b/integration/sawtooth_integration/tests/seth_timestamp_test.go @@ -47,14 +47,14 @@ func TestBlockNumber(t *testing.T) { // Create the EOA _, err := client.CreateExternalAccount(priv, nil, nil, 0, WAIT) if err != nil { - t.Error(err.Error()) + t.Fatal(err.Error()) } nonce += 1 // Create the Contract contractCreateResult, err := client.CreateContractAccount(priv, init, nil, nonce, 1000, WAIT) if err != nil { - t.Error(err.Error()) + t.Fatal(err.Error()) } nonce += 1 @@ -65,19 +65,19 @@ func TestBlockNumber(t *testing.T) { // Get number of current block from BlockInfo blockInfoAddr, err := NewBlockInfoAddr(2); if err != nil { - t.Error(err.Error()) + t.Fatal(err.Error()) } resp, err := http.Get(fmt.Sprintf("%s/state/%s?wait=%v", client.Url, blockInfoAddr, WAIT)) if err != nil { - t.Error(err.Error()) + t.Fatal(err.Error()) } body, err := c.ParseRespBody(resp) if err != nil { - t.Error(err.Error()) + t.Fatal(err.Error()) } buf, err := base64.StdEncoding.DecodeString(body.Data.(string)) if err != nil { - t.Error(err.Error()) + t.Fatal(err.Error()) } blockInfo := &BlockInfo{} err = proto.Unmarshal(buf, blockInfo)