From dc956020ef7c6d3f1880263700422b31253c8da3 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Tue, 3 Jul 2018 12:55:05 -0700 Subject: Move NodeType caching out of web3-wrapper and into our internal code --- packages/contracts/test/utils/assertions.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'packages/contracts/test') diff --git a/packages/contracts/test/utils/assertions.ts b/packages/contracts/test/utils/assertions.ts index c8031c8a1..112a470f6 100644 --- a/packages/contracts/test/utils/assertions.ts +++ b/packages/contracts/test/utils/assertions.ts @@ -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; async function _getGanacheOrGethError(ganacheError: string, gethError: string): Promise { - 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); -- cgit v1.2.3