aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-cov/src
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-03-22 02:24:54 +0800
committerFabio Berger <me@fabioberger.com>2018-03-22 02:24:54 +0800
commitec219fc3959cb4721a559472a872598f8dbee719 (patch)
tree487caf6301914144991b2f5a7a504205b7318082 /packages/sol-cov/src
parenta555a8a374743c4e4be3647110e664dd3d799432 (diff)
downloaddexon-sol-tools-ec219fc3959cb4721a559472a872598f8dbee719.tar
dexon-sol-tools-ec219fc3959cb4721a559472a872598f8dbee719.tar.gz
dexon-sol-tools-ec219fc3959cb4721a559472a872598f8dbee719.tar.bz2
dexon-sol-tools-ec219fc3959cb4721a559472a872598f8dbee719.tar.lz
dexon-sol-tools-ec219fc3959cb4721a559472a872598f8dbee719.tar.xz
dexon-sol-tools-ec219fc3959cb4721a559472a872598f8dbee719.tar.zst
dexon-sol-tools-ec219fc3959cb4721a559472a872598f8dbee719.zip
Add comments to sol-cov
Diffstat (limited to 'packages/sol-cov/src')
-rw-r--r--packages/sol-cov/src/coverage_subprovider.ts27
1 files changed, 18 insertions, 9 deletions
diff --git a/packages/sol-cov/src/coverage_subprovider.ts b/packages/sol-cov/src/coverage_subprovider.ts
index bc59d5ef8..1d3f263b0 100644
--- a/packages/sol-cov/src/coverage_subprovider.ts
+++ b/packages/sol-cov/src/coverage_subprovider.ts
@@ -12,18 +12,25 @@ interface MaybeFakeTxData extends Web3.TxData {
isFakeTransaction?: boolean;
}
-/*
- * This class implements the web3-provider-engine subprovider interface and collects traces of all transactions that were sent and all calls that were executed.
- * Because there is no notion of call trace in the rpc - we collect them in rather non-obvious/hacky way.
+/**
+ * This class implements the [web3-provider-engine](https://github.com/MetaMask/provider-engine) subprovider interface.
+ * It collects traces of all transactions that were sent and all calls that were executed through JSON RPC.
+ * Because there is no notion of a call trace in the Ethereum rpc - we collect them in a rather non-obvious/hacky way.
* On each call - we create a snapshot, execute the call as a transaction, get the trace, revert the snapshot.
- * That allows us to not influence the test behaviour.
- * Source: https://github.com/MetaMask/provider-engine/blob/master/subproviders/subprovider.js
+ * That allows us to avoid influencing test behaviour.
*/
export class CoverageSubprovider extends Subprovider {
// Lock is used to not accept normal transactions while doing call/snapshot magic because they'll be reverted later otherwise
private _lock: Lock;
private _coverageManager: CoverageManager;
private _defaultFromAddress: string;
+ /**
+ * Instantiates a CoverageSubprovider
+ * @param artifactsPath Path to the smart contract artifacts
+ * @param sourcePath Path to the smart contract source files
+ * @param networkId network id
+ * @param defaultFromAddress default from address to use when sending transactions
+ */
constructor(artifactsPath: string, sourcesPath: string, networkId: number, defaultFromAddress: string) {
super();
this._lock = new Lock();
@@ -35,7 +42,12 @@ export class CoverageSubprovider extends Subprovider {
this._getContractCodeAsync.bind(this),
);
}
- public handleRequest(payload: Web3.JSONRPCRequestPayload, next: NextCallback, end: ErrorCallback) {
+ public async writeCoverageAsync(): Promise<void> {
+ await this._coverageManager.writeCoverageAsync();
+ }
+ // This method must conform to the web3-provider-engine interface
+ // tslint:disable-next-line:prefer-function-over-method underscore-private-and-protected
+ private handleRequest(payload: Web3.JSONRPCRequestPayload, next: NextCallback, end: ErrorCallback) {
switch (payload.method) {
case 'eth_sendTransaction':
const txData = payload.params[0];
@@ -53,9 +65,6 @@ export class CoverageSubprovider extends Subprovider {
return;
}
}
- public async writeCoverageAsync(): Promise<void> {
- await this._coverageManager.writeCoverageAsync();
- }
private async _onTransactionSentAsync(
txData: MaybeFakeTxData,
err: Error | null,