Handle legacy server list ping for handshake

This commit is contained in:
Geoff Bourne
2019-07-13 15:40:34 -05:00
parent 3699931af0
commit 4c99daafa3
4 changed files with 300 additions and 78 deletions
+36
View File
@@ -0,0 +1,36 @@
package mcproto
import (
"bytes"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
)
func TestReadVarInt(t *testing.T) {
tests := []struct {
Name string
Input []byte
Expected int
}{
{
Name: "Single byte",
Input: []byte{0xFA, 0x00},
Expected: 0x7A,
},
{
Name: "Two byte",
Input: []byte{0x81, 0x04},
Expected: 0x0201,
},
}
for _, tt := range tests {
t.Run(tt.Name, func(t *testing.T) {
result, err := ReadVarInt(bytes.NewBuffer(tt.Input))
require.NoError(t, err)
assert.Equal(t, tt.Expected, result)
})
}
}