Skip to content

Commit

Permalink
update construction of path capability values
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent committed Aug 31, 2024
1 parent cff0943 commit d30a1ea
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions cmd/util/ledger/migrations/cadence_values_migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2218,14 +2218,13 @@ func TestStoragePathCapabilityMigration(t *testing.T) {

aCapStorageMapKey := interpreter.StringStorageMapKey("aCap")

aCapability := &interpreter.PathCapabilityValue{
BorrowType: borrowType,
Path: interpreter.NewUnmeteredPathValue(common.PathDomainStorage, "a"),

aCapability := interpreter.NewUnmeteredPathCapabilityValue(
borrowType,
// Important: Capability must be for a different address,
// compared to where the capability is stored.
Address: interpreter.AddressValue(addressB),
}
interpreter.AddressValue(addressB),
interpreter.NewUnmeteredPathValue(common.PathDomainStorage, "a"),
)

storageMapForAddressA.WriteValue(
migrationRuntime.Interpreter,
Expand All @@ -2238,13 +2237,14 @@ func TestStoragePathCapabilityMigration(t *testing.T) {

bCapStorageMapKey := interpreter.StringStorageMapKey("bCap")

bCapability := &interpreter.PathCapabilityValue{
Path: interpreter.NewUnmeteredPathValue(common.PathDomainStorage, "b"),

bCapability := interpreter.NewUnmeteredPathCapabilityValue(
// NOTE: no borrow type
nil,
// Important: Capability must be for a different address,
// compared to where the capability is stored.
Address: interpreter.AddressValue(addressB),
}
interpreter.AddressValue(addressB),
interpreter.NewUnmeteredPathValue(common.PathDomainStorage, "b"),
)

storageMapForAddressA.WriteValue(
migrationRuntime.Interpreter,
Expand All @@ -2269,13 +2269,14 @@ func TestStoragePathCapabilityMigration(t *testing.T) {

cCapStorageMapKey := interpreter.StringStorageMapKey("cCap")

cCapability := &interpreter.PathCapabilityValue{
Path: interpreter.NewUnmeteredPathValue(common.PathDomainStorage, "c"),

cCapability := interpreter.NewUnmeteredPathCapabilityValue(
// NOTE: no borrow type
nil,
// Important: Capability must be for a different address,
// compared to where the capability is stored.
Address: interpreter.AddressValue(addressB),
}
interpreter.AddressValue(addressB),
interpreter.NewUnmeteredPathValue(common.PathDomainStorage, "c"),
)

storageMapForAddressA.WriteValue(
migrationRuntime.Interpreter,
Expand All @@ -2297,14 +2298,13 @@ func TestStoragePathCapabilityMigration(t *testing.T) {

dCapStorageMapKey := interpreter.StringStorageMapKey("dCap")

dCapability := &interpreter.PathCapabilityValue{
BorrowType: dBorrowType,
Path: interpreter.NewUnmeteredPathValue(common.PathDomainStorage, "d"),

dCapability := interpreter.NewUnmeteredPathCapabilityValue(
dBorrowType,
// Important: Capability must be for a different address,
// compared to where the capability is stored.
Address: interpreter.AddressValue(addressB),
}
interpreter.AddressValue(addressB),
interpreter.NewUnmeteredPathValue(common.PathDomainStorage, "d"),
)

storageMapForAddressA.WriteValue(
migrationRuntime.Interpreter,
Expand Down Expand Up @@ -3008,12 +3008,12 @@ func TestStorageCapsMigrationDeterminism(t *testing.T) {
interpreter.PrimitiveStaticTypeAnyStruct,
)

aCapability := &interpreter.PathCapabilityValue{
BorrowType: borrowType,
Path: interpreter.NewUnmeteredPathValue(common.PathDomainStorage, "a"),
aCapability := interpreter.NewUnmeteredPathCapabilityValue(
borrowType,
// Important: Capability must be for address A.
Address: interpreter.AddressValue(addressA),
}
interpreter.AddressValue(addressA),
interpreter.NewUnmeteredPathValue(common.PathDomainStorage, "a"),
)

storageMapForAddressA := storage.GetStorageMap(
addressA,
Expand All @@ -3032,12 +3032,12 @@ func TestStorageCapsMigrationDeterminism(t *testing.T) {
// Then, create a capability with storage path, issued for account A,
// and store it in account B.

bCapability := &interpreter.PathCapabilityValue{
BorrowType: borrowType,
Path: interpreter.NewUnmeteredPathValue(common.PathDomainStorage, "b"),
bCapability := interpreter.NewUnmeteredPathCapabilityValue(
borrowType,
// Important: Capability must be for address A.
Address: interpreter.AddressValue(addressA),
}
interpreter.AddressValue(addressA),
interpreter.NewUnmeteredPathValue(common.PathDomainStorage, "b"),
)

storageMapForAddressB := storage.GetStorageMap(
addressB,
Expand Down

0 comments on commit d30a1ea

Please sign in to comment.