diff --git a/cadence/tests/fork/backcompat_redeploy_test.cdc b/cadence/tests/fork/backcompat_redeploy_test.cdc new file mode 100644 index 00000000..ad233881 --- /dev/null +++ b/cadence/tests/fork/backcompat_redeploy_test.cdc @@ -0,0 +1,84 @@ +#test_fork(network: "mainnet", height: nil) + +import Test + +access(all) struct ContractSpec { + access(all) let path: String + access(all) let arguments: [AnyStruct] + + init( + path: String, + arguments: [AnyStruct] + ) { + self.path = path + self.arguments = arguments + } +} + +/// Extract contract name from path +/// "../../contracts/FlowALPv0.cdc" -> "FlowALPv0" +access(all) fun contractNameFromPath(path: String): String { + // Split by "/" + let parts = path.split(separator: "/") + let file = parts[parts.length - 1] + + // Remove ".cdc" + let nameParts = file.split(separator: ".") + return nameParts[0] +} + +access(all) fun deployAndExpectSuccess(_ contractSpec: ContractSpec) { + let name = contractNameFromPath(path: contractSpec.path) + + log("Deploying ".concat(name).concat("...")) + + let err = Test.deployContract( + name: name, + path: contractSpec.path, + arguments: contractSpec.arguments + ) + + Test.expect(err, Test.beNil()) + Test.commitBlock() +} + +access(all) fun setup() { + log("==== FlowActions Backward-Compatibility Redeploy Test ====") + + let contractsSpecs: [ContractSpec] = [ + ContractSpec( + path: "../../lib/FlowALPMath.cdc", + arguments: [] + ), + ContractSpec( + path: "../../contracts/MOET.cdc", + arguments: [0.0] + ), + ContractSpec( + path: "../../contracts/FlowALPv0.cdc", + arguments: [] + ), + ContractSpec( + path: "../../contracts/FlowALPRebalancerv1.cdc", + arguments: [] + ), + ContractSpec( + path: "../../contracts/FlowALPRebalancerPaidv1.cdc", + arguments: [] + ), + ContractSpec( + path: "../../contracts/FlowALPSupervisorv1.cdc", + arguments: [] + ) + ] + + for contractSpec in contractsSpecs { + deployAndExpectSuccess(contractSpec) + } + + log("==== All FlowALP contracts redeployed successfully ====") +} + +access(all) fun testAllContractsRedeployedWithoutError() { + log("All FlowALP contracts redeployed without error (verified in setup)") +} diff --git a/flow.json b/flow.json index 7d8baff7..03a71424 100644 --- a/flow.json +++ b/flow.json @@ -49,31 +49,46 @@ "FlowALPMath": { "source": "./cadence/lib/FlowALPMath.cdc", "aliases": { - "testing": "0000000000000007" + "mainnet": "6b00ff876c299c61", + "mainnet-fork": "6b00ff876c299c61", + "testing": "0000000000000007", + "testnet": "426f0458ced60037" } }, "FlowALPRebalancerPaidv1": { "source": "./cadence/contracts/FlowALPRebalancerPaidv1.cdc", "aliases": { - "testing": "0000000000000007" + "mainnet": "6b00ff876c299c61", + "mainnet-fork": "6b00ff876c299c61", + "testing": "0000000000000007", + "testnet": "426f0458ced60037" } }, "FlowALPRebalancerv1": { "source": "./cadence/contracts/FlowALPRebalancerv1.cdc", "aliases": { - "testing": "0000000000000007" + "mainnet": "6b00ff876c299c61", + "mainnet-fork": "6b00ff876c299c61", + "testing": "0000000000000007", + "testnet": "426f0458ced60037" } }, "FlowALPSupervisorv1": { "source": "./cadence/contracts/FlowALPSupervisorv1.cdc", "aliases": { - "testing": "0000000000000007" + "mainnet": "6b00ff876c299c61", + "mainnet-fork": "6b00ff876c299c61", + "testing": "0000000000000007", + "testnet": "426f0458ced60037" } }, "FlowALPv0": { "source": "./cadence/contracts/FlowALPv0.cdc", "aliases": { - "testing": "0000000000000007" + "mainnet": "6b00ff876c299c61", + "mainnet-fork": "6b00ff876c299c61", + "testing": "0000000000000007", + "testnet": "426f0458ced60037" } }, "FungibleTokenConnectors": { @@ -89,6 +104,8 @@ "MOET": { "source": "./cadence/contracts/MOET.cdc", "aliases": { + "mainnet": "6b00ff876c299c61", + "mainnet-fork": "6b00ff876c299c61", "testing": "0000000000000007" } }, @@ -364,7 +381,10 @@ } ] }, - "FlowALPv0" + "FlowALPv0", + "FlowALPRebalancerPaidv1", + "FlowALPRebalancerv1", + "FlowALPSupervisorv1" ], "mainnet-fyv-deployer": [ "MockDexSwapper", @@ -383,7 +403,10 @@ } ] }, - "FlowALPv0" + "FlowALPv0", + "FlowALPRebalancerPaidv1", + "FlowALPRebalancerv1", + "FlowALPSupervisorv1" ], "mainnet-fork-fyv-deployer": [ "MockDexSwapper", @@ -402,7 +425,10 @@ } ] }, - "FlowALPv0" + "FlowALPv0", + "FlowALPRebalancerPaidv1", + "FlowALPRebalancerv1", + "FlowALPSupervisorv1" ], "testnet-fyv-deployer": [ "MockDexSwapper",