Skip to content

Commit

Permalink
Merge pull request #5434 from onflow/supun/untyped-capability-test
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent authored Feb 23, 2024
2 parents b7f56e3 + 1318345 commit 46d7563
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
32 changes: 30 additions & 2 deletions cmd/util/ledger/migrations/cadence_values_migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func checkMigratedPayloads(

storageMap := mr.Storage.GetStorageMap(address, common.PathDomainStorage.Identifier(), false)
require.NotNil(t, storageMap)
require.Equal(t, 11, int(storageMap.Count()))
require.Equal(t, 12, int(storageMap.Count()))

iterator := storageMap.Iterator(mr.Interpreter)

Expand Down Expand Up @@ -241,7 +241,7 @@ func checkMigratedPayloads(
common.CompositeKindResource,
[]interpreter.CompositeField{
{
Value: interpreter.NewUnmeteredUInt64Value(1369094286720630784),
Value: interpreter.NewUnmeteredUInt64Value(360287970189639680),
Name: "uuid",
},
},
Expand All @@ -256,6 +256,12 @@ func checkMigratedPayloads(
),
),

interpreter.NewUnmeteredCapabilityValue(
interpreter.NewUnmeteredUInt64Value(2),
interpreter.NewAddressValue(nil, address),
interpreter.NewReferenceStaticType(nil, entitlementAuthorization(), rResourceType),
),

interpreter.NewDictionaryValue(
mr.Interpreter,
interpreter.EmptyLocationRange,
Expand Down Expand Up @@ -500,6 +506,28 @@ func checkReporters(
common.PathDomainPublic,
),

// untyped capability
capConsPathCapabilityMigrationEntry{
AccountAddress: address,
AddressPath: interpreter.AddressPath{
Address: address,
Path: interpreter.NewUnmeteredPathValue(
common.PathDomainPublic,
"linkR",
),
},
BorrowType: interpreter.NewReferenceStaticType(
nil,
entitlementAuthorization(),
rResourceType,
),
},
newCadenceValueMigrationReportEntry(
"CapabilityValueMigration",
"untyped_capability",
common.PathDomainStorage,
),

// Account-typed keys in dictionary
acctTypedDictKeyMigrationReportEntry,
acctTypedDictKeyMigrationReportEntry,
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@ transaction {

// Capabilities and links
acct.save(<- Test.createR(), to: /storage/r)
var cap = acct.link<&Test.R>(/public/linkR, target: /storage/r)
acct.save(cap, to: /storage/capability)

// Typed capability
var cap1: Capability<&Test.R>? = acct.link<&Test.R>(/public/linkR, target: /storage/r)
acct.save(cap1, to: /storage/capability)

// Untyped capability
var cap2: Capability = acct.getCapability(/public/linkR)
acct.save(cap2, to: /storage/untyped_capability)

// account-typed keys in dictionary
acct.save(
Expand Down

0 comments on commit 46d7563

Please sign in to comment.