test: add regression tests for `*FromBytes` implementations when provided empty, wrong, or nil bytes
package hedera
import (
+ "encoding/base64"
"fmt"
"github.com/stretchr/testify/assert"
"strings"
@@ -265,3 +266,22 @@ func Test_TokenInfo_NoTokenID(t *testing.T) {
assert.Equal(t, fmt.Sprintf("exceptional precheck status INVALID_TOKEN_ID"), err.Error())
}
}
+
+func Test_TokenInfo_FromBytes_BadBytes(t *testing.T) {
+ bytes, err := base64.StdEncoding.DecodeString("tfhyY++/Q4BycortAgD4cmMKACB/")
+ assert.NoError(t, err)
+
+ _, err = TokenInfoFromBytes(bytes)
+ assert.NoError(t, err)
+}
+
+func Test_TokenInfo_FromBytes_Nil(t *testing.T) {
+ _, err := TokenRelationshipFromBytes(nil)
+ assert.Error(t, err)
+}
+
+func Test_TokenInfo_FromBytes_EmptyBytes(t *testing.T) {
+ _, err := TokenInfoFromBytes([]byte{})
+ assert.NoError(t, err)
+}
+
