@@ -11,13 +11,16 @@ func TestMemNode_Getters(t *testing.T) {
1111 right := NewNodePointer (& MemNode {})
1212 nodeId := NewNodeID (true , 5 , 10 )
1313
14+ testKey := []byte ("testkey" )
15+ testValue := []byte ("testvalue" )
16+ testHash := []byte ("testhash" )
1417 node := & MemNode {
1518 height : 3 ,
1619 version : 7 ,
1720 size : 42 ,
18- key : [] byte ( "testkey" ) ,
19- value : [] byte ( "testvalue" ) ,
20- hash : [] byte ( "testhash" ) ,
21+ key : testKey ,
22+ value : testValue ,
23+ hash : testHash ,
2124 left : left ,
2225 right : right ,
2326 nodeId : nodeId ,
@@ -29,16 +32,16 @@ func TestMemNode_Getters(t *testing.T) {
2932 require .Equal (t , int64 (42 ), node .Size ())
3033 require .Equal (t , left , node .Left ())
3134 require .Equal (t , right , node .Right ())
32- require .Equal (t , [] byte ( "testhash" ) , node .Hash ())
35+ require .Equal (t , testHash , node .Hash (). UnsafeBytes ())
3336 require .Equal (t , nodeId , node .ID ())
3437
3538 key , err := node .Key ()
3639 require .NoError (t , err )
37- require .Equal (t , [] byte ( "testkey" ) , key )
40+ require .Equal (t , testKey , key . UnsafeBytes () )
3841
3942 value , err := node .Value ()
4043 require .NoError (t , err )
41- require .Equal (t , [] byte ( "testvalue" ) , value )
44+ require .Equal (t , testValue , value . UnsafeBytes () )
4245}
4346
4447func TestMemNode_IsLeaf (t * testing.T ) {
@@ -98,12 +101,14 @@ func TestMemNode_String(t *testing.T) {
98101}
99102
100103func TestMemNode_MutateBranch (t * testing.T ) {
104+ key := []byte ("key" )
105+ origHash := []byte ("origHash" )
101106 original := & MemNode {
102107 height : 2 ,
103108 version : 5 ,
104109 size : 10 ,
105- key : [] byte ( " key" ) ,
106- hash : [] byte ( "oldhash" ) ,
110+ key : key ,
111+ hash : origHash ,
107112 left : NewNodePointer (& MemNode {}),
108113 right : NewNodePointer (& MemNode {}),
109114 }
@@ -113,13 +118,13 @@ func TestMemNode_MutateBranch(t *testing.T) {
113118
114119 // Version updated, hash cleared
115120 require .Equal (t , uint32 (12 ), mutated .Version ())
116- require .Nil (t , mutated .Hash ())
121+ require .Nil (t , mutated .Hash (). UnsafeBytes () )
117122
118123 // Other fields preserved
119124 require .Equal (t , original .Height (), mutated .Height ())
120125 require .Equal (t , original .Size (), mutated .Size ())
121- key , _ := mutated .Key ()
122- require .Equal (t , [] byte ( " key" ), key )
126+ key2 , _ := mutated .Key ()
127+ require .Equal (t , key , key2 . UnsafeBytes () )
123128 require .Equal (t , original .Left (), mutated .Left ())
124129 require .Equal (t , original .Right (), mutated .Right ())
125130
@@ -128,7 +133,7 @@ func TestMemNode_MutateBranch(t *testing.T) {
128133
129134 // Original unchanged
130135 require .Equal (t , uint32 (5 ), original .Version ())
131- require .Equal (t , [] byte ( "oldhash" ) , original .Hash ())
136+ require .Equal (t , origHash , original .Hash (). UnsafeBytes ())
132137}
133138
134139func TestMemNode_Get_Leaf (t * testing.T ) {
@@ -180,7 +185,7 @@ func TestMemNode_Get_Leaf(t *testing.T) {
180185 }
181186 val , idx , err := node .Get ([]byte (tt .searchKey ))
182187 require .NoError (t , err )
183- require .Equal (t , tt .wantValue , val )
188+ require .Equal (t , tt .wantValue , val . UnsafeBytes () )
184189 require .Equal (t , tt .wantIndex , idx )
185190 })
186191 }
@@ -254,7 +259,7 @@ func TestMemNode_Get_Branch(t *testing.T) {
254259 t .Run (tt .name , func (t * testing.T ) {
255260 val , idx , err := root .Get ([]byte (tt .searchKey ))
256261 require .NoError (t , err )
257- require .Equal (t , tt .wantValue , val )
262+ require .Equal (t , tt .wantValue , val . UnsafeBytes () )
258263 require .Equal (t , tt .wantIndex , idx )
259264 })
260265 }
@@ -312,7 +317,7 @@ func TestMemNode_Get_DeeperTree(t *testing.T) {
312317 t .Run (tt .searchKey , func (t * testing.T ) {
313318 val , idx , err := root .Get ([]byte (tt .searchKey ))
314319 require .NoError (t , err )
315- require .Equal (t , tt .wantValue , val )
320+ require .Equal (t , tt .wantValue , val . UnsafeBytes () )
316321 require .Equal (t , tt .wantIndex , idx )
317322 })
318323 }
0 commit comments