'use strict'; // inspired in bitcoin core test: // https://github.com/bitcoin/bitcoin/blob/7d49a9173ab636d118c2a81fc3c3562192e7813a/src/test/sighash_tests.cpp var chai = chai || require('chai'); var should = chai.should(); var bitcore = bitcore || require('../bitcore'); var Transaction = bitcore.Transaction; var Script = bitcore.Script; var Opcode = bitcore.Opcode; var randInt = function(low, high) { return Math.floor(Math.random() * (high - low + 1) + low); }; var randUIntN = function(nBits) { return randInt(0, Math.pow(2, nBits)); }; var randUInt32 = function() { return randUIntN(32); }; var randBool = function() { return Math.random() < 0.5; }; var hexAlphabet = '0123456789abcdef'; var randHex = function() { return hexAlphabet[randInt(0, 15)]; }; var randHexN = function(n) { var s = ''; while (n--) { s += randHex(); } return s; }; var randTxHash = function() { return randHexN(64); }; var randPick = function(list) { return list[randInt(0, list.length-1)]; }; var opList = Opcode.asList(); var randomScript = function() { var s = new Script(); var ops = randInt(0,10); for (var i=0; i