Skip to content

Commit

Permalink
add tests for local qualified names
Browse files Browse the repository at this point in the history
  • Loading branch information
dsainati1 committed Feb 7, 2024
1 parent e5989b5 commit 2567340
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions runtime/stdlib/legacy_contract_upgrade_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,39 @@ func TestContractUpgradeIntersectionFieldType(t *testing.T) {
require.NoError(t, err)
})

t.Run("change field type restricted type dict with qualified names", func(t *testing.T) {

t.Parallel()

const oldCode = `
pub contract Test {
pub resource interface I {}
pub resource R:I {}
pub var a: @{Int: R{I}}
init() {
self.a <- {0: <- create R()}
}
}
`

const newCode = `
access(all) contract Test {
access(all) resource interface I {}
access(all) resource R:I {}
access(all) var a: @{Int: Test.R}
init() {
self.a <- {0: <- create Test.R()}
}
}
`

err := testContractUpdate(t, oldCode, newCode)

require.NoError(t, err)
})

t.Run("change field type restricted reference type", func(t *testing.T) {

t.Parallel()
Expand Down Expand Up @@ -937,6 +970,48 @@ func TestContractUpgradeIntersectionFieldType(t *testing.T) {
require.NoError(t, err)
})

t.Run("change field type restricted entitled reference type with qualified types", func(t *testing.T) {

t.Parallel()

const oldCode = `
pub contract Test {
pub resource interface I {
pub fun foo()
}
pub resource R:I {
pub fun foo()
}
pub var a: Capability<&R{I}>?
init() {
self.a = nil
}
}
`

const newCode = `
access(all) contract Test {
access(all) entitlement E
access(all) resource interface I {
access(Test.E) fun foo()
}
access(all) resource R:I {
access(Test.E) fun foo() {}
}
access(all) var a: Capability<auth(Test.E) &Test.R>?
init() {
self.a = nil
}
}
`

err := testContractUpdate(t, oldCode, newCode)

require.NoError(t, err)
})

t.Run("change field type restricted entitled reference type with too many granted entitlements", func(t *testing.T) {

t.Parallel()
Expand Down

0 comments on commit 2567340

Please sign in to comment.