Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Commit

Permalink
Merge pull request #245 from renuzit/wrap-vars-in-before
Browse files Browse the repository at this point in the history
Wrap mocha test vars in before()
  • Loading branch information
matiu authored Nov 30, 2018
2 parents 4157261 + 5cb8c32 commit 8bb520d
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 36 deletions.
41 changes: 27 additions & 14 deletions test/block/block.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 27 additions & 16 deletions test/block/blockheader.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,34 @@ var dataRawId = '000000000b99b16390660d79fcc138d2ad0c89a0d044c4201a02bdf1f61ffa1
var data = require('../data/blk86756-testnet');

describe('BlockHeader', function() {

var version = data.version;
var prevblockidbuf = new Buffer(data.prevblockidhex, 'hex');
var merklerootbuf = new Buffer(data.merkleroothex, 'hex');
var time = data.time;
var bits = data.bits;
var nonce = data.nonce;
var bh = new BlockHeader({
version: version,
prevHash: prevblockidbuf,
merkleRoot: merklerootbuf,
time: time,
bits: bits,
nonce: nonce
var version;
var prevblockidbuf;
var merklerootbuf;
var time;
var bits;
var nonce;
var bh;
var bhhex;
var bhbuf;

before(function () {
version = data.version;
prevblockidbuf = new Buffer(data.prevblockidhex, 'hex');
merklerootbuf = new Buffer(data.merkleroothex, 'hex');
time = data.time;
bits = data.bits;
nonce = data.nonce;
bh = new BlockHeader({
version: version,
prevHash: prevblockidbuf,
merkleRoot: merklerootbuf,
time: time,
bits: bits,
nonce: nonce
});
bhhex = data.blockheaderhex;
bhbuf = new Buffer(bhhex, 'hex');
});
var bhhex = data.blockheaderhex;
var bhbuf = new Buffer(bhhex, 'hex');

it('should make a new blockheader', function() {
BlockHeader(bhbuf).toBuffer().toString('hex').should.equal(bhhex);
Expand Down
18 changes: 12 additions & 6 deletions test/block/merkleblock.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,17 @@ var transactionVector = require('../data/tx_creation');


describe('MerkleBlock', function() {
var blockhex = data.HEX[0];
var blockbuf = new Buffer(blockhex,'hex');
var blockJSON = JSON.stringify(data.JSON[0]);
var blockObject = JSON.parse(JSON.stringify(data.JSON[0]));
var blockhex;
var blockbuf;
var blockJSON;
var blockObject;

before(function() {
blockhex = data.HEX[0];
blockbuf = new Buffer(blockhex,'hex');
blockJSON = JSON.stringify(data.JSON[0]);
blockObject = JSON.parse(JSON.stringify(data.JSON[0]));
});

describe('#constructor', function() {
it('should make a new merkleblock from buffer', function() {
Expand Down Expand Up @@ -155,7 +162,7 @@ describe('MerkleBlock', function() {
describe('#filterdTxsHash', function() {

it('should validate good merkleblocks', function() {
var hashOfFilteredTx = '6f64fd5aa9dd01f74c03656d376625cf80328d83d9afebe60cc68b8f0e245bd9'
var hashOfFilteredTx = '6f64fd5aa9dd01f74c03656d376625cf80328d83d9afebe60cc68b8f0e245bd9'
var b = MerkleBlock(data.JSON[3]);
b.filterdTxsHash()[0].should.equal(hashOfFilteredTx);
});
Expand Down Expand Up @@ -227,4 +234,3 @@ describe('MerkleBlock', function() {
});

});

0 comments on commit 8bb520d

Please sign in to comment.