diff --git a/test-mutation/all-configs/config.single.json b/test-mutation/all-configs/config.single.json new file mode 100644 index 0000000000..c5dd04f417 --- /dev/null +++ b/test-mutation/all-configs/config.single.json @@ -0,0 +1,10 @@ +[ + { + "filename": "../contracts/tokenbridge/ethereum/gateway/L1ERC20Gateway.sol", + "sourceroot": "..", + "solc_remappings": [ + "@openzeppelin=../node_modules/@openzeppelin", + "@arbitrum=../node_modules/@arbitrum" + ] + } +] diff --git a/test-mutation/all-configs/config.tokenbridge-ethereum.json b/test-mutation/all-configs/config.tokenbridge-ethereum.json new file mode 100644 index 0000000000..13da9e7018 --- /dev/null +++ b/test-mutation/all-configs/config.tokenbridge-ethereum.json @@ -0,0 +1,106 @@ +[ + { + "filename": "../contracts/tokenbridge/ethereum/L1ArbitrumMessenger.sol", + "sourceroot": "..", + "solc_remappings": [ + "@openzeppelin=../node_modules/@openzeppelin", + "@arbitrum=../node_modules/@arbitrum" + ] + }, + { + "filename": "../contracts/tokenbridge/ethereum/gateway/L1ArbitrumExtendedGateway.sol", + "sourceroot": "..", + "solc_remappings": [ + "@openzeppelin=../node_modules/@openzeppelin", + "@arbitrum=../node_modules/@arbitrum" + ] + }, + { + "filename": "../contracts/tokenbridge/ethereum/gateway/L1ArbitrumGateway.sol", + "sourceroot": "..", + "solc_remappings": [ + "@openzeppelin=../node_modules/@openzeppelin", + "@arbitrum=../node_modules/@arbitrum" + ] + }, + { + "filename": "../contracts/tokenbridge/ethereum/gateway/L1CustomGateway.sol", + "sourceroot": "..", + "solc_remappings": [ + "@openzeppelin=../node_modules/@openzeppelin", + "@arbitrum=../node_modules/@arbitrum" + ] + }, + { + "filename": "../contracts/tokenbridge/ethereum/gateway/L1ERC20Gateway.sol", + "sourceroot": "..", + "solc_remappings": [ + "@openzeppelin=../node_modules/@openzeppelin", + "@arbitrum=../node_modules/@arbitrum" + ] + }, + { + "filename": "../contracts/tokenbridge/ethereum/gateway/L1ForceOnlyReverseCustomGateway.sol", + "sourceroot": "..", + "solc_remappings": [ + "@openzeppelin=../node_modules/@openzeppelin", + "@arbitrum=../node_modules/@arbitrum" + ] + }, + { + "filename": "../contracts/tokenbridge/ethereum/gateway/L1GatewayRouter.sol", + "sourceroot": "..", + "solc_remappings": [ + "@openzeppelin=../node_modules/@openzeppelin", + "@arbitrum=../node_modules/@arbitrum" + ] + }, + { + "filename": "../contracts/tokenbridge/ethereum/gateway/L1OrbitCustomGateway.sol", + "sourceroot": "..", + "solc_remappings": [ + "@openzeppelin=../node_modules/@openzeppelin", + "@arbitrum=../node_modules/@arbitrum" + ] + }, + { + "filename": "../contracts/tokenbridge/ethereum/gateway/L1OrbitERC20Gateway.sol", + "sourceroot": "..", + "solc_remappings": [ + "@openzeppelin=../node_modules/@openzeppelin", + "@arbitrum=../node_modules/@arbitrum" + ] + }, + { + "filename": "../contracts/tokenbridge/ethereum/gateway/L1OrbitGatewayRouter.sol", + "sourceroot": "..", + "solc_remappings": [ + "@openzeppelin=../node_modules/@openzeppelin", + "@arbitrum=../node_modules/@arbitrum" + ] + }, + { + "filename": "../contracts/tokenbridge/ethereum/gateway/L1OrbitReverseCustomGateway.sol", + "sourceroot": "..", + "solc_remappings": [ + "@openzeppelin=../node_modules/@openzeppelin", + "@arbitrum=../node_modules/@arbitrum" + ] + }, + { + "filename": "../contracts/tokenbridge/ethereum/gateway/L1ReverseCustomGateway.sol", + "sourceroot": "..", + "solc_remappings": [ + "@openzeppelin=../node_modules/@openzeppelin", + "@arbitrum=../node_modules/@arbitrum" + ] + }, + { + "filename": "../contracts/tokenbridge/ethereum/gateway/L1WethGateway.sol", + "sourceroot": "..", + "solc_remappings": [ + "@openzeppelin=../node_modules/@openzeppelin", + "@arbitrum=../node_modules/@arbitrum" + ] + } +] diff --git a/test-mutation/config.json b/test-mutation/config.json index 9fe720829d..13da9e7018 100644 --- a/test-mutation/config.json +++ b/test-mutation/config.json @@ -1,6 +1,6 @@ [ { - "filename": "../contracts/tokenbridge/ethereum/gateway/L1ERC20Gateway.sol", + "filename": "../contracts/tokenbridge/ethereum/L1ArbitrumMessenger.sol", "sourceroot": "..", "solc_remappings": [ "@openzeppelin=../node_modules/@openzeppelin", @@ -8,7 +8,15 @@ ] }, { - "filename": "../contracts/tokenbridge/ethereum/gateway/L1CustomGateway.sol", + "filename": "../contracts/tokenbridge/ethereum/gateway/L1ArbitrumExtendedGateway.sol", + "sourceroot": "..", + "solc_remappings": [ + "@openzeppelin=../node_modules/@openzeppelin", + "@arbitrum=../node_modules/@arbitrum" + ] + }, + { + "filename": "../contracts/tokenbridge/ethereum/gateway/L1ArbitrumGateway.sol", "sourceroot": "..", "solc_remappings": [ "@openzeppelin=../node_modules/@openzeppelin", @@ -22,5 +30,77 @@ "@openzeppelin=../node_modules/@openzeppelin", "@arbitrum=../node_modules/@arbitrum" ] + }, + { + "filename": "../contracts/tokenbridge/ethereum/gateway/L1ERC20Gateway.sol", + "sourceroot": "..", + "solc_remappings": [ + "@openzeppelin=../node_modules/@openzeppelin", + "@arbitrum=../node_modules/@arbitrum" + ] + }, + { + "filename": "../contracts/tokenbridge/ethereum/gateway/L1ForceOnlyReverseCustomGateway.sol", + "sourceroot": "..", + "solc_remappings": [ + "@openzeppelin=../node_modules/@openzeppelin", + "@arbitrum=../node_modules/@arbitrum" + ] + }, + { + "filename": "../contracts/tokenbridge/ethereum/gateway/L1GatewayRouter.sol", + "sourceroot": "..", + "solc_remappings": [ + "@openzeppelin=../node_modules/@openzeppelin", + "@arbitrum=../node_modules/@arbitrum" + ] + }, + { + "filename": "../contracts/tokenbridge/ethereum/gateway/L1OrbitCustomGateway.sol", + "sourceroot": "..", + "solc_remappings": [ + "@openzeppelin=../node_modules/@openzeppelin", + "@arbitrum=../node_modules/@arbitrum" + ] + }, + { + "filename": "../contracts/tokenbridge/ethereum/gateway/L1OrbitERC20Gateway.sol", + "sourceroot": "..", + "solc_remappings": [ + "@openzeppelin=../node_modules/@openzeppelin", + "@arbitrum=../node_modules/@arbitrum" + ] + }, + { + "filename": "../contracts/tokenbridge/ethereum/gateway/L1OrbitGatewayRouter.sol", + "sourceroot": "..", + "solc_remappings": [ + "@openzeppelin=../node_modules/@openzeppelin", + "@arbitrum=../node_modules/@arbitrum" + ] + }, + { + "filename": "../contracts/tokenbridge/ethereum/gateway/L1OrbitReverseCustomGateway.sol", + "sourceroot": "..", + "solc_remappings": [ + "@openzeppelin=../node_modules/@openzeppelin", + "@arbitrum=../node_modules/@arbitrum" + ] + }, + { + "filename": "../contracts/tokenbridge/ethereum/gateway/L1ReverseCustomGateway.sol", + "sourceroot": "..", + "solc_remappings": [ + "@openzeppelin=../node_modules/@openzeppelin", + "@arbitrum=../node_modules/@arbitrum" + ] + }, + { + "filename": "../contracts/tokenbridge/ethereum/gateway/L1WethGateway.sol", + "sourceroot": "..", + "solc_remappings": [ + "@openzeppelin=../node_modules/@openzeppelin", + "@arbitrum=../node_modules/@arbitrum" + ] } ] diff --git a/test-mutation/gambitTester.ts b/test-mutation/gambitTester.ts index a4a372095b..f99fa251d7 100644 --- a/test-mutation/gambitTester.ts +++ b/test-mutation/gambitTester.ts @@ -14,7 +14,6 @@ const TEST_TIMES = [ 'test-foundry', ] const MAX_TASKS = os.cpus().length - 1 -const TASK_TIMEOUT = 3 * 60 * 1000 // 3min const execAsync = promisify(exec) const symlink = promisify(fs.symlink) @@ -35,7 +34,6 @@ interface TestResult { enum MutantStatus { KILLED = 'KILLED', SURVIVED = 'SURVIVED', - TIMEOUT = 'TIMEOUT', } runMutationTesting().catch(error => { @@ -60,7 +58,9 @@ async function runMutationTesting() { // Print time testing took const endTime = Date.now() - console.log(`\n====== Done in ${(endTime - startTime) / (60 * 1000)} min`) + console.log( + `\n====== Done in ${((endTime - startTime) / (60 * 1000)).toFixed(2)} min` + ) } async function _generateMutants(): Promise { @@ -121,23 +121,13 @@ async function _testMutant(mutant: Mutant): Promise { // Re-build and test let mutantStatus: MutantStatus try { - await Promise.race([ - (async () => { - await execAsync(`forge build --root ${testDirectory}`) - await execAsync(`forge test --root ${testDirectory}`) - mutantStatus = MutantStatus.SURVIVED - })(), - new Promise((_, reject) => - setTimeout(() => reject(new Error('Timeout')), TASK_TIMEOUT) - ), - ]) + await execAsync(`forge build --root ${testDirectory}`) + await execAsync( + `forge test --fail-fast --gas-limit 30000000 --root ${testDirectory}` + ) + mutantStatus = MutantStatus.SURVIVED } catch (error) { - if (error instanceof Error) { - mutantStatus = - error.message === 'Timeout' ? MutantStatus.TIMEOUT : MutantStatus.KILLED - } else { - mutantStatus = MutantStatus.KILLED - } + mutantStatus = MutantStatus.KILLED } // delete test folder @@ -158,7 +148,6 @@ function _printResults(results: TestResult[]) { let lastFileName = '' let killedCount = 0 let survivedCount = 0 - let timeoutCount = 0 /// print table and count stats results.forEach(result => { @@ -176,8 +165,6 @@ function _printResults(results: TestResult[]) { killedCount++ } else if (result.status === MutantStatus.SURVIVED) { survivedCount++ - } else { - timeoutCount++ } })