Skip to content

Commit

Permalink
GH-2886 test cases for all branches of validation logic
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryBespalov committed Nov 21, 2023
1 parent 2b1b52c commit 036b4f5
Show file tree
Hide file tree
Showing 11 changed files with 1,744 additions and 32 deletions.
28 changes: 28 additions & 0 deletions Multisig.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,13 @@
B367AED22B0CB89600F06B86 /* TransactionValidationTestCase1.json in Resources */ = {isa = PBXBuildFile; fileRef = B367AED12B0CB89600F06B86 /* TransactionValidationTestCase1.json */; };
B3710B3D2AD584BE002E503B /* SecureConfig in Frameworks */ = {isa = PBXBuildFile; productRef = B3710B3C2AD584BE002E503B /* SecureConfig */; };
B3710B442AD5AAD7002E503B /* config.bundle in Resources */ = {isa = PBXBuildFile; fileRef = B3710B432AD5AAD7002E503B /* config.bundle */; };
B380756B2B0CF45200C62BCF /* TransactionValidationTestCase_InvalidSafeTxHash.json in Resources */ = {isa = PBXBuildFile; fileRef = B380756A2B0CF45200C62BCF /* TransactionValidationTestCase_InvalidSafeTxHash.json */; };
B380756D2B0CF60A00C62BCF /* TransactionValidationTestCase_NoConfirmations.json in Resources */ = {isa = PBXBuildFile; fileRef = B380756C2B0CF60A00C62BCF /* TransactionValidationTestCase_NoConfirmations.json */; };
B380756F2B0CF6AC00C62BCF /* TransactionValidationTestCase_ConfirmationsNotFromOwners.json in Resources */ = {isa = PBXBuildFile; fileRef = B380756E2B0CF6AC00C62BCF /* TransactionValidationTestCase_ConfirmationsNotFromOwners.json */; };
B38075712B0CF75200C62BCF /* TransactionValidationTestCase_SignerNotMatchingSignature.json in Resources */ = {isa = PBXBuildFile; fileRef = B38075702B0CF75200C62BCF /* TransactionValidationTestCase_SignerNotMatchingSignature.json */; };
B38075732B0CF7C600C62BCF /* TransactionValidationTestCase_MultipleConfirmations.json in Resources */ = {isa = PBXBuildFile; fileRef = B38075722B0CF7C600C62BCF /* TransactionValidationTestCase_MultipleConfirmations.json */; };
B38075752B0CF85900C62BCF /* TransactionValidationTestCase_AllSignatureTypes_v1_1_0.json in Resources */ = {isa = PBXBuildFile; fileRef = B38075742B0CF85900C62BCF /* TransactionValidationTestCase_AllSignatureTypes_v1_1_0.json */; };
B38075772B0CFD3A00C62BCF /* TransactionValidationTestCase_AllSignatureTypes_v1_0_0.json in Resources */ = {isa = PBXBuildFile; fileRef = B38075762B0CFD3A00C62BCF /* TransactionValidationTestCase_AllSignatureTypes_v1_0_0.json */; };
B3B6044F2A850F5E007BDAC0 /* UIAlertControllerStyle+Multiplatform.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3B6044E2A850F5E007BDAC0 /* UIAlertControllerStyle+Multiplatform.swift */; };
B3C4D2D92AAF596D0026A8BC /* UIViewController+Navigation.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3C4D2D82AAF596D0026A8BC /* UIViewController+Navigation.swift */; };
D80B5A032769CEAD00D6E024 /* Tooltip.swift in Sources */ = {isa = PBXBuildFile; fileRef = D80B5A022769CEAD00D6E024 /* Tooltip.swift */; };
Expand Down Expand Up @@ -2089,6 +2096,13 @@
B3710B432AD5AAD7002E503B /* config.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = config.bundle; sourceTree = "<group>"; };
B3710B452AD5AE9D002E503B /* apis-prod.example.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "apis-prod.example.json"; sourceTree = "<group>"; };
B3710B462AD5AE9D002E503B /* apis-staging.example.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "apis-staging.example.json"; sourceTree = "<group>"; };
B380756A2B0CF45200C62BCF /* TransactionValidationTestCase_InvalidSafeTxHash.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = TransactionValidationTestCase_InvalidSafeTxHash.json; sourceTree = "<group>"; };
B380756C2B0CF60A00C62BCF /* TransactionValidationTestCase_NoConfirmations.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = TransactionValidationTestCase_NoConfirmations.json; sourceTree = "<group>"; };
B380756E2B0CF6AC00C62BCF /* TransactionValidationTestCase_ConfirmationsNotFromOwners.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = TransactionValidationTestCase_ConfirmationsNotFromOwners.json; sourceTree = "<group>"; };
B38075702B0CF75200C62BCF /* TransactionValidationTestCase_SignerNotMatchingSignature.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = TransactionValidationTestCase_SignerNotMatchingSignature.json; sourceTree = "<group>"; };
B38075722B0CF7C600C62BCF /* TransactionValidationTestCase_MultipleConfirmations.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = TransactionValidationTestCase_MultipleConfirmations.json; sourceTree = "<group>"; };
B38075742B0CF85900C62BCF /* TransactionValidationTestCase_AllSignatureTypes_v1_1_0.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = TransactionValidationTestCase_AllSignatureTypes_v1_1_0.json; sourceTree = "<group>"; };
B38075762B0CFD3A00C62BCF /* TransactionValidationTestCase_AllSignatureTypes_v1_0_0.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = TransactionValidationTestCase_AllSignatureTypes_v1_0_0.json; sourceTree = "<group>"; };
B3B6044E2A850F5E007BDAC0 /* UIAlertControllerStyle+Multiplatform.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIAlertControllerStyle+Multiplatform.swift"; sourceTree = "<group>"; };
B3C4D2D82AAF596D0026A8BC /* UIViewController+Navigation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+Navigation.swift"; sourceTree = "<group>"; };
D80B5A022769CEAD00D6E024 /* Tooltip.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tooltip.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3482,6 +3496,13 @@
0A64313F247ED1AA006FD30A /* MultisigIntegrationTests.xctestplan */,
B367AECE2B0CB59700F06B86 /* TransactionValidationTests.swift */,
B367AED12B0CB89600F06B86 /* TransactionValidationTestCase1.json */,
B38075762B0CFD3A00C62BCF /* TransactionValidationTestCase_AllSignatureTypes_v1_0_0.json */,
B38075742B0CF85900C62BCF /* TransactionValidationTestCase_AllSignatureTypes_v1_1_0.json */,
B38075722B0CF7C600C62BCF /* TransactionValidationTestCase_MultipleConfirmations.json */,
B380756C2B0CF60A00C62BCF /* TransactionValidationTestCase_NoConfirmations.json */,
B38075702B0CF75200C62BCF /* TransactionValidationTestCase_SignerNotMatchingSignature.json */,
B380756E2B0CF6AC00C62BCF /* TransactionValidationTestCase_ConfirmationsNotFromOwners.json */,
B380756A2B0CF45200C62BCF /* TransactionValidationTestCase_InvalidSafeTxHash.json */,
0A802B8F24E581A50001790F /* SafeClientGatewayServiceIntegrationTests.swift */,
0A513A9C2768EBC900F07D5A /* DelegateKeyTests.swift */,
5532D4D02449A1E40067505A /* MockLogger.swift */,
Expand Down Expand Up @@ -5220,11 +5241,18 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B38075732B0CF7C600C62BCF /* TransactionValidationTestCase_MultipleConfirmations.json in Resources */,
B38075772B0CFD3A00C62BCF /* TransactionValidationTestCase_AllSignatureTypes_v1_0_0.json in Resources */,
B38075752B0CF85900C62BCF /* TransactionValidationTestCase_AllSignatureTypes_v1_1_0.json in Resources */,
0AA5F55F28BF6F2200D6D220 /* claiming_test_fixtures.yml in Resources */,
B380756B2B0CF45200C62BCF /* TransactionValidationTestCase_InvalidSafeTxHash.json in Resources */,
B380756D2B0CF60A00C62BCF /* TransactionValidationTestCase_NoConfirmations.json in Resources */,
0A61E8452670E632009D68A4 /* __Snapshots__ in Resources */,
6A91EFDA27DA2C8D009E63E9 /* wc_registry_wallets.json in Resources */,
0AA5F55D28BF667000D6D220 /* claiming_test_fixtures.json in Resources */,
B380756F2B0CF6AC00C62BCF /* TransactionValidationTestCase_ConfirmationsNotFromOwners.json in Resources */,
B367AED22B0CB89600F06B86 /* TransactionValidationTestCase1.json in Resources */,
B38075712B0CF75200C62BCF /* TransactionValidationTestCase_SignerNotMatchingSignature.json in Resources */,
0A74719A269F152D008E9F2D /* chains_4_safes_0x1230B3d59858296A31053C1b8562Ecf89A2f888b_balances_usd.json in Resources */,
0A3DFEFE2667D3A700B45770 /* README.md in Resources */,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ class TransactionDetailCellBuilder {
}

guard !txMultisigInfo.confirmations.isEmpty else {
throw "Transaction has no confirmations. This may be a dangerous transaction"
throw "Transaction has no confirmations."
}

// all confirming addresses are from safe owners
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
{
"testCaseName": "Valid transaction, Ethereum, 2/4 owners, 1/2 confirmations",
"chain": {
"chainId": "1",
"chainName": "Ethereum",
"description": "The main Ethereum network",
"l2": false,
"nativeCurrency": {
"name": "Ether",
"symbol": "ETH",
"decimals": 18,
"logoUri": "https://safe-transaction-assets.safe.global/chains/1/currency_logo.png"
},
"transactionService": "https://safe-transaction-mainnet.safe.global",
"blockExplorerUriTemplate": {
"address": "https://etherscan.io/address/{{address}}",
"txHash": "https://etherscan.io/tx/{{txHash}}",
"api": "https://api.etherscan.io/api?module={{module}}&action={{action}}&address={{address}}&apiKey={{apiKey}}"
},
"disabledWallets": [
"NONE",
"opera",
"operaTouch",
"safeMobile",
"socialSigner",
"tally",
"trust",
"walletConnect"
],
"ensRegistryAddress": "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
"features": [
"CONTRACT_INTERACTION",
"DEFAULT_TOKENLIST",
"DOMAIN_LOOKUP",
"EIP1271",
"EIP1559",
"ERC721",
"MOONPAY_MOBILE",
"NATIVE_WALLETCONNECT",
"PUSH_NOTIFICATIONS",
"RISK_MITIGATION",
"SAFE_APPS",
"SAFE_TX_GAS_OPTIONAL",
"SOCIAL_LOGIN",
"SPENDING_LIMIT",
"TX_SIMULATION"
],
"gasPrice": [
{
"type": "oracle",
"uri": "https://api.etherscan.io/api?module=gastracker&action=gasoracle&apikey=JNFAU892RF9TJWBU3EV7DJCPIWZY8KEMY1",
"gasParameter": "FastGasPrice",
"gweiFactor": "1000000000.000000000"
}
],
"publicRpcUri": {
"authentication": "NO_AUTHENTICATION",
"value": "https://cloudflare-eth.com"
},
"rpcUri": {
"authentication": "API_KEY_PATH",
"value": "https://mainnet.infura.io/v3/"
},
"safeAppsRpcUri": {
"authentication": "API_KEY_PATH",
"value": "https://mainnet.infura.io/v3/"
},
"shortName": "eth",
"theme": {
"textColor": "#001428",
"backgroundColor": "#DDDDDD"
}
},
"safe": {
"address": {
"value": "0xfF501B324DC6d78dC9F983f140B9211c3EdB4dc7",
"name": null,
"logoUri": null
},
"chainId": "1",
"nonce": 20,
"threshold": 2,
"owners": [
{
"value": "0x9F87C1aCaF3Afc6a5557c58284D9F8609470b571",
"name": null,
"logoUri": null
},
{
"value": "0x8712128BEA09C9687Df05A5D692F3750F8086C81",
"name": null,
"logoUri": null
},
{
"value": "0x80F59C1D46EFC1Bb18F0AaEc132b77266f00Be9a",
"name": null,
"logoUri": null
},
{
"value": "0x9F7dfAb2222A473284205cdDF08a677726d786A0",
"name": null,
"logoUri": null
},
{
"value": "0x728cafe9fB8CC2218Fb12a9A2D9335193caa07e0",
"name": null,
"logoUri": null
}
],
"implementation": {
"value": "0x34CfAC646f301356fAa8B21e94227e3583Fe3F5F",
"name": "Safe 1.0.0",
"logoUri": "https://safe-transaction-assets.safe.global/contracts/logos/0x34CfAC646f301356fAa8B21e94227e3583Fe3F5F.png"
},
"implementationVersionState": "OUTDATED",
"collectiblesTag": "1663062476",
"txQueuedTag": "1670938242",
"txHistoryTag": "1697840747",
"messagesTag": "1700560947",
"modules": [
{
"value": "0xCFbFaC74C26F8647cBDb8c5caf80BB5b32E43134",
"name": null,
"logoUri": null
}
],
"fallbackHandler": {
"value": "0xd5D82B6aDDc9027B22dCA772Aa68D5d74cdBdF44",
"name": "Safe: DefaultCallbackHandler 1.0.0",
"logoUri": "https://safe-transaction-assets.safe.global/contracts/logos/0xd5D82B6aDDc9027B22dCA772Aa68D5d74cdBdF44.png"
},
"guard": null,
"version": "1.0.0"
},
"tx": {
"safeAddress": "0xfF501B324DC6d78dC9F983f140B9211c3EdB4dc7",
"txId": "multisig_0xfF501B324DC6d78dC9F983f140B9211c3EdB4dc7_0xaed54190962dce2c448391841fcd7730eb23ac18c5fa2a7896ac9074bf38f127",
"executedAt": null,
"txStatus": "AWAITING_CONFIRMATIONS",
"txInfo": {
"type": "Custom",
"humanDescription": null,
"richDecodedInfo": null,
"to": {
"value": "0xfF501B324DC6d78dC9F983f140B9211c3EdB4dc7",
"name": null,
"logoUri": null
},
"dataSize": "0",
"value": "0",
"methodName": null,
"actionCount": null,
"isCancellation": false
},
"txData": {
"hexData": null,
"dataDecoded": null,
"to": {
"value": "0xfF501B324DC6d78dC9F983f140B9211c3EdB4dc7",
"name": null,
"logoUri": null
},
"value": "0",
"operation": 0,
"trustedDelegateCallTarget": null,
"addressInfoIndex": null
},
"txHash": null,
"detailedExecutionInfo": {
"type": "MULTISIG",
"submittedAt": 1614014118782,
"nonce": 20,
"safeTxGas": "43808",
"baseGas": "0",
"gasPrice": "0",
"gasToken": "0x0000000000000000000000000000000000000000",
"refundReceiver": {
"value": "0x0000000000000000000000000000000000000000",
"name": null,
"logoUri": null
},
"safeTxHash": "0xaed54190962dce2c448391841fcd7730eb23ac18c5fa2a7896ac9074bf38f127",
"executor": null,
"signers": [
{
"value": "0x9F87C1aCaF3Afc6a5557c58284D9F8609470b571",
"name": null,
"logoUri": null
},
{
"value": "0x8712128BEA09C9687Df05A5D692F3750F8086C81",
"name": null,
"logoUri": null
},
{
"value": "0x80F59C1D46EFC1Bb18F0AaEc132b77266f00Be9a",
"name": null,
"logoUri": null
},
{
"value": "0x9F7dfAb2222A473284205cdDF08a677726d786A0",
"name": null,
"logoUri": null
}
],
"confirmationsRequired": 2,
"confirmations": [
{
"signer": {
"value": "0x8712128BEA09C9687Df05A5D692F3750F8086C81",
"name": null,
"logoUri": null
},
"signature": "0x7dec7a1c46320f9bc4b62fe22e6ad34fe1f54b08c39637d064d104def4f3c812591ad2da837f5d9049d74e038811f76fcb33ac739e7ef866f696abdc9e55e1f51b",
"submittedAt": 1614014118798
},
{
"signer": {
"value": "0x9F87C1aCaF3Afc6a5557c58284D9F8609470b571",
"name": null,
"logoUri": null
},
"signature": "0x0000000000000000000000009f87c1acaf3afc6a5557c58284d9f8609470b571abababababababababababababababababababababababababababababababab00",
"submittedAt": 1614014118797
},
{
"signer": {
"value": "0x9F7dfAb2222A473284205cdDF08a677726d786A0",
"name": null,
"logoUri": null
},
"signature": "0x0000000000000000000000009f7dfab2222a473284205cddf08a677726d786a0abababababababababababababababababababababababababababababababab01",
"submittedAt": 1614014118797
},
],
"rejectors": [],
"gasTokenInfo": null,
"trusted": true
},
"safeAppInfo": null
}
}
Loading

0 comments on commit 036b4f5

Please sign in to comment.