diff options
author | Fabio Berger <me@fabioberger.com> | 2018-06-12 01:54:59 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-06-12 01:54:59 +0800 |
commit | 60f5a52964d6965d35eb3c3cb15abc8471de6fd6 (patch) | |
tree | 3912c687aa7e3eb9891d1f4d5a46d516805a4503 /packages/sol-cov/src/profiler_subprovider.ts | |
parent | 89b7b56a2cb38d95f65067e5493e8135cb1e7e98 (diff) | |
parent | 7e5866ce3fffc67633d3ab84cc3d2a6abdd22ce5 (diff) | |
download | dexon-sol-tools-60f5a52964d6965d35eb3c3cb15abc8471de6fd6.tar dexon-sol-tools-60f5a52964d6965d35eb3c3cb15abc8471de6fd6.tar.gz dexon-sol-tools-60f5a52964d6965d35eb3c3cb15abc8471de6fd6.tar.bz2 dexon-sol-tools-60f5a52964d6965d35eb3c3cb15abc8471de6fd6.tar.lz dexon-sol-tools-60f5a52964d6965d35eb3c3cb15abc8471de6fd6.tar.xz dexon-sol-tools-60f5a52964d6965d35eb3c3cb15abc8471de6fd6.tar.zst dexon-sol-tools-60f5a52964d6965d35eb3c3cb15abc8471de6fd6.zip |
Merge branch 'v2-prototype' into fix/contract-wrappers/exchangeTransferSimulator
* v2-prototype:
Fix a bug in SolCompilerArtifacts adapter config overriding
Increase timeout for contract migrations
Remove some copy-paste code
Await transactions in migrations
Fix typos
Await transactions in migrations
Await fake transactions
Fix a typo
Implement SolidityProfiler & adapt sol-cov to work with Geth
# Conflicts:
# packages/migrations/CHANGELOG.json
Diffstat (limited to 'packages/sol-cov/src/profiler_subprovider.ts')
-rw-r--r-- | packages/sol-cov/src/profiler_subprovider.ts | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/packages/sol-cov/src/profiler_subprovider.ts b/packages/sol-cov/src/profiler_subprovider.ts new file mode 100644 index 000000000..ac878c070 --- /dev/null +++ b/packages/sol-cov/src/profiler_subprovider.ts @@ -0,0 +1,36 @@ +import * as _ from 'lodash'; + +import { AbstractArtifactAdapter } from './artifact_adapters/abstract_artifact_adapter'; +import { ProfilerManager } from './profiler_manager'; +import { TraceCollectionSubprovider } from './trace_collection_subprovider'; + +/** + * This class implements the [web3-provider-engine](https://github.com/MetaMask/provider-engine) subprovider interface. + * ProfilerSubprovider is used to profile Solidity code while running tests. + */ +export class ProfilerSubprovider extends TraceCollectionSubprovider { + private _profilerManager: ProfilerManager; + /** + * Instantiates a ProfilerSubprovider instance + * @param artifactAdapter Adapter for used artifacts format (0x, truffle, giveth, etc.) + * @param defaultFromAddress default from address to use when sending transactions + * @param isVerbose If true, we will log any unknown transactions. Otherwise we will ignore them + */ + constructor(artifactAdapter: AbstractArtifactAdapter, defaultFromAddress: string, isVerbose: boolean = true) { + const traceCollectionSubproviderConfig = { + shouldCollectTransactionTraces: true, + shouldCollectGasEstimateTraces: false, + shouldCollectCallTraces: false, + }; + super(defaultFromAddress, traceCollectionSubproviderConfig); + this._profilerManager = new ProfilerManager(artifactAdapter, isVerbose); + } + /** + * Write the test profiler results to a file in Istanbul format. + */ + public async writeProfilerOutputAsync(): Promise<void> { + const traceInfos = this.getCollectedTraceInfos(); + _.forEach(traceInfos, traceInfo => this._profilerManager.appendTraceInfo(traceInfo)); + await this._profilerManager.writeProfilerOutputAsync(); + } +} |