Skip to content

Commit 83473a0

Browse files
committed
Tests for file ordering
1 parent fa60e8d commit 83473a0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+603
-1
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
fail-fast: false
2323
matrix:
2424
os: ["ubuntu-latest", "windows-2022"]
25-
type: ["brownie", "buidler", "dapp", "embark", "hardhat", "solc", "truffle", "waffle", "foundry", "standard"]
25+
type: ["brownie", "buidler", "dapp", "embark", "hardhat", "solc", "truffle", "waffle", "foundry", "standard", "solc_multi_file", "hardhat_multi_file"]
2626
exclude:
2727
# Currently broken, tries to pull git:// which is blocked by GH
2828
- type: embark
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
DIR=$(mktemp -d)
4+
5+
cp -r tests/hardhat-multi-file "$DIR"
6+
cd "$DIR/hardhat-multi-file" || exit 255
7+
npm install
8+
crytic-compile --compile-remove-metadata --export-formats solc,truffle .
9+
10+
cd - || exit 255
11+
node tests/process_combined_solc.js "$DIR/hardhat-multi-file/crytic-export/combined_solc.json" "$DIR"
12+
DIFF=$(diff -r "$DIR/hardhat-multi-file/crytic-export" tests/expected/hardhat-multi-file)
13+
if [ "$?" != "0" ] || [ "$DIFF" != "" ]
14+
then
15+
echo "hardhat-multi-file test failed"
16+
echo "$DIFF"
17+
exit 255
18+
fi

scripts/ci_test_solc_multi_file.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
DIR=$(mktemp -d)
4+
5+
cp -r tests/solc-multi-file "$DIR"
6+
cd "$DIR/solc-multi-file" || exit 255
7+
crytic-compile --compile-remove-metadata --export-formats solc,truffle A.sol
8+
9+
cd - || exit 255
10+
node tests/process_combined_solc.js "$DIR/solc-multi-file/crytic-export/combined_solc.json" "$DIR"
11+
DIFF=$(diff -r "$DIR/solc-multi-file/crytic-export" tests/expected/solc-multi-file)
12+
if [ "$?" != "0" ] || [ "$DIFF" != "" ]
13+
then
14+
echo "solc-multi-file test failed"
15+
echo "$DIFF"
16+
exit 255
17+
fi

tests/expected/hardhat-multi-file/A.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

tests/expected/hardhat-multi-file/B.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

tests/expected/hardhat-multi-file/C.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

tests/expected/hardhat-multi-file/D.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"contractName": "E", "abi": [{"inputs": [{"internalType": "uint256", "name": "yval", "type": "uint256"}], "stateMutability": "nonpayable", "type": "constructor"}, {"inputs": [{"internalType": "uint256", "name": "xval", "type": "uint256"}], "name": "setX", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [], "name": "sum", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}], "bytecode": "0x608060405234801561001057600080fd5b506040516105033803806105038339818101604052602081101561003357600080fd5b810190808051906020019092919050505060008081905550806001819055508060405161005f906100cc565b80828152602001915050604051809103906000f080158015610085573d6000803e3d6000fd5b50600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506100d9565b6102a28061026183390190565b610179806100e86000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80634018d9aa1461003b578063853255cc14610069575b600080fd5b6100676004803603602081101561005157600080fd5b8101908080359060200190929190505050610087565b005b610071610091565b6040518082815260200191505060405180910390f35b8060008190555050565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a0d7afb76040518163ffffffff1660e01b815260040160206040518083038186803b1580156100fb57600080fd5b505afa15801561010f573d6000803e3d6000fd5b505050506040513d602081101561012557600080fd5b8101908080519060200190929190505050600154600054010190509056fe608060405234801561001057600080fd5b506040516102a23803806102a28339818101604052602081101561003357600080fd5b810190808051906020019092919050505060008081905550806001819055506005604051610060906100cd565b80828152602001915050604051809103906000f080158015610086573d6000803e3d6000fd5b50600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506100da565b61012d8061017583390190565b608d806100e86000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063a0d7afb714602d575b600080fd5b60336049565b6040518082815260200191505060405180910390f35b60006001546000540390509056fea26469706673582212204e7f66950d7eac1667bf123fd0c2c0b36d53de5866b4bd867fac7411e321b0b464736f6c63430007030033608060405234801561001057600080fd5b5060405161012d38038061012d8339818101604052602081101561003357600080fd5b810190808051906020019092919050505060008081905550806001819055505060cc806100616000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80634018d9aa146037578063853255cc146062575b600080fd5b606060048036036020811015604b57600080fd5b8101908080359060200190929190505050607e565b005b60686088565b6040518082815260200191505060405180910390f35b8060008190555050565b60006001546000540190509056fea2646970667358221220fa023934f603bf6bcaae6a6ab06db920cce4aca360c67548633e7f3514118cc964736f6c63430007030033", "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100365760003560e01c80634018d9aa1461003b578063853255cc14610069575b600080fd5b6100676004803603602081101561005157600080fd5b8101908080359060200190929190505050610087565b005b610071610091565b6040518082815260200191505060405180910390f35b8060008190555050565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a0d7afb76040518163ffffffff1660e01b815260040160206040518083038186803b1580156100fb57600080fd5b505afa15801561010f573d6000803e3d6000fd5b505050506040513d602081101561012557600080fd5b8101908080519060200190929190505050600154600054010190509056fe", "ast": {"absolutePath": "contracts/E/E.sol", "exportedSymbols": {"C": [191], "D": [229], "E": [285], "I": [421]}, "id": 286, "license": "Unlicense", "nodeType": "SourceUnit", "nodes": [{"id": 231, "literals": ["solidity", "^", "0.7", ".0"], "nodeType": "PragmaDirective", "src": "37:23:2"}, {"absolutePath": "contracts/C.sol", "file": "../C.sol", "id": 232, "nodeType": "ImportDirective", "scope": 286, "sourceUnit": 230, "src": "62:18:2", "symbolAliases": [], "unitAlias": ""}, {"absolutePath": "contracts/I/I.sol", "file": "../I/I.sol", "id": 233, "nodeType": "ImportDirective", "scope": 286, "sourceUnit": 422, "src": "81:20:2", "symbolAliases": [], "unitAlias": ""}, {"abstract": false, "baseContracts": [], "contractDependencies": [229], "contractKind": "contract", "fullyImplemented": true, "id": 285, "linearizedBaseContracts": [285], "name": "E", "nodeType": "ContractDefinition", "nodes": [{"constant": false, "id": 235, "mutability": "mutable", "name": "x", "nodeType": "VariableDeclaration", "scope": 285, "src": "118:9:2", "stateVariable": true, "storageLocation": "default", "typeDescriptions": {"typeIdentifier": "t_uint256", "typeString": "uint256"}, "typeName": {"id": 234, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "118:7:2", "typeDescriptions": {"typeIdentifier": "t_uint256", "typeString": "uint256"}}, "visibility": "internal"}, {"constant": false, "id": 237, "mutability": "mutable", "name": "y", "nodeType": "VariableDeclaration", "scope": 285, "src": "131:9:2", "stateVariable": true, "storageLocation": "default", "typeDescriptions": {"typeIdentifier": "t_uint256", "typeString": "uint256"}, "typeName": {"id": 236, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "131:7:2", "typeDescriptions": {"typeIdentifier": "t_uint256", "typeString": "uint256"}}, "visibility": "internal"}, {"constant": false, "id": 239, "mutability": "mutable", "name": "d", "nodeType": "VariableDeclaration", "scope": 285, "src": "144:3:2", "stateVariable": true, "storageLocation": "default", "typeDescriptions": {"typeIdentifier": "t_contract$_D_$229", "typeString": "contract D"}, "typeName": {"id": 238, "name": "D", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 229, "src": "144:1:2", "typeDescriptions": {"typeIdentifier": "t_contract$_D_$229", "typeString": "contract D"}}, "visibility": "internal"}, {"body": {"id": 259, "nodeType": "Block", "src": "178:51:2", "statements": [{"expression": {"id": 246, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": {"id": 244, "name": "x", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 235, "src": "184:1:2", "typeDescriptions": {"typeIdentifier": "t_uint256", "typeString": "uint256"}}, "nodeType": "Assignment", "operator": "=", "rightHandSide": {"hexValue": "30", "id": 245, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "188:1:2", "typeDescriptions": {"typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0"}, "value": "0"}, "src": "184:5:2", "typeDescriptions": {"typeIdentifier": "t_uint256", "typeString": "uint256"}}, "id": 247, "nodeType": "ExpressionStatement", "src": "184:5:2"}, {"expression": {"id": 250, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": {"id": 248, "name": "y", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 237, "src": "195:1:2", "typeDescriptions": {"typeIdentifier": "t_uint256", "typeString": "uint256"}}, "nodeType": "Assignment", "operator": "=", "rightHandSide": {"id": 249, "name": "yval", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 241, "src": "199:4:2", "typeDescriptions": {"typeIdentifier": "t_uint256", "typeString": "uint256"}}, "src": "195:8:2", "typeDescriptions": {"typeIdentifier": "t_uint256", "typeString": "uint256"}}, "id": 251, "nodeType": "ExpressionStatement", "src": "195:8:2"}, {"expression": {"id": 257, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": {"id": 252, "name": "d", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 239, "src": "209:1:2", "typeDescriptions": {"typeIdentifier": "t_contract$_D_$229", "typeString": "contract D"}}, "nodeType": "Assignment", "operator": "=", "rightHandSide": {"arguments": [{"id": 255, "name": "yval", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 241, "src": "219:4:2", "typeDescriptions": {"typeIdentifier": "t_uint256", "typeString": "uint256"}}], "expression": {"argumentTypes": [{"typeIdentifier": "t_uint256", "typeString": "uint256"}], "id": 254, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "nodeType": "NewExpression", "src": "213:5:2", "typeDescriptions": {"typeIdentifier": "t_function_creation_nonpayable$_t_uint256_$returns$_t_contract$_D_$229_$", "typeString": "function (uint256) returns (contract D)"}, "typeName": {"id": 253, "name": "D", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 229, "src": "217:1:2", "typeDescriptions": {"typeIdentifier": "t_contract$_D_$229", "typeString": "contract D"}}}, "id": 256, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "213:11:2", "tryCall": false, "typeDescriptions": {"typeIdentifier": "t_contract$_D_$229", "typeString": "contract D"}}, "src": "209:15:2", "typeDescriptions": {"typeIdentifier": "t_contract$_D_$229", "typeString": "contract D"}}, "id": 258, "nodeType": "ExpressionStatement", "src": "209:15:2"}]}, "id": 260, "implemented": true, "kind": "constructor", "modifiers": [], "name": "", "nodeType": "FunctionDefinition", "parameters": {"id": 242, "nodeType": "ParameterList", "parameters": [{"constant": false, "id": 241, "mutability": "mutable", "name": "yval", "nodeType": "VariableDeclaration", "scope": 260, "src": "164:12:2", "stateVariable": false, "storageLocation": "default", "typeDescriptions": {"typeIdentifier": "t_uint256", "typeString": "uint256"}, "typeName": {"id": 240, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "164:7:2", "typeDescriptions": {"typeIdentifier": "t_uint256", "typeString": "uint256"}}, "visibility": "internal"}], "src": "163:14:2"}, "returnParameters": {"id": 243, "nodeType": "ParameterList", "parameters": [], "src": "178:0:2"}, "scope": 285, "src": "152:77:2", "stateMutability": "nonpayable", "virtual": false, "visibility": "public"}, {"body": {"id": 273, "nodeType": "Block", "src": "278:30:2", "statements": [{"expression": {"commonType": {"typeIdentifier": "t_uint256", "typeString": "uint256"}, "id": 271, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": {"commonType": {"typeIdentifier": "t_uint256", "typeString": "uint256"}, "id": 267, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": {"id": 265, "name": "x", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 235, "src": "291:1:2", "typeDescriptions": {"typeIdentifier": "t_uint256", "typeString": "uint256"}}, "nodeType": "BinaryOperation", "operator": "+", "rightExpression": {"id": 266, "name": "y", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 237, "src": "293:1:2", "typeDescriptions": {"typeIdentifier": "t_uint256", "typeString": "uint256"}}, "src": "291:3:2", "typeDescriptions": {"typeIdentifier": "t_uint256", "typeString": "uint256"}}, "nodeType": "BinaryOperation", "operator": "+", "rightExpression": {"arguments": [], "expression": {"argumentTypes": [], "expression": {"id": 268, "name": "d", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 239, "src": "295:1:2", "typeDescriptions": {"typeIdentifier": "t_contract$_D_$229", "typeString": "contract D"}}, "id": 269, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "diff", "nodeType": "MemberAccess", "referencedDeclaration": 228, "src": "295:6:2", "typeDescriptions": {"typeIdentifier": "t_function_external_view$__$returns$_t_uint256_$", "typeString": "function () view external returns (uint256)"}}, "id": 270, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "295:8:2", "tryCall": false, "typeDescriptions": {"typeIdentifier": "t_uint256", "typeString": "uint256"}}, "src": "291:12:2", "typeDescriptions": {"typeIdentifier": "t_uint256", "typeString": "uint256"}}, "functionReturnParameters": 264, "id": 272, "nodeType": "Return", "src": "284:19:2"}]}, "functionSelector": "853255cc", "id": 274, "implemented": true, "kind": "function", "modifiers": [], "name": "sum", "nodeType": "FunctionDefinition", "parameters": {"id": 261, "nodeType": "ParameterList", "parameters": [], "src": "245:2:2"}, "returnParameters": {"id": 264, "nodeType": "ParameterList", "parameters": [{"constant": false, "id": 263, "mutability": "mutable", "name": "", "nodeType": "VariableDeclaration", "scope": 274, "src": "269:7:2", "stateVariable": false, "storageLocation": "default", "typeDescriptions": {"typeIdentifier": "t_uint256", "typeString": "uint256"}, "typeName": {"id": 262, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "269:7:2", "typeDescriptions": {"typeIdentifier": "t_uint256", "typeString": "uint256"}}, "visibility": "internal"}], "src": "268:9:2"}, "scope": 285, "src": "233:75:2", "stateMutability": "view", "virtual": false, "visibility": "public"}, {"body": {"id": 283, "nodeType": "Block", "src": "347:19:2", "statements": [{"expression": {"id": 281, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": {"id": 279, "name": "x", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 235, "src": "353:1:2", "typeDescriptions": {"typeIdentifier": "t_uint256", "typeString": "uint256"}}, "nodeType": "Assignment", "operator": "=", "rightHandSide": {"id": 280, "name": "xval", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 276, "src": "357:4:2", "typeDescriptions": {"typeIdentifier": "t_uint256", "typeString": "uint256"}}, "src": "353:8:2", "typeDescriptions": {"typeIdentifier": "t_uint256", "typeString": "uint256"}}, "id": 282, "nodeType": "ExpressionStatement", "src": "353:8:2"}]}, "functionSelector": "4018d9aa", "id": 284, "implemented": true, "kind": "function", "modifiers": [], "name": "setX", "nodeType": "FunctionDefinition", "parameters": {"id": 277, "nodeType": "ParameterList", "parameters": [{"constant": false, "id": 276, "mutability": "mutable", "name": "xval", "nodeType": "VariableDeclaration", "scope": 284, "src": "326:12:2", "stateVariable": false, "storageLocation": "default", "typeDescriptions": {"typeIdentifier": "t_uint256", "typeString": "uint256"}, "typeName": {"id": 275, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "326:7:2", "typeDescriptions": {"typeIdentifier": "t_uint256", "typeString": "uint256"}}, "visibility": "internal"}], "src": "325:14:2"}, "returnParameters": {"id": 278, "nodeType": "ParameterList", "parameters": [], "src": "347:0:2"}, "scope": 285, "src": "312:54:2", "stateMutability": "nonpayable", "virtual": false, "visibility": "public"}], "scope": 286, "src": "103:265:2"}], "src": "37:332:2"}, "userdoc": {"methods": {}, "notice": null}, "devdoc": {"methods": {}, "author": null, "details": null, "title": null}}

tests/expected/hardhat-multi-file/G.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

tests/expected/hardhat-multi-file/I.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)