// FIXME: This is not checking the exact height of the tree but just making
//  sure there are as many children as we would have with a complete HAMT.
This is not checking the exact height of the tree but just making
sure there are as many children as we would have with a complete HAMT.
// FIXME : This is not checking the exact height of the tree but just making // sure there are as many children as we would have with a complete HAMT .
func TestCreateCompleteShard(t *testing.T) {
	oldHashFunc := internal.HAMTHashFunction
	defer func() { internal.HAMTHashFunction = oldHashFunc }()
	internal.HAMTHashFunction = idHash
	ds := mdtest.Mock()
	childsPerNode := 16
	treeHeight := 2
	node, err := CreateCompleteHAMT(ds, treeHeight, childsPerNode)
	assert.NoError(t, err)
	shard, err := hamt.NewHamtFromDag(ds, node)
	assert.NoError(t, err)
	links, err := shard.EnumLinks(context.Background())
	assert.NoError(t, err)
	childNodes := int(math.Pow(float64(childsPerNode), float64(treeHeight)))
	assert.Equal(t, childNodes, len(links))
}
func TestCreateCompleteShard ( t * testing . T ) { oldHashFunc := internal . HAMTHashFunction defer func ( ) { internal . HAMTHashFunction = oldHashFunc } ( ) internal . HAMTHashFunction = idHash ds := mdtest . Mock ( ) childsPerNode := 16 treeHeight := 2 node , err := CreateCompleteHAMT ( ds , treeHeight , childsPerNode ) assert . NoError ( t , err ) shard , err := hamt . NewHamtFromDag ( ds , node ) assert . NoError ( t , err ) links , err := shard . EnumLinks ( context . Background ( ) ) assert . NoError ( t , err ) childNodes := int ( math . Pow ( float64 ( childsPerNode ) , float64 ( treeHeight ) ) ) assert . Equal ( t , childNodes , len ( links ) ) }
This is not checking the exact height of the tree but just making
sure there are as many children as we would have with a complete HAMT.
This is not checking the exact height of the tree but just making sure there are as many children as we would have with a complete HAMT .