You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

76 lines
1.5 KiB

package types
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestResultQuery(t *testing.T) {
orig := &ResponseQuery{
Code: CodeType_OK,
Index: 0,
Key: []byte("hello"),
Value: []byte("world"),
Height: 1,
}
res := orig.Result()
assert.False(t, res.IsErr())
orig = &ResponseQuery{
Code: CodeType_BadNonce,
Index: 0,
Key: []byte("hello"),
Value: []byte("world"),
Height: 1,
Log: "bad",
}
res = orig.Result()
assert.True(t, res.IsErr())
assert.Equal(t, "Error bad nonce (3): bad", res.Error())
}
func TestResponseDeliverTx(t *testing.T) {
res := ResponseDeliverTx{
Code: CodeType_OK,
Data: []byte("Victor Mancha"),
}
assert.False(t, res.IsErr())
res = ResponseDeliverTx{
Code: CodeType_InternalError,
Log: "bad",
}
assert.True(t, res.IsErr())
assert.Equal(t, "Internal error (1): bad", res.Error())
}
func TestResponseCheckTx(t *testing.T) {
res := ResponseCheckTx{
Code: CodeType_OK,
Data: []byte("Talos"),
}
assert.False(t, res.IsErr())
res = ResponseCheckTx{
Code: CodeType_InternalError,
Log: "bad",
}
assert.True(t, res.IsErr())
assert.Equal(t, "Internal error (1): bad", res.Error())
}
func TestResponseCommit(t *testing.T) {
res := ResponseCommit{
Code: CodeType_OK,
Data: []byte("Old Lace"),
}
assert.False(t, res.IsErr())
res = ResponseCommit{
Code: CodeType_Unauthorized,
Log: "bad",
}
assert.True(t, res.IsErr())
assert.Equal(t, "Unauthorized (4): bad", res.Error())
}