@@ -1308,15 +1308,53 @@ func TestApplSubmission(t *testing.T) {
13081308 // Can't set epp when app id is given
13091309 tx .ForeignApps = append (tx .ForeignApps , basics .AppIndex (7 ))
13101310 TestApp (t , p + `int 1; itxn_field ExtraProgramPages;
1311- int 7; itxn_field ApplicationID` + s , ep , "immutable" )
1311+ int 7; itxn_field ApplicationID` + s , ep , "inappropriate non-zero tx.Extra" )
1312+ // nor can global schema be set
1313+ TestApp (t , p + `int 1; itxn_field GlobalNumUint;
1314+ int 7; itxn_field ApplicationID` + s , ep , "inappropriate non-zero tx.Global" )
1315+ // nor can local schema be set
1316+ TestApp (t , p + `int 1; itxn_field LocalNumUint;
1317+ int 7; itxn_field ApplicationID` + s , ep , "inappropriate non-zero tx.Local" )
1318+
1319+ // When performing an update, we can set epp and (global only) schema
1320+ ledger .NewApp (tx .Receiver , 7 , basics.AppParams {
1321+ ApprovalProgram : ops .Program , // which is "int 1"
1322+ })
1323+ TestApp (t , p + a + `int UpdateApplication; itxn_field OnCompletion;
1324+ int 1; itxn_field ExtraProgramPages;
1325+ int 7; itxn_field ApplicationID` + s , ep )
1326+ // global schema can be set
1327+ TestApp (t , p + a + `int UpdateApplication; itxn_field OnCompletion;
1328+ int 1; itxn_field GlobalNumUint;
1329+ int 7; itxn_field ApplicationID` + s , ep )
1330+ // but local schema still cannot be set
1331+ TestApp (t , p + a + `int UpdateApplication; itxn_field OnCompletion;
1332+ int 1; itxn_field LocalNumUint;
1333+ int 7; itxn_field ApplicationID` + s , ep , "inappropriate non-zero tx.Local" )
1334+
1335+ // Even when performing an update, they cannot be set (in old consensus)
1336+ ep .Proto .AppSizeUpdates = false
1337+ TestApp (t , p + a + `int UpdateApplication; itxn_field OnCompletion;
1338+ int 1; itxn_field ExtraProgramPages;
1339+ int 7; itxn_field ApplicationID` + s , ep , "inappropriate non-zero tx.Extra" )
1340+ // global schema can be set
1341+ TestApp (t , p + a + `int UpdateApplication; itxn_field OnCompletion;
1342+ int 1; itxn_field GlobalNumUint;
1343+ int 7; itxn_field ApplicationID` + s , ep , "inappropriate non-zero tx.Global" )
1344+ // but local schema still cannot be set
1345+ TestApp (t , p + a + `int UpdateApplication; itxn_field OnCompletion;
1346+ int 1; itxn_field LocalNumUint;
1347+ int 7; itxn_field ApplicationID` + s , ep , "inappropriate non-zero tx.Local" )
13121348
13131349 TestApp (t , p + a + "int 20; itxn_field GlobalNumUint; int 11; itxn_field GlobalNumByteSlice" + s ,
13141350 ep , "too large" )
13151351 TestApp (t , p + a + "int 7; itxn_field LocalNumUint; int 7; itxn_field LocalNumByteSlice" + s ,
13161352 ep , "too large" )
13171353}
13181354
1319- func TestInnerApplCreate (t * testing.T ) {
1355+ // TestInnerApplLifecycle tests creation, update, and deletion of apps with
1356+ // inner transactions.
1357+ func TestInnerApplLifecycle (t * testing.T ) {
13201358 partitiontest .PartitionTest (t )
13211359 t .Parallel ()
13221360
@@ -1345,6 +1383,7 @@ itxn_submit
13451383int 1
13461384` )
13471385
1386+ // Can't examine it without ForeignApps
13481387 test ("int 5000; app_params_get AppGlobalNumByteSlice; assert; int 0; ==; assert" ,
13491388 "unavailable App 5000" )
13501389
@@ -1358,7 +1397,8 @@ int 1
13581397 // Can't call it either
13591398 test (call , "unavailable App 5000" )
13601399
1361- tx .ForeignApps = []basics.AppIndex {basics .AppIndex (5000 )}
1400+ // Add to ForeignApps, then we can examine and call it.
1401+ tx .ForeignApps = []basics.AppIndex {5000 }
13621402 test (`
13631403int 5000; app_params_get AppGlobalNumByteSlice; assert; int 0; ==; assert
13641404int 5000; app_params_get AppGlobalNumUint; assert; int 1; ==; assert
@@ -1387,10 +1427,33 @@ int 1
13871427 test (update )
13881428
13891429 if v >= 12 {
1390- // Version starts at 0
1430+ // Version is up to 1
13911431 test (`int 5000; app_params_get AppVersion; assert; int 1; ==` )
13921432 }
13931433
1434+ updateSchema := `
1435+ itxn_begin
1436+ int appl; itxn_field TypeEnum
1437+ int 5000; itxn_field ApplicationID
1438+ ` + approve + `; itxn_field ApprovalProgram
1439+ ` + approve + `; itxn_field ClearStateProgram
1440+ int 2; itxn_field GlobalNumUint
1441+ int UpdateApplication; itxn_field OnCompletion
1442+ itxn_submit
1443+ int 1
1444+ `
1445+ test (updateSchema )
1446+ if v >= 12 {
1447+ // Version is up to 2
1448+ test (`int 5000; app_params_get AppVersion; assert; int 2; ==` )
1449+ }
1450+
1451+ test (`
1452+ int 5000; app_params_get AppGlobalNumUint; assert; int 2; ==; assert
1453+ int 1
1454+ ` )
1455+
1456+ // Delete it
13941457 test (`
13951458itxn_begin
13961459int appl; itxn_field TypeEnum
@@ -1405,7 +1468,6 @@ int 1
14051468
14061469 // Can't call it either
14071470 test (call , "no app 5000" )
1408-
14091471 })
14101472}
14111473
0 commit comments