pkg/vm/stack: make some use of testReadInt64()

GolangCI complains:
  testReadInt64 is unused (from deadcode)

Fix it to always provide correctly-sized buffer for the binary.Read().
This commit is contained in:
Roman Khimov 2019-08-12 17:53:19 +03:00
parent 6be27ad4b0
commit d6c3f74e3c
2 changed files with 7 additions and 1 deletions

View file

@ -64,6 +64,8 @@ func TestByteArrConversion(t *testing.T) {
ba, err := a.ByteArray()
assert.Nil(t, err)
assert.Equal(t, num, testReadInt64(ba.val))
have, err := ba.Integer()
assert.Nil(t, err)

View file

@ -38,7 +38,11 @@ func testMakeStackInt(t *testing.T, num int64) *Int {
func testReadInt64(data []byte) int64 {
var ret int64
buf := bytes.NewBuffer(data)
var arr [8]byte
// expands or shrinks data automatically
copy(arr[:], data)
buf := bytes.NewBuffer(arr[:])
binary.Read(buf, binary.LittleEndian, &ret)
return ret
}