Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions cadence/tests/fork/backcompat_redeploy_test.cdc
Original file line number Diff line number Diff line change
@@ -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)")
}
42 changes: 34 additions & 8 deletions flow.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -89,6 +104,8 @@
"MOET": {
"source": "./cadence/contracts/MOET.cdc",
"aliases": {
"mainnet": "6b00ff876c299c61",
"mainnet-fork": "6b00ff876c299c61",
"testing": "0000000000000007"
}
},
Expand Down Expand Up @@ -364,7 +381,10 @@
}
]
},
"FlowALPv0"
"FlowALPv0",
"FlowALPRebalancerPaidv1",
"FlowALPRebalancerv1",
"FlowALPSupervisorv1"
],
"mainnet-fyv-deployer": [
"MockDexSwapper",
Expand All @@ -383,7 +403,10 @@
}
]
},
"FlowALPv0"
"FlowALPv0",
"FlowALPRebalancerPaidv1",
"FlowALPRebalancerv1",
"FlowALPSupervisorv1"
],
"mainnet-fork-fyv-deployer": [
"MockDexSwapper",
Expand All @@ -402,7 +425,10 @@
}
]
},
"FlowALPv0"
"FlowALPv0",
"FlowALPRebalancerPaidv1",
"FlowALPRebalancerv1",
"FlowALPSupervisorv1"
],
"testnet-fyv-deployer": [
"MockDexSwapper",
Expand Down
Loading