Skip to content
This repository has been archived by the owner on Jul 20, 2022. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
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 <knkski@bitwise.io>
  • Loading branch information
Kenneth Koski committed Sep 21, 2018
1 parent a9dfb62 commit af8cb98
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 32 deletions.
15 changes: 6 additions & 9 deletions integration/sawtooth_integration/tests/seth_blockhash_test.go
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions integration/sawtooth_integration/tests/seth_blocknum_test.go
Expand Up @@ -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

Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions integration/sawtooth_integration/tests/seth_chaining_test.go
Expand Up @@ -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

Expand Down
16 changes: 8 additions & 8 deletions integration/sawtooth_integration/tests/seth_intkey_test.go
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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{
Expand All @@ -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)
}
}

Expand Down
12 changes: 6 additions & 6 deletions integration/sawtooth_integration/tests/seth_timestamp_test.go
Expand Up @@ -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

Expand All @@ -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)
Expand Down

0 comments on commit af8cb98

Please sign in to comment.