From 4db78674487d71ed2fb95ce9efd02fde6ebcbcad Mon Sep 17 00:00:00 2001 From: Supun Setunga Date: Fri, 30 Aug 2024 08:27:15 -0700 Subject: [PATCH] Add contract-update test for removing a field from nested resource --- runtime/contract_update_validation_test.go | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/runtime/contract_update_validation_test.go b/runtime/contract_update_validation_test.go index 24cee33329..c39eede25e 100644 --- a/runtime/contract_update_validation_test.go +++ b/runtime/contract_update_validation_test.go @@ -395,6 +395,54 @@ func TestRuntimeContractUpdateValidation(t *testing.T) { assertExtraneousFieldError(t, cause, "TestResource", "c") }) + testWithValidators(t, "remove field from nested decl", func(t *testing.T, config Config) { + + const oldCode = ` + access(all) contract Test { + + access(all) var a: @TestResource + + init() { + self.a <- create Test.TestResource() + } + + access(all) resource TestResource { + + access(all) var b: String + access(all) var c: Int + + init() { + self.b = "hello" + self.c = 0 + } + } + } + ` + + const newCode = ` + access(all) contract Test { + + access(all) var a: @Test.TestResource + + init() { + self.a <- create Test.TestResource() + } + + access(all) resource TestResource { + + access(all) var b: String + + init() { + self.b = "hello" + } + } + } + ` + + err := testDeployAndUpdate(t, "Test", oldCode, newCode, config) + require.NoError(t, err) + }) + testWithValidators(t, "change indirect field type", func(t *testing.T, config Config) { const oldCode = `