github.com/koko1123/flow-go-1@v0.29.6/storage/badger/operation/prefix_test.go (about) 1 // (c) 2019 Dapper Labs - ALL RIGHTS RESERVED 2 3 package operation 4 5 import ( 6 "testing" 7 8 "github.com/stretchr/testify/assert" 9 10 "github.com/koko1123/flow-go-1/model/flow" 11 ) 12 13 func TestMakePrefix(t *testing.T) { 14 15 code := byte(0x01) 16 17 u := uint64(1337) 18 expected := []byte{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x39} 19 actual := makePrefix(code, u) 20 21 assert.Equal(t, expected, actual) 22 23 r := flow.Role(2) 24 expected = []byte{0x01, 0x02} 25 actual = makePrefix(code, r) 26 27 assert.Equal(t, expected, actual) 28 29 id := flow.Identifier{0x05, 0x06, 0x07} 30 expected = []byte{0x01, 31 0x05, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 32 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 33 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 34 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 35 } 36 actual = makePrefix(code, id) 37 38 assert.Equal(t, expected, actual) 39 }