bitpay/bitcore — pull request #170 by MattFaus (2014-03-19 01:52:39+00:00)
Title: Hook up testdata/tx_valid.json and tx_invalid.json test cases

This pull request hooks up the code to load each of the transactions from `testdata/tx_valid.json` and `testdata/tx_invalid.json`, and perform some rudimentary verifications.

This results in adding 41 new test cases within `test.Transactions.js`, 15 of which fail.

Here is the before and after of `mocha test/test.Transaction.js`:
```
16 passing (329ms)
25 pending
```

```
57 passing (342ms)
15 failing
```

The 15 failures fall into 3 classes, as shown by the stack traces below.

```
Uncaught AssertionError: expected [Error: Non-canonical signature: S value negative] to not exist
at Assertion. (/Users/mattfaus/dev/bitcore/node_modules/chai/lib/chai/core/assertions.js:293:10)
at Assertion.Object.defineProperty.get (/Users/mattfaus/dev/bitcore/node_modules/chai/lib/chai/utils/addProperty.js:35:29)
at Object.should.not.exist (/Users/mattfaus/dev/bitcore/node_modules/chai/lib/chai/interface/should.js:65:37)
at /Users/mattfaus/dev/bitcore/test/test.Transaction.js:318:24
at /Users/mattfaus/dev/bitcore/ScriptInterpreter.js:944:9
at ScriptInterpreter.executeStep (/Users/mattfaus/dev/bitcore/ScriptInterpreter.js:770:7)
at process._tickCallback (node.js:415:13)
```

```
Uncaught AssertionError: expected [Error: OP_EQUALVERIFY negative] to not exist
at Assertion. (/Users/mattfaus/dev/bitcore/node_modules/chai/lib/chai/core/assertions.js:293:10)
at Assertion.Object.defineProperty.get (/Users/mattfaus/dev/bitcore/node_modules/chai/lib/chai/utils/addProperty.js:35:29)
at Object.should.not.exist (/Users/mattfaus/dev/bitcore/node_modules/chai/lib/chai/interface/should.js:65:37)
at /Users/mattfaus/dev/bitcore/test/test.Transaction.js:318:24
at /Users/mattfaus/dev/bitcore/ScriptInterpreter.js:944:9
at ScriptInterpreter.executeStep (/Users/mattfaus/dev/bitcore/ScriptInterpreter.js:770:7)
at process._tickCallback (node.js:415:13)
```

```
Uncaught AssertionError: expected false to equal true
+ expected - actual

+true
-false

at Assertion.assertEqual (/Users/mattfaus/dev/bitcore/node_modules/chai/lib/chai/core/assertions.js:388:12)
at Assertion.ctx.(anonymous function) [as equal] (/Users/mattfaus/dev/bitcore/node_modules/chai/lib/chai/utils/addMethod.js:34:25)
at /Users/mattfaus/dev/bitcore/test/test.Transaction.js:343:66
at /Users/mattfaus/dev/bitcore/ScriptInterpreter.js:956:7
at ScriptInterpreter.executeStep (/Users/mattfaus/dev/bitcore/ScriptInterpreter.js:55:7)
at process._tickCallback (node.js:415:13)
```

One oddity is that running `mocha -R spec test/test.Transaction.js` results in several tests cases throwing this exception, which I do not understand. I think it is a problem with mocha specifically, or how I have implemented the test.

```
RangeError: Invalid array length
at indent (/usr/local/share/npm/lib/node_modules/mocha/lib/reporters/spec.js:32:12)
at Runner. (/usr/local/share/npm/lib/node_modules/mocha/lib/reporters/spec.js:73:17)
at Runner.EventEmitter.emit (events.js:117:20)
at Runner.fail (/usr/local/share/npm/lib/node_modules/mocha/lib/runner.js:200:8)
at /usr/local/share/npm/lib/node_modules/mocha/lib/runner.js:456:16
at Test.Runnable.run (/usr/local/share/npm/lib/node_modules/mocha/lib/runnable.js:225:5)
at Runner.runTest (/usr/local/share/npm/lib/node_modules/mocha/lib/runner.js:374:10)
at /usr/local/share/npm/lib/node_modules/mocha/lib/runner.js:452:12
at next (/usr/local/share/npm/lib/node_modules/mocha/lib/runner.js:299:14)
at /usr/local/share/npm/lib/node_modules/mocha/lib/runner.js:309:7
at next (/usr/local/share/npm/lib/node_modules/mocha/lib/runner.js:247:23)
at Object._onImmediate (/usr/local/share/npm/lib/node_modules/mocha/lib/runner.js:276:5)
at processImmediate [as _immediateCallback] (timers.js:330:15)
```

The total failures with `-R spec` are:
```
57 passing (346ms)
35 failing
```

I will not spend more time on these changes until I hear from @maroz that changes to the underlying libraries to fix these test cases have been resolved, as mentioned in https://github.com/bitpay/bitcore/pull/116. If you would like me to proceed differently, let me know.