github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/storage/badger/operation/prefix_test.go (about)

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