github.com/nspcc-dev/neo-go@v0.105.2-0.20240517133400-6be757af3eba/pkg/encoding/bigint/bigint_test.go (about)

     1  package bigint
     2  
     3  import (
     4  	"math"
     5  	"math/big"
     6  	"testing"
     7  
     8  	"github.com/nspcc-dev/neo-go/pkg/util/slice"
     9  	"github.com/stretchr/testify/assert"
    10  	"github.com/stretchr/testify/require"
    11  )
    12  
    13  // testCases were generated using C# node
    14  // https://dotnetfiddle.net/trQ4xt
    15  var testCases = []struct {
    16  	number int64
    17  	buf    []byte
    18  }{
    19  	{0, []byte{}},
    20  	{1, []byte{1}},
    21  	{-1, []byte{255}},
    22  	{2, []byte{2}},
    23  	{-2, []byte{254}},
    24  	{127, []byte{127}},
    25  	{-127, []byte{129}},
    26  	{128, []byte{128, 0}},
    27  	{-128, []byte{128}},
    28  	{129, []byte{129, 0}},
    29  	{-129, []byte{127, 255}},
    30  	{255, []byte{255, 0}},
    31  	{-255, []byte{1, 255}},
    32  	{256, []byte{0, 1}},
    33  	{-256, []byte{0, 255}},
    34  	{123456789, []byte{21, 205, 91, 7}},
    35  	{-123456789, []byte{235, 50, 164, 248}},
    36  	{-6777216, []byte{128, 150, 152}}, // tx c8ba2ce29e07447639b9b658db3930c4cce617652d325e78b768ee9d4dbd72b8
    37  	{6777216, []byte{128, 105, 103}},
    38  
    39  	{32639, []byte{127, 127}},
    40  	{-32641, []byte{127, 128}},
    41  	{8355711, []byte{127, 127, 127}},
    42  	{-8355969, []byte{127, 127, 128}},
    43  	{2139062143, []byte{127, 127, 127, 127}},
    44  	{-2139127937, []byte{127, 127, 127, 128}},
    45  	{547599908735, []byte{127, 127, 127, 127, 127}},
    46  	{-547616751745, []byte{127, 127, 127, 127, 128}},
    47  	{140185576636287, []byte{127, 127, 127, 127, 127, 127}},
    48  	{-140189888446593, []byte{127, 127, 127, 127, 127, 128}},
    49  	{35887507618889599, []byte{127, 127, 127, 127, 127, 127, 127}},
    50  	{-35888611442327681, []byte{127, 127, 127, 127, 127, 127, 128}},
    51  	{9187201950435737471, []byte{127, 127, 127, 127, 127, 127, 127, 127}},
    52  	{-9187484529235886209, []byte{127, 127, 127, 127, 127, 127, 127, 128}},
    53  
    54  	// https://github.com/dotnet/runtime/blob/master/src/libraries/System.Runtime.Numerics/tests/BigInteger/ToByteArray.cs#L14
    55  	// {0, []byte{0x00}}, commented because this test check default `BigInteger` serialization, not NEO3 serialization.
    56  	{3, []byte{0x03}},
    57  	{128, []byte{0x80, 0x00}},
    58  	{200, []byte{0xc8, 0x00}},
    59  	{256, []byte{0x00, 0x01}},
    60  	{2005, []byte{0xd5, 0x07}},
    61  	{10197, []byte{0xd5, 0x27}},
    62  	{33023, []byte{0xff, 0x80, 0x00}},
    63  	{2368349, []byte{0x5d, 0x23, 0x24}},
    64  	{10756957, []byte{0x5d, 0x23, 0xa4, 0x00}},
    65  	{193100307, []byte{0x13, 0x7a, 0x82, 0x0b}},
    66  	{1266842131, []byte{0x13, 0x7a, 0x82, 0x4b}},
    67  	{math.MaxInt32, []byte{0xff, 0xff, 0xff, 0x7f}},
    68  	{-1, []byte{0xff}},
    69  	{-128, []byte{0x80}},
    70  	{-172, []byte{0x54, 0xff}},
    71  	{-23439, []byte{0x71, 0xa4}},
    72  	{-51301, []byte{0x9b, 0x37, 0xff}},
    73  	{-126341, []byte{0x7b, 0x12, 0xfe}},
    74  	{-13194515, []byte{0xed, 0xaa, 0x36, 0xff}},
    75  	{-2068145902, []byte{0x12, 0x99, 0xba, 0x84}},
    76  	{math.MinInt32, []byte{0x00, 0x00, 0x00, 0x80}},
    77  
    78  	// https://github.com/dotnet/runtime/blob/master/src/libraries/System.Runtime.Numerics/tests/BigInteger/ToByteArray.cs#L53
    79  	{0x100112233, []byte{0x33, 0x22, 0x11, 0x00, 0x01}},
    80  	{0x300112233, []byte{0x33, 0x22, 0x11, 0x00, 0x03}},
    81  	{0x8000112233, []byte{0x33, 0x22, 0x11, 0x00, 0x80, 0x00}},
    82  	{0x3cd00112233, []byte{0x33, 0x22, 0x11, 0x00, 0xcd, 0x03}},
    83  	{0xf92100112233, []byte{0x33, 0x22, 0x11, 0x00, 0x21, 0xf9, 0x00}},
    84  	{0x749aa00112233, []byte{0x33, 0x22, 0x11, 0x00, 0xaa, 0x49, 0x07}},
    85  	{0x80112200112233, []byte{0x33, 0x22, 0x11, 0x00, 0x22, 0x11, 0x80, 0x00}},
    86  	{0x7654321000112233, []byte{0x33, 0x22, 0x11, 0x00, 0x10, 0x32, 0x54, 0x76}},
    87  	{math.MaxInt64, []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f}},
    88  	{-0x100112233, []byte{0xcd, 0xdd, 0xee, 0xff, 0xfe}},
    89  	{-0x8000112233, []byte{0xcd, 0xdd, 0xee, 0xff, 0x7f, 0xff}},
    90  	{-0x3cd00112233, []byte{0xcd, 0xdd, 0xee, 0xff, 0x32, 0xfc}},
    91  	{-0xf92100112233, []byte{0xcd, 0xdd, 0xee, 0xff, 0xde, 0x06, 0xff}},
    92  	{-0x749aa00112233, []byte{0xcd, 0xdd, 0xee, 0xff, 0x55, 0xb6, 0xf8}},
    93  	{-0x80112200112233, []byte{0xcd, 0xdd, 0xee, 0xff, 0xdd, 0xee, 0x7f, 0xff}},
    94  	{-0x7654321000112233, []byte{0xcd, 0xdd, 0xee, 0xff, 0xef, 0xcd, 0xab, 0x89}},
    95  	{math.MinInt64, []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80}},
    96  	{-0x100000000, []byte{0x00, 0x00, 0x00, 0x00, 0xff}},
    97  	{-0x300000000, []byte{0x00, 0x00, 0x00, 0x00, 0xfd}},
    98  	{-0x8000000000, []byte{0x00, 0x00, 0x00, 0x00, 0x80}},
    99  	{-0xfe00000000, []byte{0x00, 0x00, 0x00, 0x00, 0x02, 0xff}},
   100  	{-0xff00000000, []byte{0x00, 0x00, 0x00, 0x00, 0x01, 0xff}},
   101  	{-0xfeff00000000, []byte{0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0xff}},
   102  	{-0xffff00000000, []byte{0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0xff}},
   103  	{-0xfeffff00000000, []byte{0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0xff}},
   104  	{-0xffffff00000000, []byte{0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0xff}},
   105  }
   106  
   107  func TestIntToBytes(t *testing.T) {
   108  	for _, tc := range testCases {
   109  		num := big.NewInt(tc.number)
   110  		var numC = *num // See #2864.
   111  		buf := ToBytes(num)
   112  		assert.Equal(t, tc.buf, buf, "error while converting %d", tc.number)
   113  		_ = numC.Neg(&numC)
   114  		_ = ToBytes(&numC)
   115  		_ = numC.Neg(&numC)
   116  		assert.Equal(t, num, &numC, "number mismatch after converting %d", tc.number)
   117  	}
   118  }
   119  
   120  func TestBytesToInt(t *testing.T) {
   121  	for _, tc := range testCases {
   122  		num := FromBytes(tc.buf)
   123  		assert.Equal(t, tc.number, num.Int64(), "error while converting %d", tc.number)
   124  	}
   125  
   126  	t.Run("empty array", func(t *testing.T) {
   127  		require.EqualValues(t, 0, FromBytes([]byte{}).Int64())
   128  	})
   129  }
   130  
   131  var unsignedCases = []struct {
   132  	number int64
   133  	buf    []byte
   134  }{
   135  	{0xff00000000, []byte{0x00, 0x00, 0x00, 0x00, 0xff}},
   136  	{0xfd00000000, []byte{0x00, 0x00, 0x00, 0x00, 0xfd}},
   137  	{0x8000000000, []byte{0x00, 0x00, 0x00, 0x00, 0x80}},
   138  	{0xff0200000000, []byte{0x00, 0x00, 0x00, 0x00, 0x02, 0xff}},
   139  	{0xff0100000000, []byte{0x00, 0x00, 0x00, 0x00, 0x01, 0xff}},
   140  	{0xff0100000000, []byte{0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x00}},
   141  }
   142  
   143  func TestBytesToUnsigned(t *testing.T) {
   144  	for _, tc := range testCases {
   145  		if tc.number > 0 {
   146  			num := FromBytesUnsigned(tc.buf)
   147  			assert.Equal(t, tc.number, num.Int64(), "expected %x, got %x", tc.number, num.Int64())
   148  		}
   149  	}
   150  	for _, tc := range unsignedCases {
   151  		num := FromBytesUnsigned(tc.buf)
   152  		assert.Equal(t, tc.number, num.Int64(), "expected %x, got %x", tc.number, num.Int64())
   153  	}
   154  }
   155  
   156  func TestEquivalentRepresentations(t *testing.T) {
   157  	for _, tc := range testCases {
   158  		buf := tc.buf
   159  		if tc.number >= 0 {
   160  			buf = append(buf, 0, 0, 0)
   161  		} else {
   162  			buf = append(buf, 0xFF, 0xFF, 0xFF)
   163  		}
   164  
   165  		num := FromBytes(buf)
   166  		assert.Equal(t, tc.number, num.Int64(), "error while converting %d", tc.number)
   167  	}
   168  }
   169  
   170  var stringCases = []struct {
   171  	numStr string
   172  	buf    []byte
   173  }{
   174  	{"-1256271214286163627607479687759920896", []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 255}},
   175  	{"168884912246183068104079824028124185087", []byte{255, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 127}},
   176  	{"1402184777283668118200134432800768511", []byte{255, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1}},
   177  	{"-43536131589161850832973096317989605473920", []byte{128, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 128}},
   178  	{"43235871975677457350187428577111288447360", []byte{128, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 127}},
   179  }
   180  
   181  // this cases are from stdlib
   182  // https://github.com/dotnet/runtime/blob/master/src/libraries/System.Runtime.Numerics/tests/BigInteger/ToByteArray.cs#L96
   183  // note that they are in big-endian.
   184  var stdlibCases = []struct {
   185  	numStr string
   186  	buf    []byte
   187  }{
   188  	{"0", []byte{0}},
   189  	{"127", []byte{0x7F}},
   190  	{"128", []byte{0x00, 0x80}},
   191  	{"33022", []byte{0x00, 0x80, 0xFE}},
   192  	{"-32514", []byte{0x80, 0xFE}},
   193  	{"-18374686475376656384", []byte{0xff, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00}},
   194  	{"-18446744069414584320", []byte{0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00}},
   195  	{"12364093636075302621581796971036731159910277399901099375861080574506898189967563102391591201943540153492149033597384108294298661111799425262742266671957323486506857011293831406641316917374615487590434666756862524718179898130435474398176187353530443750986128762955255137790631223519091107256083370837751230886741470719554141609004126665185940207631783192780186624919167901565253877397154522582982120840364212333366972597473045167409184762879376102731157263235904816835054250885637739932914015117504485702897712016943555929710070193511128651378003670520306509417025958556935067307123832592173743652726898616663215056178200135054604939862749863002480827458494339065850786495122398411385446068167146399066035389699059499954747263948595492570959736940353095030589033792026029085438901525807032848103038290802923997216273712349905230080849822000411239032166420681788646737098078876258256753058713515144604794792139863186822520361187685685356628044518258989638970651859178568755065879235553215218267011024902142765549091793970027321040036512883269922219608216030987714165823965404563131018846411947569009598716649463301689241563037584803938711917477764863093448004918315253652379776337794243677630540042379049027", []byte{0x00, 0xf0, 0x1d, 0x7b, 0xa2, 0xfd, 0x50, 0xf9, 0x50, 0x07, 0xce, 0x2a, 0xdf, 0xfb, 0x75, 0x70, 0x49, 0x5e, 0x5d, 0xf7, 0x1b, 0x0a, 0x76, 0x1f, 0xe7, 0xe3, 0xc7, 0x0a, 0xc7, 0xee, 0xca, 0x4e, 0xa2, 0xe6, 0xae, 0xe8, 0x1a, 0x2c, 0x3b, 0xa9, 0x12, 0x77, 0xb1, 0x47, 0x3c, 0xb5, 0xab, 0x32, 0x26, 0x18, 0x0d, 0x43, 0x51, 0x6b, 0x11, 0x0c, 0x45, 0xed, 0x52, 0x7d, 0xce, 0xe8, 0x75, 0x6c, 0xe1, 0xda, 0xaf, 0x42, 0x1c, 0xc6, 0x21, 0x23, 0x1f, 0x5d, 0x2d, 0x48, 0xf8, 0x20, 0x67, 0x2f, 0x49, 0x3d, 0x3e, 0x5d, 0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xaa, 0x1a, 0x90, 0xbe, 0xf8, 0x91, 0x50, 0x30, 0x6d, 0x73, 0x49, 0x3c, 0xab, 0xa4, 0xaf, 0x13, 0xa8, 0xdd, 0x0a, 0xf5, 0xc3, 0x34, 0x98, 0xb4, 0x7f, 0x0b, 0xb4, 0x63, 0x0f, 0xe3, 0x6e, 0xcc, 0xf8, 0x1d, 0xea, 0x34, 0x71, 0x8b, 0x06, 0xa5, 0x4f, 0x81, 0x12, 0xa9, 0xfd, 0xb8, 0x43}},
   196  	{"-1500566381192798663042470094195709329888702572609999105286667163606153967917290138712408909178830809119008530236180974166477902167438722120032328817587204550920260039698718901932896233377293832747667996098291476468951412311792579258943277768740116090186686963715856483147820131067091322876669577393210366426487028489206389247040659375214497672166049911500383423054774768058254673393263777607084960848658501529675225559011863409579602879830226289200557853195239635009395081629845517655774307827048680743808664945667425540772434721298573889660136104342949269877806888346513652384111162522895043239369803590295673472600852282901495791087130835483730406094888840219829189061112151151001898468218215751327382511813082884657126285166508024920536549363279290734920537316417286759974845704859198588552892947264856714040130408613412473996518038227113385600353365608575770837750435553392852567153310861059766627383200108369176626042676222592985818614861742325706568951932845447397512345181981733524874445871904571909006536844113768514813826258460666950996534336842871477679076553532049073323784011247842133811527684859166963235747571306708361946012941167234981369225227878132777327321706825860067928644566542309248", []byte{0xe2, 0xdb, 0xc3, 0xee, 0xdc, 0xd0, 0xa4, 0xdc, 0x41, 0xec, 0xf7, 0xf3, 0x53, 0x2f, 0xd9, 0x5e, 0xe5, 0xbf, 0x5e, 0xea, 0x84, 0xde, 0x00, 0x79, 0x48, 0xc6, 0xf4, 0xd0, 0x29, 0xd9, 0x41, 0xb3, 0xc1, 0x31, 0xe0, 0x18, 0x42, 0xa5, 0x76, 0x88, 0x95, 0x60, 0xe8, 0x55, 0x51, 0x98, 0x01, 0xdb, 0x58, 0x0f, 0x76, 0xe5, 0x23, 0xb3, 0xa3, 0x8b, 0xb6, 0x8b, 0x66, 0x30, 0xd2, 0xb4, 0x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0xfb, 0x11, 0x53, 0x7c, 0xeb, 0xd4, 0xd2, 0x16, 0xaf, 0x20, 0x5e, 0x42, 0x09, 0xea, 0x92, 0x0b, 0xab, 0x94, 0xaa, 0xaf, 0x23, 0xda, 0xda, 0xe3, 0x40, 0xc1, 0x5a, 0xab, 0xc2, 0xdd, 0x8d, 0x76, 0x62, 0xb3, 0xd4, 0x13, 0xac, 0x0c, 0x06, 0xa9, 0x98, 0x27, 0xa8, 0x34, 0x94, 0xd6, 0x85, 0x99, 0x24, 0x7e, 0x8a, 0xf1, 0xf8, 0x6d, 0xef, 0x66, 0xf0, 0xe6, 0xc9, 0x2c, 0x4d, 0x1f, 0x3e, 0xfa, 0x28, 0x80}},
   197  }
   198  
   199  func TestVeryBigInts(t *testing.T) {
   200  	for _, tc := range stringCases {
   201  		num, ok := new(big.Int).SetString(tc.numStr, 10)
   202  		assert.True(t, ok)
   203  
   204  		result := FromBytes(tc.buf)
   205  		assert.Equal(t, num, result, "error while converting %s from bytes", tc.numStr)
   206  		assert.Equal(t, tc.buf, ToBytes(result), "error while converting %s to bytes", tc.numStr)
   207  	}
   208  
   209  	for _, tc := range stdlibCases {
   210  		num, ok := new(big.Int).SetString(tc.numStr, 10)
   211  		assert.True(t, ok)
   212  
   213  		result := FromBytes(slice.CopyReverse(tc.buf))
   214  		assert.Equal(t, num, result, "error while converting %s from bytes", tc.numStr)
   215  	}
   216  }