Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
janezpodhostnik committed May 16, 2024
1 parent bf6bf25 commit 5e8737e
Show file tree
Hide file tree
Showing 7 changed files with 473 additions and 168 deletions.
12 changes: 9 additions & 3 deletions contracts/DependencyAudit.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ access(all) contract DependencyAudit {

// checkDependencies is called from the FlowServiceAccount contract
access(self) fun checkDependencies(_ dependenciesAddresses: [Address], _ dependenciesNames: [String], _ authorizers: [Address]) {
var numDependencies = dependenciesAddresses.length
var i = 0

var unstagedDependenciesAddresses: [Address] = []
var unstagedDependenciesNames: [String] = []

var numDependencies = dependenciesAddresses.length
var i = 0
while i < numDependencies {
let isExcluded = DependencyAudit.excludedAddresses[dependenciesAddresses[i]] ?? false
if isExcluded {
Expand Down Expand Up @@ -89,6 +88,13 @@ access(all) contract DependencyAudit {
DependencyAudit.panicOnUnstaged = shouldPanic
emit PanicOnUnstagedDependenciesChanged(shouldPanic: shouldPanic)
}

// testCheckDependencies is used for testing purposes
// It will call the `checkDependencies` function with the provided dependencies
// `checkDependencies` is otherwise not callable from the outside
access(all) fun testCheckDependencies(_ dependenciesAddresses: [Address], _ dependenciesNames: [String], _ authorizers: [Address]) {
return DependencyAudit.checkDependencies(dependenciesAddresses, dependenciesNames, authorizers)
}
}

// The admin resource is saved to the storage so that the admin can be accessed by the service account
Expand Down
320 changes: 155 additions & 165 deletions flow.json
Original file line number Diff line number Diff line change
@@ -1,166 +1,156 @@
{
"contracts": {
"A": {
"source": "./contracts/test/A.cdc",
"aliases": {
"emulator": "179b6b1cb6755e31",
"testing": "0000000000000009"
}
},
"B": {
"source": "./contracts/test/B.cdc",
"aliases": {
"emulator": "f3fcd2c1a78f5eee",
"testing": "0000000000000010"
}
},
"C": {
"source": "./contracts/test/C.cdc",
"aliases": {
"emulator": "f3fcd2c1a78f5eee",
"testing": "0000000000000010"
}
},
"Foo": {
"source": "./contracts/test/Foo.cdc",
"aliases": {
"emulator": "01cf0e2f2f715450",
"testing": "0000000000000008"
}
},
"FungibleToken": {
"source": "./contracts/standards/FungibleToken.cdc",
"aliases": {
"emulator": "ee82856bf20e2aa6",
"mainnet": "f233dcee88fe0abe",
"testnet": "9a0766d93b6608b7"
}
},
"MetadataViews": {
"source": "./contracts/standards/MetadataViews.cdc",
"aliases": {
"emulator": "f8d6e0586b0a20c7",
"mainnet": "1d7e57aa55817448",
"testnet": "631e88ae7f1d7c20"
}
},
"MigrationContractStaging": {
"source": "./contracts/MigrationContractStaging.cdc",
"aliases": {
"crescendo": "27b2302520211b67",
"emulator": "f8d6e0586b0a20c7",
"mainnet": "56100d46aa9b0212",
"testing": "0000000000000007",
"testnet": "2ceae959ed1a7e7a"
}
},
"NonFungibleToken": {
"source": "./contracts/standards/NonFungibleToken.cdc",
"aliases": {
"emulator": "f8d6e0586b0a20c7",
"mainnet": "1d7e57aa55817448",
"testnet": "631e88ae7f1d7c20"
}
},
"StagedContractUpdates": {
"source": "./contracts/staged-contract-updates/StagedContractUpdates.cdc",
"aliases": {
"emulator": "f8d6e0586b0a20c7",
"testing": "0000000000000007"
}
}
},
"networks": {
"crescendo": "access.crescendo.nodes.onflow.org: 9000",
"emulator": "127.0.0.1:3569",
"mainnet": "access.mainnet.nodes.onflow.org:9000",
"sandboxnet": "access.sandboxnet.nodes.onflow.org:9000",
"testing": "127.0.0.1:3569",
"testnet": "access.devnet.nodes.onflow.org:9000"
},
"accounts": {
"a-account": {
"address": "179b6b1cb6755e31",
"key": "1bbaf3239cfd9e8e35f85723f6c70f2ac5c8f50856c4667021cf9ed72eabd9f8"
},
"abc-updater": {
"address": "e03daebed8ca0615",
"key": "caa4da634fee3ad45ce67ef8a6813987888d88f4b4e6e70b8d84685845db7f25"
},
"bc-account": {
"address": "f3fcd2c1a78f5eee",
"key": "c06a4b0fce3bc3088a2a2e3b11a9ea5d13e251661cefa3f26af1180ad317d3dc"
},
"emulator-account": {
"address": "f8d6e0586b0a20c7",
"key": "a08c990a1f7adb14c290d05df0f397d2de2f4d0cb18cdffed592f611f95f5d08"
},
"emulator-ft": {
"address": "ee82856bf20e2aa6",
"key": "686779d775e5fcbf8d2f4a85cb4c53525d02b7ef53230d180fc16f35d9b7d025"
},
"foo": {
"address": "01cf0e2f2f715450",
"key": "e9b7b36e9d16f47501db73e84c68e441609475ee482ee808411b2fe0bd2329da"
},
"migration-contract-staging-crescendo": {
"address": "27b2302520211b67",
"key": {
"type": "google-kms",
"hashAlgorithm": "SHA2_256",
"resourceID": "projects/dl-flow-admin/locations/global/keyRings/migration-contract-staging-testnet/cryptoKeys/evm-storage-testnet-key/cryptoKeyVersions/1"
}
},
"migration-contract-staging-mainnet": {
"address": "56100d46aa9b0212",
"key": {
"type": "google-kms",
"hashAlgorithm": "SHA2_256",
"resourceID": "projects/dl-flow-admin/locations/global/keyRings/migration-contract-staging-mainnet/cryptoKeys/evm-storage-mainnet-key/cryptoKeyVersions/1"
}
},
"migration-contract-staging-testnet": {
"address": "2ceae959ed1a7e7a",
"key": {
"type": "google-kms",
"hashAlgorithm": "SHA2_256",
"resourceID": "projects/dl-flow-admin/locations/global/keyRings/migration-contract-staging-testnet/cryptoKeys/evm-storage-testnet-key/cryptoKeyVersions/1"
}
}
},
"deployments": {
"crescendo": {
"migration-contract-staging-crescendo": [
"MigrationContractStaging"
]
},
"emulator": {
"a-account": [
"A"
],
"bc-account": [
"B",
"C"
],
"emulator-account": [
"MigrationContractStaging"
],
"emulator-ft": [
"FungibleToken"
],
"foo": [
"Foo"
]
},
"mainnet": {
"migration-contract-staging-mainnet": [
"MigrationContractStaging"
]
},
"testnet": {
"migration-contract-staging-testnet": [
"MigrationContractStaging"
]
}
}
}
"contracts": {
"A": {
"source": "./contracts/test/A.cdc",
"aliases": {
"emulator": "179b6b1cb6755e31",
"testing": "0000000000000009"
}
},
"B": {
"source": "./contracts/test/B.cdc",
"aliases": {
"emulator": "f3fcd2c1a78f5eee",
"testing": "0000000000000010"
}
},
"C": {
"source": "./contracts/test/C.cdc",
"aliases": {
"emulator": "f3fcd2c1a78f5eee",
"testing": "0000000000000010"
}
},
"Foo": {
"source": "./contracts/test/Foo.cdc",
"aliases": {
"emulator": "01cf0e2f2f715450",
"testing": "0000000000000008"
}
},
"FungibleToken": {
"source": "./contracts/standards/FungibleToken.cdc",
"aliases": {
"emulator": "ee82856bf20e2aa6",
"mainnet": "f233dcee88fe0abe",
"testnet": "9a0766d93b6608b7"
}
},
"MetadataViews": {
"source": "./contracts/standards/MetadataViews.cdc",
"aliases": {
"emulator": "f8d6e0586b0a20c7",
"mainnet": "1d7e57aa55817448",
"testnet": "631e88ae7f1d7c20"
}
},
"MigrationContractStaging": {
"source": "./contracts/MigrationContractStaging.cdc",
"aliases": {
"crescendo": "27b2302520211b67",
"emulator": "f8d6e0586b0a20c7",
"mainnet": "56100d46aa9b0212",
"testing": "0000000000000007",
"testnet": "2ceae959ed1a7e7a"
}
},
"NonFungibleToken": {
"source": "./contracts/standards/NonFungibleToken.cdc",
"aliases": {
"emulator": "f8d6e0586b0a20c7",
"mainnet": "1d7e57aa55817448",
"testnet": "631e88ae7f1d7c20"
}
},
"StagedContractUpdates": {
"source": "./contracts/staged-contract-updates/StagedContractUpdates.cdc",
"aliases": {
"emulator": "f8d6e0586b0a20c7",
"testing": "0000000000000007"
}
},
"DependencyAudit": {
"source": "./contracts/DependencyAudit.cdc",
"aliases": {
"emulator": "f8d6e0586b0a20c7",
"testing": "0000000000000007"
}
}
},
"networks": {
"crescendo": "access.crescendo.nodes.onflow.org: 9000",
"emulator": "127.0.0.1:3569",
"mainnet": "access.mainnet.nodes.onflow.org:9000",
"sandboxnet": "access.sandboxnet.nodes.onflow.org:9000",
"testing": "127.0.0.1:3569",
"testnet": "access.devnet.nodes.onflow.org:9000"
},
"accounts": {
"a-account": {
"address": "179b6b1cb6755e31",
"key": "1bbaf3239cfd9e8e35f85723f6c70f2ac5c8f50856c4667021cf9ed72eabd9f8"
},
"abc-updater": {
"address": "e03daebed8ca0615",
"key": "caa4da634fee3ad45ce67ef8a6813987888d88f4b4e6e70b8d84685845db7f25"
},
"bc-account": {
"address": "f3fcd2c1a78f5eee",
"key": "c06a4b0fce3bc3088a2a2e3b11a9ea5d13e251661cefa3f26af1180ad317d3dc"
},
"emulator-account": {
"address": "f8d6e0586b0a20c7",
"key": "a08c990a1f7adb14c290d05df0f397d2de2f4d0cb18cdffed592f611f95f5d08"
},
"emulator-ft": {
"address": "ee82856bf20e2aa6",
"key": "686779d775e5fcbf8d2f4a85cb4c53525d02b7ef53230d180fc16f35d9b7d025"
},
"foo": {
"address": "01cf0e2f2f715450",
"key": "e9b7b36e9d16f47501db73e84c68e441609475ee482ee808411b2fe0bd2329da"
},
"migration-contract-staging-crescendo": {
"address": "27b2302520211b67",
"key": {
"type": "google-kms",
"hashAlgorithm": "SHA2_256",
"resourceID": "projects/dl-flow-admin/locations/global/keyRings/migration-contract-staging-testnet/cryptoKeys/evm-storage-testnet-key/cryptoKeyVersions/1"
}
},
"migration-contract-staging-mainnet": {
"address": "56100d46aa9b0212",
"key": {
"type": "google-kms",
"hashAlgorithm": "SHA2_256",
"resourceID": "projects/dl-flow-admin/locations/global/keyRings/migration-contract-staging-mainnet/cryptoKeys/evm-storage-mainnet-key/cryptoKeyVersions/1"
}
},
"migration-contract-staging-testnet": {
"address": "2ceae959ed1a7e7a",
"key": {
"type": "google-kms",
"hashAlgorithm": "SHA2_256",
"resourceID": "projects/dl-flow-admin/locations/global/keyRings/migration-contract-staging-testnet/cryptoKeys/evm-storage-testnet-key/cryptoKeyVersions/1"
}
}
},
"deployments": {
"crescendo": {
"migration-contract-staging-crescendo": ["MigrationContractStaging"]
},
"emulator": {
"a-account": ["A"],
"bc-account": ["B", "C"],
"emulator-account": ["MigrationContractStaging", "DependencyAudit"],
"emulator-ft": ["FungibleToken"],
"foo": ["Foo"]
},
"mainnet": {
"migration-contract-staging-mainnet": ["MigrationContractStaging"]
},
"testnet": {
"migration-contract-staging-testnet": ["MigrationContractStaging"]
}
}
}
23 changes: 23 additions & 0 deletions lib/go/contracts/internal/assets/assets.go

Large diffs are not rendered by default.

Loading

0 comments on commit 5e8737e

Please sign in to comment.