Skip to content

Commit

Permalink
Merge pull request #489 from onflow/fxamacker/avoid-using-unexported-…
Browse files Browse the repository at this point in the history
…map-fields-in-tests

Avoid using unexported `OrderedMap` fields in tests
  • Loading branch information
fxamacker authored Jan 30, 2025
2 parents a8d5bb5 + 86312f9 commit a4d9406
Show file tree
Hide file tree
Showing 6 changed files with 282 additions and 265 deletions.
4 changes: 2 additions & 2 deletions array_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2830,7 +2830,7 @@ func TestArrayWithChildArrayMap(t *testing.T) {
require.NoError(t, err)
require.Nil(t, storable)

require.True(t, childMap.root.IsData())
require.True(t, IsMapRootDataSlab(childMap))

err = array.Append(childMap)
require.NoError(t, err)
Expand Down Expand Up @@ -2871,7 +2871,7 @@ func TestArrayWithChildArrayMap(t *testing.T) {
expectedChildMapValues[k] = v
}

require.False(t, childMap.root.IsData())
require.False(t, IsMapRootDataSlab(childMap))

err = array.Append(childMap)
require.NoError(t, err)
Expand Down
6 changes: 6 additions & 0 deletions export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,9 @@ var (
ArrayHasParentUpdater = (*Array).hasParentUpdater
GetArrayMutableElementIndexCount = (*Array).getMutableElementIndexCount
)

// Exported function of OrderedMap for testing.
var (
GetMapRootSlab = (*OrderedMap).rootSlab
GetMapDigesterBuilder = (*OrderedMap).getDigesterBuilder
)
8 changes: 8 additions & 0 deletions map.go
Original file line number Diff line number Diff line change
Expand Up @@ -4883,6 +4883,14 @@ func (m *OrderedMap) setParentUpdater(f parentUpdater) {
m.parentUpdater = f
}

func (m *OrderedMap) rootSlab() MapSlab {
return m.root
}

func (m *OrderedMap) getDigesterBuilder() DigesterBuilder {
return m.digesterBuilder
}

// setCallbackWithChild sets up callback function with child value (child)
// so parent map (m) can be notified when child value is modified.
func (m *OrderedMap) setCallbackWithChild(
Expand Down
Loading

0 comments on commit a4d9406

Please sign in to comment.