Skip to content

Commit

Permalink
Add test for staging with entitlements
Browse files Browse the repository at this point in the history
  • Loading branch information
SupunS committed Aug 27, 2024
1 parent 1c6c140 commit bd87b9f
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions internal/migrate/staging_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -876,4 +876,61 @@ func Test_StagingValidator(t *testing.T) {

require.NoError(t, err)
})

t.Run("contract update with entitlements", func(t *testing.T) {
// setup mocks
srv := setupValidatorMocks(t, []mockNetworkAccount{
{
address: flow.HexToAddress("01"),
contracts: map[string][]byte{"Foo": []byte(`
pub contract Foo {
pub resource Bar {}
}`)},
},
{
address: flow.HexToAddress("02"),
contracts: map[string][]byte{"Test": []byte(`
import Foo from 0x01
pub contract Test {
pub resource R {
pub var bar: auth &Foo.Bar?
init() {
self.bar = nil
}
}
}`)},
},
})

validator := newStagingValidator(srv)
err := validator.Validate([]stagedContractUpdate{
{
DeployLocation: simpleAddressLocation("0x01.Foo"),
SourceLocation: common.StringLocation("./Foo.cdc"),
Code: []byte(`
access(all) contract Foo {
access(all) resource Bar {
access(E) fun foo(){}
}
access(all) entitlement E
}`),
},
{
DeployLocation: simpleAddressLocation("0x02.Test"),
SourceLocation: common.StringLocation("./Test.cdc"),
Code: []byte(`
import Foo from 0x01
access(all) contract Test {
access(all) resource R {
access(all) var bar: auth(Foo.E) &Foo.Bar?
init() {
self.bar = nil
}
}
}`),
},
})

require.NoError(t, err)
})
}

0 comments on commit bd87b9f

Please sign in to comment.