Skip to content

Commit

Permalink
Fix trufflesuite#365: Event logging on test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
Mason Fischer committed Mar 11, 2017
1 parent 2ff5f1a commit e766a25
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion lib/testing/testrunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ var Migrate = require("truffle-migrate");
var TestResolver = require("./testresolver");
var TestSource = require("./testsource");
var expect = require("truffle-expect");
var contract = require("truffle-contract");
var SolidityCoder = require("web3/lib/solidity/coder.js");
var path = require("path");
var _ = require("lodash");
var Promise = require("bluebird");
var fs = Promise.promisifyAll(require("fs"));


function TestRunner(options) {
options = options || {};
Expand Down Expand Up @@ -42,7 +49,32 @@ TestRunner.prototype.initialize = function(callback) {
var afterStateReset = function(err) {
if (err) return callback(err);

callback();
fs.readdirAsync(self.config.contracts_build_directory).then(function (files) {
return _.filter(files, function(file) {
return path.extname(file) === ".json"
});
})
.then(function(files) {
return files.map(function(file){
return fs.readFileAsync(path.join(self.config.contracts_build_directory, file), "utf8");
})
}).then(_.flatten)
.then(Promise.all)
.then(function(files){
var contracts = files.map(JSON.parse).map(contract);
var abis = _.flatMap(contracts, "abi");

abis.map(function(abi) {
if (abi.type == "event") {
var signature = abi.name + "(" + _.map(abi.inputs, "type").join(",") + ")";
self.known_events[web3.sha3(signature)] = {
signature: signature,
abi_entry: abi
};
}
});
callback();
})

//self.known_events = {};

Expand Down

0 comments on commit e766a25

Please sign in to comment.