bitpay / bitcore-lib

A pure and powerful JavaScript Bitcoin library
https://bitcore.io/
Other
611 stars 1.03k forks source link

Wrap mocha test vars in before() #245

Closed renuzit closed 5 years ago

renuzit commented 5 years ago

All test variables should be initialized in a before() block. Initializing variables outside of the mocha framework can lead to unintended consequences and many hours lost debugging.

For now, this commit only takes the block tests and initializes the variables in a way that mocha likes.

Before Example:

buffer.js:977
    throw new RangeError('Index out of range');
    ^

RangeError: Index out of range

After Example:

bitcore-lib/lib/address.js:196
    throw new TypeError('Address buffers must be exactly 22 bytes.');
    ^

TypeError: Address buffers must be exactly 22 bytes.
renuzit commented 5 years ago

@matiu Let me know how I can help out! I found several other places where this maybe an issue as well.

matiu commented 5 years ago

Thanks. Definitely yes! Keep the PR coming.

On Sat, Dec 1, 2018, 4:28 AM renuzit <notifications@github.com wrote:

@matiu https://github.com/matiu Let me know how I can help out! I found several other places where this maybe an issue as well.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/bitpay/bitcore-lib/pull/245#issuecomment-443406773, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGCHNBaaan6k3Y4hHkRCdmPbQ1CTlgnks5u0i-wgaJpZM4VGWoG .