github.com/koko1123/flow-go-1@v0.29.6/module/updatable_configs/sealing_configs_test.go (about) 1 package updatable_configs_test 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/require" 7 8 "github.com/koko1123/flow-go-1/model/flow" 9 "github.com/koko1123/flow-go-1/module/updatable_configs" 10 ) 11 12 func TestRequiredApprovalsForSealingContruction(t *testing.T) { 13 14 instance, err := updatable_configs.NewSealingConfigs( 15 flow.DefaultRequiredApprovalsForSealConstruction, 16 flow.DefaultRequiredApprovalsForSealValidation, 17 flow.DefaultChunkAssignmentAlpha, 18 flow.DefaultEmergencySealingActive, 19 ) 20 require.NoError(t, err) 21 22 // should get the default value 23 val := instance.RequireApprovalsForSealConstructionDynamicValue() 24 require.Equal(t, uint(1), val) 25 26 err = instance.SetRequiredApprovalsForSealingConstruction(0) 27 require.NoError(t, err) 28 29 // value should be updated by SetRequiredApprovalsForSealingConstruction 30 newVal := instance.RequireApprovalsForSealConstructionDynamicValue() 31 require.Equal(t, uint(0), newVal) 32 33 // test updating multiple times 34 for i := 1; i <= flow.DefaultChunkAssignmentAlpha; i++ { 35 err := instance.SetRequiredApprovalsForSealingConstruction(uint(i)) 36 require.NoError(t, err, err) 37 require.Equal(t, uint(i), instance.RequireApprovalsForSealConstructionDynamicValue()) 38 } 39 40 // test an invalid input 41 err = instance.SetRequiredApprovalsForSealingConstruction(flow.DefaultChunkAssignmentAlpha + 1) 42 require.Error(t, err) 43 }