mirror of https://github.com/embarklabs/embark.git
feat(@embark/test-runner): make evmMethod globally available + docs
This commit is contained in:
parent
3b753e856c
commit
67581ce482
|
@ -177,6 +177,8 @@ class TestRunner {
|
|||
}
|
||||
};
|
||||
|
||||
global.evmMethod = this.evmMethod.bind(this);
|
||||
|
||||
global.getEvmVersion = async () => {
|
||||
return this.evmMethod('web3_clientVersion');
|
||||
};
|
||||
|
@ -382,6 +384,9 @@ class TestRunner {
|
|||
if (error) {
|
||||
return reject(error);
|
||||
}
|
||||
if (res.error) {
|
||||
return reject(new Error(res.error));
|
||||
}
|
||||
resolve(res.result);
|
||||
}
|
||||
);
|
||||
|
|
|
@ -293,7 +293,7 @@ This function lets you increase the time of the EVM. It is useful in the case wh
|
|||
await increaseTime(amount);
|
||||
```
|
||||
|
||||
`amount`: [Number] Number of seconds to increase
|
||||
- `amount`: [Number] Number of seconds to increase
|
||||
|
||||
```javascript
|
||||
it("should have expired after increasing time", async function () {
|
||||
|
@ -325,6 +325,26 @@ await getEvmVersion();
|
|||
|
||||
Returns a string, eg: `EthereumJS TestRPC/v2.9.2/ethereum-js`
|
||||
|
||||
### evmMethod
|
||||
|
||||
If there are EVM methods that are not supported by the web3 library you use, Embark exposes the global function `evmMethod` that lets you call the RPC method directly.
|
||||
|
||||
#### Syntax
|
||||
`evmMethod(rpcMethodName, parameters)`
|
||||
|
||||
- `rpcMethodName`: [string] Name of the RPC method to call.
|
||||
- `parameters`: [Array<any>] Optional array of parameters, as specified by the RPC method API.
|
||||
|
||||
#### Usage
|
||||
For example, let's say you are using `web3.js` in your tests, but would like to call the `eth_signTypedData` RPC method. Because `web3.js` does not support this method, it won't be possible to use `web3.js` for this call. Instead, we can call the `eth_signTypedData` RPC method in our tests using the global `evmMethod` function:
|
||||
|
||||
```javascript
|
||||
const signature = await evmMethod("eth_signTypedData", [
|
||||
accounts[0],
|
||||
data
|
||||
]);
|
||||
```
|
||||
|
||||
## Code coverage
|
||||
|
||||
Embark allows you to generate a coverage report for your Solidity Smart Contracts by passing the `--coverage` option on the `embark test` command.
|
||||
|
|
Loading…
Reference in New Issue