Fix zero handling in refmt transfrom
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
parent
f9dde3d10a
commit
0add5bbb8d
@ -133,6 +133,10 @@ func (bi *BigInt) cborBytes() []byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func fromCborBytes(buf []byte) (BigInt, error) {
|
func fromCborBytes(buf []byte) (BigInt, error) {
|
||||||
|
if len(buf) == 0 {
|
||||||
|
return NewInt(0), nil
|
||||||
|
}
|
||||||
|
|
||||||
var negative bool
|
var negative bool
|
||||||
switch buf[0] {
|
switch buf[0] {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
|
|
||||||
func TestBigIntSerializationRoundTrip(t *testing.T) {
|
func TestBigIntSerializationRoundTrip(t *testing.T) {
|
||||||
testValues := []string{
|
testValues := []string{
|
||||||
"0", "1", "10", "9999", "12345678901234567891234567890123456789012345678901234567890",
|
"0", "1", "10", "-10", "9999", "12345678901234567891234567890123456789012345678901234567890",
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, v := range testValues {
|
for _, v := range testValues {
|
||||||
@ -29,5 +29,6 @@ func TestBigIntSerializationRoundTrip(t *testing.T) {
|
|||||||
if BigCmp(out, bi) != 0 {
|
if BigCmp(out, bi) != 0 {
|
||||||
t.Fatal("failed to round trip BigInt through cbor")
|
t.Fatal("failed to round trip BigInt through cbor")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user