Move NodeType caching out of web3-wrapper and into our internal code

This commit is contained in:
Alex Browne
2018-07-03 12:55:05 -07:00
parent ce1542da4f
commit dc956020ef
3 changed files with 19 additions and 12 deletions

View File

@@ -9,12 +9,16 @@ import { web3Wrapper } from './web3_wrapper';
const expect = chai.expect;
let nodeType: NodeType | undefined;
// Represents the return value of a `sendTransaction` call. The Promise should
// resolve with either a transaction receipt or a transaction hash.
export type sendTransactionResult = Promise<TransactionReceipt | TransactionReceiptWithDecodedLogs | string>;
async function _getGanacheOrGethError(ganacheError: string, gethError: string): Promise<string> {
const nodeType = await web3Wrapper.getNodeTypeAsync();
if (_.isUndefined(nodeType)) {
nodeType = await web3Wrapper.getNodeTypeAsync();
}
switch (nodeType) {
case NodeType.Ganache:
return ganacheError;
@@ -68,7 +72,9 @@ export async function expectTransactionFailedAsync(p: sendTransactionResult, rea
_.noop(e);
});
const nodeType = await web3Wrapper.getNodeTypeAsync();
if (_.isUndefined(nodeType)) {
nodeType = await web3Wrapper.getNodeTypeAsync();
}
switch (nodeType) {
case NodeType.Ganache:
return expect(p).to.be.rejectedWith(reason);