diff --git a/runtime/convertTypes.go b/runtime/convertTypes.go index 4914fac5a9..0358966581 100644 --- a/runtime/convertTypes.go +++ b/runtime/convertTypes.go @@ -570,7 +570,12 @@ func importAuthorization(memoryGauge common.MemoryGauge, auth cadence.Authorizat case cadence.EntitlementMapAuthorization: return interpreter.NewEntitlementMapAuthorization(memoryGauge, auth.TypeID) case cadence.EntitlementSetAuthorization: - return interpreter.NewEntitlementSetAuthorization(memoryGauge, auth.Entitlements, sema.EntitlementSetKind(auth.Kind)) + return interpreter.NewEntitlementSetAuthorization( + memoryGauge, + func() []common.TypeID { return auth.Entitlements }, + len(auth.Entitlements), + sema.EntitlementSetKind(auth.Kind), + ) } panic(fmt.Sprintf("cannot import authorization of type %T", auth)) } diff --git a/runtime/convertValues_test.go b/runtime/convertValues_test.go index c41b67a039..cabbad6add 100644 --- a/runtime/convertValues_test.go +++ b/runtime/convertValues_test.go @@ -1211,7 +1211,12 @@ func TestImportRuntimeType(t *testing.T) { Type: cadence.IntType{}, }, expected: interpreter.ReferenceStaticType{ - Authorization: interpreter.NewEntitlementSetAuthorization(nil, []common.TypeID{"E", "F"}, sema.Conjunction), + Authorization: interpreter.NewEntitlementSetAuthorization( + nil, + func() []common.TypeID { return []common.TypeID{"E", "F"} }, + 2, + sema.Conjunction, + ), ReferencedType: interpreter.PrimitiveStaticTypeInt, }, }, @@ -1226,7 +1231,11 @@ func TestImportRuntimeType(t *testing.T) { Type: cadence.IntType{}, }, expected: interpreter.ReferenceStaticType{ - Authorization: interpreter.NewEntitlementSetAuthorization(nil, []common.TypeID{"E", "F"}, sema.Disjunction), + Authorization: interpreter.NewEntitlementSetAuthorization( + nil, + func() []common.TypeID { return []common.TypeID{"E", "F"} }, + 2, + sema.Disjunction), ReferencedType: interpreter.PrimitiveStaticTypeInt, }, }, diff --git a/runtime/interpreter/decode.go b/runtime/interpreter/decode.go index ee13072c5c..c3474f7bec 100644 --- a/runtime/interpreter/decode.go +++ b/runtime/interpreter/decode.go @@ -1546,18 +1546,34 @@ func (d TypeDecoder) decodeStaticAuthorization() (Authorization, error) { } return nil, err } - var entitlements []common.TypeID - if entitlementsSize > 0 { - entitlements = make([]common.TypeID, entitlementsSize) - for i := 0; i < int(entitlementsSize); i++ { - typeID, err := d.decoder.DecodeString() - if err != nil { - return nil, err + + var setCreationErr error + + entitlementSet := NewEntitlementSetAuthorization( + d.memoryGauge, + func() (entitlements []common.TypeID) { + if entitlementsSize > 0 { + entitlements = make([]common.TypeID, entitlementsSize) + for i := 0; i < int(entitlementsSize); i++ { + typeID, err := d.decoder.DecodeString() + if err != nil { + setCreationErr = err + return nil + } + entitlements[i] = common.TypeID(typeID) + } } - entitlements[i] = common.TypeID(typeID) - } + return + }, + int(entitlementsSize), + sema.EntitlementSetKind(setKind), + ) + + if setCreationErr != nil { + return nil, setCreationErr } - return NewEntitlementSetAuthorization(d.memoryGauge, entitlements, sema.EntitlementSetKind(setKind)), nil + + return entitlementSet, nil } return nil, errors.NewUnexpectedError("invalid static authorization encoding tag: %d", number) } diff --git a/runtime/interpreter/interpreter.go b/runtime/interpreter/interpreter.go index bb0903067b..17ef300dc5 100644 --- a/runtime/interpreter/interpreter.go +++ b/runtime/interpreter/interpreter.go @@ -3481,34 +3481,41 @@ func referenceTypeFunction(invocation Invocation) Value { } var authorization Authorization = UnauthorizedAccess - var entitlements []common.TypeID = make([]common.TypeID, 0, entitlementValues.Count()) errInIteration := false + entitlementsCount := entitlementValues.Count() - entitlementValues.Iterate(invocation.Interpreter, func(element Value) (resume bool) { - entitlementString, isString := element.(*StringValue) - if !isString { - errInIteration = true - return false - } + if entitlementsCount > 0 { + authorization = NewEntitlementSetAuthorization( + invocation.Interpreter, + func() []common.TypeID { + entitlements := make([]common.TypeID, 0, entitlementsCount) + entitlementValues.Iterate(invocation.Interpreter, func(element Value) (resume bool) { + entitlementString, isString := element.(*StringValue) + if !isString { + errInIteration = true + return false + } - _, err := lookupEntitlement(invocation.Interpreter, entitlementString.Str) - if err != nil { - errInIteration = true - return false - } - entitlements = append(entitlements, common.TypeID(entitlementString.Str)) + _, err := lookupEntitlement(invocation.Interpreter, entitlementString.Str) + if err != nil { + errInIteration = true + return false + } + entitlements = append(entitlements, common.TypeID(entitlementString.Str)) - return true - }) + return true + }) + return entitlements + }, + entitlementsCount, + sema.Conjunction, + ) + } if errInIteration { return Nil } - if len(entitlements) > 0 { - authorization = NewEntitlementSetAuthorization(invocation.Interpreter, entitlements, sema.Conjunction) - } - return NewSomeValueNonCopying( invocation.Interpreter, NewTypeValue( diff --git a/runtime/interpreter/statictype.go b/runtime/interpreter/statictype.go index f133f156ac..fda26179f2 100644 --- a/runtime/interpreter/statictype.go +++ b/runtime/interpreter/statictype.go @@ -513,14 +513,21 @@ var _ Authorization = EntitlementSetAuthorization{} func NewEntitlementSetAuthorization( memoryGauge common.MemoryGauge, - entitlementList []common.TypeID, + entitlementListConstructor func() []common.TypeID, + entitlementListSize int, kind sema.EntitlementSetKind, ) EntitlementSetAuthorization { common.UseMemory(memoryGauge, common.MemoryUsage{ Kind: common.MemoryKindEntitlementSetStaticAccess, - Amount: uint64(len(entitlementList)), + Amount: uint64(entitlementListSize), }) + entitlementList := entitlementListConstructor() + if len(entitlementList) > entitlementListSize { + // it should not be possible to reach this point unless something is implemented wrong + panic(errors.NewUnreachableError()) + } + entitlements := orderedmap.New[sema.TypeIDOrderedSet](len(entitlementList)) for _, entitlement := range entitlementList { entitlements.Set(entitlement, struct{}{}) @@ -831,7 +838,18 @@ func ConvertSemaAccesstoStaticAuthorization( typeId := key.ID() entitlements = append(entitlements, typeId) }) - return NewEntitlementSetAuthorization(memoryGauge, entitlements, access.SetKind) + return NewEntitlementSetAuthorization( + memoryGauge, + func() (entitlements []common.TypeID) { + access.Entitlements.Foreach(func(key *sema.EntitlementType, _ struct{}) { + typeId := key.ID() + entitlements = append(entitlements, typeId) + }) + return + }, + access.Entitlements.Len(), + access.SetKind, + ) case sema.EntitlementMapAccess: typeId := access.Type.ID() diff --git a/runtime/tests/interpreter/entitlements_test.go b/runtime/tests/interpreter/entitlements_test.go index 99f4d03a61..e4e6194380 100644 --- a/runtime/tests/interpreter/entitlements_test.go +++ b/runtime/tests/interpreter/entitlements_test.go @@ -262,7 +262,8 @@ func TestInterpretEntitledReferences(t *testing.T) { t, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.X"}, + func() []common.TypeID { return []common.TypeID{"S.test.X"} }, + 1, sema.Conjunction, ).Equal(value.(*interpreter.StorageReferenceValue).Authorization), ) @@ -608,7 +609,8 @@ func TestInterpretEntitledReferenceCasting(t *testing.T) { nil, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.X", "S.test.Y"}, + func() []common.TypeID { return []common.TypeID{"S.test.X", "S.test.Y"} }, + 2, sema.Conjunction, ), interpreter.PrimitiveStaticTypeInt, @@ -652,7 +654,10 @@ func TestInterpretEntitledReferenceCasting(t *testing.T) { address, interpreter.NewReferenceStaticType( nil, - interpreter.NewEntitlementSetAuthorization(nil, []common.TypeID{"S.test.X"}, sema.Conjunction), + interpreter.NewEntitlementSetAuthorization(nil, + func() []common.TypeID { return []common.TypeID{"S.test.X"} }, + 1, + sema.Conjunction), interpreter.PrimitiveStaticTypeInt, ), ) @@ -1055,7 +1060,8 @@ func TestInterpretEntitlementMappingFields(t *testing.T) { t, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.Y"}, + func() []common.TypeID { return []common.TypeID{"S.test.Y"} }, + 1, sema.Conjunction, ).Equal(value.(*interpreter.EphemeralReferenceValue).Authorization), ) @@ -1105,7 +1111,8 @@ func TestInterpretEntitlementMappingFields(t *testing.T) { t, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.Y"}, + func() []common.TypeID { return []common.TypeID{"S.test.Y"} }, + 1, sema.Conjunction, ).Equal(value.(*interpreter.EphemeralReferenceValue).Authorization), ) @@ -1154,7 +1161,8 @@ func TestInterpretEntitlementMappingFields(t *testing.T) { t, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.Y"}, + func() []common.TypeID { return []common.TypeID{"S.test.Y"} }, + 1, sema.Conjunction, ).Equal(value.(*interpreter.EphemeralReferenceValue).Authorization), ) @@ -1202,7 +1210,8 @@ func TestInterpretEntitlementMappingFields(t *testing.T) { t, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.Y", "S.test.F"}, + func() []common.TypeID { return []common.TypeID{"S.test.Y", "S.test.F"} }, + 2, sema.Conjunction, ).Equal(value.(*interpreter.EphemeralReferenceValue).Authorization), ) @@ -1251,7 +1260,8 @@ func TestInterpretEntitlementMappingFields(t *testing.T) { t, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.Y", "S.test.F"}, + func() []common.TypeID { return []common.TypeID{"S.test.Y", "S.test.F"} }, + 2, sema.Conjunction, ).Equal(value.(*interpreter.EphemeralReferenceValue).Authorization), ) @@ -1300,7 +1310,8 @@ func TestInterpretEntitlementMappingFields(t *testing.T) { t, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.Y"}, + func() []common.TypeID { return []common.TypeID{"S.test.Y"} }, + 1, sema.Conjunction, ).Equal(value.(*interpreter.EphemeralReferenceValue).Authorization), ) @@ -1357,7 +1368,8 @@ func TestInterpretEntitlementMappingFields(t *testing.T) { t, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.Y"}, + func() []common.TypeID { return []common.TypeID{"S.test.Y"} }, + 1, sema.Conjunction, ).Equal(value.(*interpreter.EphemeralReferenceValue).Authorization), ) @@ -1404,7 +1416,8 @@ func TestInterpretEntitlementMappingAccessors(t *testing.T) { t, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.Y"}, + func() []common.TypeID { return []common.TypeID{"S.test.Y"} }, + 1, sema.Conjunction, ).Equal(value.(*interpreter.EphemeralReferenceValue).Authorization), ) @@ -1475,7 +1488,8 @@ func TestInterpretEntitlementMappingAccessors(t *testing.T) { t, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.Y", "S.test.Z"}, + func() []common.TypeID { return []common.TypeID{"S.test.Y", "S.test.Z"} }, + 2, sema.Conjunction, ).Equal(value.(*interpreter.EphemeralReferenceValue).Authorization), ) @@ -1514,7 +1528,8 @@ func TestInterpretEntitlementMappingAccessors(t *testing.T) { t, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.Y", "S.test.Z"}, + func() []common.TypeID { return []common.TypeID{"S.test.Y", "S.test.Z"} }, + 2, sema.Conjunction, ).Equal(value.(*interpreter.EphemeralReferenceValue).Authorization), ) @@ -1559,7 +1574,8 @@ func TestInterpretEntitlementMappingAccessors(t *testing.T) { t, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.F"}, + func() []common.TypeID { return []common.TypeID{"S.test.F"} }, + 1, sema.Conjunction, ).Equal(value.(*interpreter.EphemeralReferenceValue).Authorization), ) @@ -1757,7 +1773,8 @@ func TestInterpretEntitlementMappingAccessors(t *testing.T) { t, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.Y"}, + func() []common.TypeID { return []common.TypeID{"S.test.Y"} }, + 1, sema.Conjunction, ).Equal(value.(*interpreter.EphemeralReferenceValue).Authorization), ) @@ -1805,7 +1822,8 @@ func TestInterpretEntitlementMappingAccessors(t *testing.T) { t, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.Z"}, + func() []common.TypeID { return []common.TypeID{"S.test.Z"} }, + 1, sema.Conjunction, ).Equal(value.(*interpreter.EphemeralReferenceValue).Authorization), ) @@ -1856,7 +1874,8 @@ func TestInterpretEntitlementMappingAccessors(t *testing.T) { t, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.Z"}, + func() []common.TypeID { return []common.TypeID{"S.test.Z"} }, + 1, sema.Conjunction, ).Equal(value.(*interpreter.EphemeralReferenceValue).Authorization), ) @@ -1910,7 +1929,8 @@ func TestInterpretEntitlementMappingAccessors(t *testing.T) { t, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.Z"}, + func() []common.TypeID { return []common.TypeID{"S.test.Z"} }, + 1, sema.Conjunction, ).Equal(value.(*interpreter.EphemeralReferenceValue).Authorization), ) @@ -1966,7 +1986,8 @@ func TestInterpretEntitlementMappingAccessors(t *testing.T) { t, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.B", "S.test.Z"}, + func() []common.TypeID { return []common.TypeID{"S.test.B", "S.test.Z"} }, + 2, sema.Conjunction, ).Equal(value.(*interpreter.EphemeralReferenceValue).Authorization), ) @@ -2003,7 +2024,8 @@ func TestInterpretEntitledAttachments(t *testing.T) { t, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.Y", "S.test.Z"}, + func() []common.TypeID { return []common.TypeID{"S.test.Y", "S.test.Z"} }, + 2, sema.Conjunction, ).Equal(value.(*interpreter.EphemeralReferenceValue).Authorization), ) @@ -2040,7 +2062,8 @@ func TestInterpretEntitledAttachments(t *testing.T) { t, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.Y", "S.test.Z"}, + func() []common.TypeID { return []common.TypeID{"S.test.Y", "S.test.Z"} }, + 2, sema.Conjunction, ).Equal(value.(*interpreter.EphemeralReferenceValue).Authorization), ) @@ -2111,7 +2134,8 @@ func TestInterpretEntitledAttachments(t *testing.T) { t, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.X"}, + func() []common.TypeID { return []common.TypeID{"S.test.X"} }, + 1, sema.Conjunction, ).Equal(value.(*interpreter.EphemeralReferenceValue).Authorization), ) @@ -2151,7 +2175,8 @@ func TestInterpretEntitledAttachments(t *testing.T) { t, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.F", "S.test.G"}, + func() []common.TypeID { return []common.TypeID{"S.test.F", "S.test.G"} }, + 2, sema.Conjunction, ).Equal(value.(*interpreter.EphemeralReferenceValue).Authorization), ) @@ -2195,7 +2220,8 @@ func TestInterpretEntitledAttachments(t *testing.T) { t, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.F", "S.test.G", "S.test.Y", "S.test.Z"}, + func() []common.TypeID { return []common.TypeID{"S.test.F", "S.test.G", "S.test.Y", "S.test.Z"} }, + 4, sema.Conjunction, ).Equal(value.(*interpreter.EphemeralReferenceValue).Authorization), ) @@ -2280,7 +2306,8 @@ func TestInterpretEntitledAttachments(t *testing.T) { t, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.E"}, + func() []common.TypeID { return []common.TypeID{"S.test.E"} }, + 1, sema.Conjunction, ).Equal(value.(*interpreter.EphemeralReferenceValue).Authorization), ) @@ -2321,7 +2348,8 @@ func TestInterpretEntitledAttachments(t *testing.T) { t, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.F", "S.test.G"}, + func() []common.TypeID { return []common.TypeID{"S.test.F", "S.test.G"} }, + 2, sema.Conjunction, ).Equal(value.(*interpreter.EphemeralReferenceValue).Authorization), ) @@ -2366,7 +2394,8 @@ func TestInterpretEntitledAttachments(t *testing.T) { t, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.F", "S.test.G"}, + func() []common.TypeID { return []common.TypeID{"S.test.F", "S.test.G"} }, + 2, sema.Conjunction, ).Equal(value.(*interpreter.EphemeralReferenceValue).Authorization), ) @@ -2415,7 +2444,8 @@ func TestInterpretEntitledAttachments(t *testing.T) { t, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.F", "S.test.G", "S.test.Y", "S.test.Z"}, + func() []common.TypeID { return []common.TypeID{"S.test.F", "S.test.G", "S.test.Y", "S.test.Z"} }, + 4, sema.Conjunction, ).Equal(value.(*interpreter.EphemeralReferenceValue).Authorization), ) @@ -2465,7 +2495,8 @@ func TestInterpretEntitledAttachments(t *testing.T) { t, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.X"}, + func() []common.TypeID { return []common.TypeID{"S.test.X"} }, + 1, sema.Conjunction, ).Equal(value.(*interpreter.EphemeralReferenceValue).Authorization), ) @@ -2557,7 +2588,8 @@ func TestInterpretEntitledAttachments(t *testing.T) { t, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.X"}, + func() []common.TypeID { return []common.TypeID{"S.test.X"} }, + 1, sema.Conjunction, ).Equal(value.(*interpreter.EphemeralReferenceValue).Authorization), ) @@ -2627,7 +2659,8 @@ func TestInterpretEntitledReferenceCollections(t *testing.T) { t, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.X"}, + func() []common.TypeID { return []common.TypeID{"S.test.X"} }, + 1, sema.Conjunction, ).Equal(value.(*interpreter.EphemeralReferenceValue).Authorization), ) @@ -2655,7 +2688,8 @@ func TestInterpretEntitledReferenceCollections(t *testing.T) { t, interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.X"}, + func() []common.TypeID { return []common.TypeID{"S.test.X"} }, + 1, sema.Conjunction, ).Equal(value.(*interpreter.EphemeralReferenceValue).Authorization), ) @@ -2671,13 +2705,15 @@ func TestInterpretEntitlementSetEquality(t *testing.T) { conjunction := interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.X"}, + func() []common.TypeID { return []common.TypeID{"S.test.X"} }, + 1, sema.Conjunction, ) disjunction := interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.X"}, + func() []common.TypeID { return []common.TypeID{"S.test.X"} }, + 1, sema.Disjunction, ) @@ -2691,13 +2727,15 @@ func TestInterpretEntitlementSetEquality(t *testing.T) { one := interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.X"}, + func() []common.TypeID { return []common.TypeID{"S.test.X"} }, + 1, sema.Conjunction, ) two := interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"S.test.X", "S.test.Y"}, + func() []common.TypeID { return []common.TypeID{"S.test.X", "S.test.Y"} }, + 2, sema.Conjunction, ) diff --git a/runtime/tests/interpreter/metatype_test.go b/runtime/tests/interpreter/metatype_test.go index 8534f1c927..aa4c8b0a08 100644 --- a/runtime/tests/interpreter/metatype_test.go +++ b/runtime/tests/interpreter/metatype_test.go @@ -633,7 +633,11 @@ func TestInterpretGetType(t *testing.T) { result: interpreter.TypeValue{ Type: interpreter.OptionalStaticType{ Type: interpreter.ReferenceStaticType{ - Authorization: interpreter.NewEntitlementSetAuthorization(nil, []common.TypeID{"S.test.X"}, sema.Conjunction), + Authorization: interpreter.NewEntitlementSetAuthorization( + nil, + func() []common.TypeID { return []common.TypeID{"S.test.X"} }, + 1, + sema.Conjunction), ReferencedType: interpreter.PrimitiveStaticTypeInt, }, }, @@ -680,7 +684,10 @@ func TestInterpretGetType(t *testing.T) { result: interpreter.TypeValue{ Type: interpreter.OptionalStaticType{ Type: interpreter.ReferenceStaticType{ - Authorization: interpreter.NewEntitlementSetAuthorization(nil, []common.TypeID{"S.test.X"}, sema.Conjunction), + Authorization: interpreter.NewEntitlementSetAuthorization( + nil, + func() []common.TypeID { return []common.TypeID{"S.test.X"} }, + 1, sema.Conjunction), ReferencedType: interpreter.PrimitiveStaticTypeInt, }, }, @@ -733,7 +740,11 @@ func TestInterpretGetType(t *testing.T) { result: interpreter.TypeValue{ Type: interpreter.OptionalStaticType{ Type: interpreter.ReferenceStaticType{ - Authorization: interpreter.NewEntitlementSetAuthorization(nil, []common.TypeID{"S.test.X"}, sema.Conjunction), + Authorization: interpreter.NewEntitlementSetAuthorization( + nil, + func() []common.TypeID { return []common.TypeID{"S.test.X"} }, + 1, + sema.Conjunction), ReferencedType: interpreter.PrimitiveStaticTypeInt, }, }, diff --git a/runtime/tests/interpreter/reference_test.go b/runtime/tests/interpreter/reference_test.go index 39a5446a7b..f4f3b68fec 100644 --- a/runtime/tests/interpreter/reference_test.go +++ b/runtime/tests/interpreter/reference_test.go @@ -664,7 +664,8 @@ func TestInterpretResourceReferenceInvalidationOnMove(t *testing.T) { arrayRef := interpreter.NewUnmeteredEphemeralReferenceValue( interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"Mutate"}, + func() []common.TypeID { return []common.TypeID{"Mutate"} }, + 1, sema.Conjunction, ), array, @@ -768,7 +769,8 @@ func TestInterpretResourceReferenceInvalidationOnMove(t *testing.T) { arrayRef1 := interpreter.NewUnmeteredEphemeralReferenceValue( interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"Mutate"}, + func() []common.TypeID { return []common.TypeID{"Mutate"} }, + 1, sema.Conjunction, ), array1, @@ -791,7 +793,8 @@ func TestInterpretResourceReferenceInvalidationOnMove(t *testing.T) { arrayRef2 := interpreter.NewUnmeteredEphemeralReferenceValue( interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"Mutate"}, + func() []common.TypeID { return []common.TypeID{"Mutate"} }, + 1, sema.Conjunction, ), array2, @@ -861,7 +864,8 @@ func TestInterpretResourceReferenceInvalidationOnMove(t *testing.T) { arrayRef := interpreter.NewUnmeteredEphemeralReferenceValue( interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"Mutate"}, + func() []common.TypeID { return []common.TypeID{"Mutate"} }, + 1, sema.Conjunction, ), array, @@ -990,7 +994,8 @@ func TestInterpretResourceReferenceInvalidationOnMove(t *testing.T) { arrayRef := interpreter.NewUnmeteredEphemeralReferenceValue( interpreter.NewEntitlementSetAuthorization( nil, - []common.TypeID{"Mutate"}, + func() []common.TypeID { return []common.TypeID{"Mutate"} }, + 1, sema.Conjunction, ), array, diff --git a/runtime/tests/interpreter/runtimetype_test.go b/runtime/tests/interpreter/runtimetype_test.go index 18a9c4862e..ce30aaf393 100644 --- a/runtime/tests/interpreter/runtimetype_test.go +++ b/runtime/tests/interpreter/runtimetype_test.go @@ -520,7 +520,12 @@ func TestInterpretReferenceType(t *testing.T) { Location: utils.TestLocation, TypeID: "S.test.R", }, - Authorization: interpreter.NewEntitlementSetAuthorization(nil, []common.TypeID{"S.test.X"}, sema.Conjunction), + Authorization: interpreter.NewEntitlementSetAuthorization( + nil, + func() []common.TypeID { return []common.TypeID{"S.test.X"} }, + 1, + sema.Conjunction, + ), }, }, inter.Globals.Get("a").GetValue(), @@ -544,7 +549,12 @@ func TestInterpretReferenceType(t *testing.T) { Location: utils.TestLocation, TypeID: "S.test.S", }, - Authorization: interpreter.NewEntitlementSetAuthorization(nil, []common.TypeID{"S.test.X"}, sema.Conjunction), + Authorization: interpreter.NewEntitlementSetAuthorization( + nil, + func() []common.TypeID { return []common.TypeID{"S.test.X"} }, + 1, + sema.Conjunction, + ), }, }, inter.Globals.Get("c").GetValue(),