@@ -682,123 +682,6 @@ func TestRuntimeContractRedeploymentInSeparateTransactions(t *testing.T) {
682
682
require .NoError (t , err )
683
683
}
684
684
685
- func TestRuntimeLegacyContractUpdate (t * testing.T ) {
686
- t .Parallel ()
687
-
688
- t .SkipNow ()
689
-
690
- runtime := NewTestInterpreterRuntimeWithConfig (Config {
691
- AtreeValidationEnabled : true ,
692
- LegacyContractUpgradeEnabled : true ,
693
- })
694
-
695
- accountCodes := map [common.Location ][]byte {}
696
- signerAccount := common .MustBytesToAddress ([]byte {0x1 })
697
- fooLocation := common.AddressLocation {
698
- Address : signerAccount ,
699
- Name : "Foo" ,
700
- }
701
- var checkGetAndSetProgram , getProgramCalled bool
702
-
703
- programs := map [Location ]* interpreter.Program {}
704
- clearPrograms := func () {
705
- for l := range programs {
706
- delete (programs , l )
707
- }
708
- }
709
-
710
- runtimeInterface := & TestRuntimeInterface {
711
- OnGetCode : func (location Location ) (bytes []byte , err error ) {
712
- return accountCodes [location ], nil
713
- },
714
- Storage : NewTestLedger (nil , nil ),
715
- OnGetSigningAccounts : func () ([]Address , error ) {
716
- return []Address {signerAccount }, nil
717
- },
718
- OnResolveLocation : NewSingleIdentifierLocationResolver (t ),
719
- OnGetAccountContractCode : func (location common.AddressLocation ) (code []byte , err error ) {
720
- return accountCodes [location ], nil
721
- },
722
- OnGetAccountContractNames : func (_ Address ) ([]string , error ) {
723
- return []string {"Foo" }, nil
724
- },
725
- OnUpdateAccountContractCode : func (location common.AddressLocation , code []byte ) error {
726
- accountCodes [location ] = code
727
- return nil
728
- },
729
- OnEmitEvent : func (event cadence.Event ) error {
730
- return nil
731
- },
732
- OnDecodeArgument : func (b []byte , t cadence.Type ) (value cadence.Value , err error ) {
733
- return json .Decode (nil , b )
734
- },
735
- OnGetAndSetProgram : func (
736
- location Location ,
737
- load func () (* interpreter.Program , error ),
738
- ) (
739
- program * interpreter.Program ,
740
- err error ,
741
- ) {
742
- _ , isTransactionLocation := location .(common.TransactionLocation )
743
- if checkGetAndSetProgram && ! isTransactionLocation {
744
- require .Equal (t , location , fooLocation )
745
- require .False (t , getProgramCalled )
746
- }
747
-
748
- var ok bool
749
- program , ok = programs [location ]
750
- if ok {
751
- return
752
- }
753
-
754
- program , err = load ()
755
-
756
- // NOTE: important: still set empty program,
757
- // even if error occurred
758
-
759
- programs [location ] = program
760
-
761
- return
762
- },
763
- }
764
-
765
- nextTransactionLocation := NewTransactionLocationGenerator ()
766
-
767
- const fooContractV1 = `
768
- pub contract Foo {
769
- init() {}
770
- pub fun hello() {}
771
- }
772
- `
773
-
774
- const fooContractV2 = `
775
- access(all) contract Foo {
776
- init() {}
777
- access(all) fun hello() {}
778
- }
779
- `
780
-
781
- // Mock the deployment of the old 'Foo' contract
782
- accountCodes [fooLocation ] = []byte (fooContractV1 )
783
-
784
- // Programs are only valid during the transaction
785
- clearPrograms ()
786
-
787
- // Update 'Foo' contract to Cadence 1.0 version
788
-
789
- signerAccount = common .MustBytesToAddress ([]byte {0x1 })
790
- err := runtime .ExecuteTransaction (
791
- Script {
792
- Source : UpdateTransaction ("Foo" , []byte (fooContractV2 )),
793
- },
794
- Context {
795
- Interface : runtimeInterface ,
796
- Location : nextTransactionLocation (),
797
- },
798
- )
799
- require .NoError (t , err )
800
- }
801
-
802
685
func TestRuntimeContractUpdateWithOldProgramError (t * testing.T ) {
803
686
t .Parallel ()
804
687
0 commit comments