From 92fa5e0f77ef37735f6de46974a06111f3b22c67 Mon Sep 17 00:00:00 2001 From: cgewecke Date: Tue, 15 Oct 2019 00:08:20 -0700 Subject: [PATCH] Stash --- test/util/integration.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/test/util/integration.js b/test/util/integration.js index 8a50dcc..340eab0 100644 --- a/test/util/integration.js +++ b/test/util/integration.js @@ -1,14 +1,16 @@ /* - Utilities for generating a mock truffle project to test plugin. + Utilities for generating & managing mock projects to test plugins. */ const path = require('path'); const fs = require('fs'); const shell = require('shelljs'); -const TruffleConfig = require('truffle-config'); const decache = require('decache'); +const PluginsTestHelpers = require("@nomiclabs/buidler/plugins-testing") +const TruffleConfig = require('truffle-config'); + const temp = './sc_temp'; const truffleConfigName = 'truffle-config.js'; const buidlerConfigName = 'buidler.config.js'; @@ -49,6 +51,23 @@ function getOutput(truffleConfig){ return JSON.parse(fs.readFileSync(jsonPath, 'utf8')); } +// Buidler env set up / tear down. +function useEnvironment(projectPath) { + let previousCWD; + + beforeEach("Loading buidler environment", function() { + previousCWD = process.cwd(); + process.chdir(projectPath); + process.env.BUIDLER_NETWORK = "develop"; + this.env = require("@nomiclabs/buidler"); + }); + + afterEach("Resetting buidler", function() { + PluginsTestHelpers.resetBuidlerContext(); + process.chdir(previousCWD); + }); +} + // ========================== // Truffle Configuration // ==========================