diff --git a/lib/workers/child-browser.js b/lib/workers/child-browser.js index efb9a01b..86bded97 100644 --- a/lib/workers/child-browser.js +++ b/lib/workers/child-browser.js @@ -4,6 +4,8 @@ * https://github.com/bcoin-org/bcoin */ +/* global register */ + 'use strict'; const assert = require('bsert'); @@ -46,6 +48,9 @@ class Child extends EventEmitter { */ init(file) { + if (process.env.BMOCHA) + register(file, [__dirname, file]); + this.child = new global.Worker(file); this.child.onerror = (event) => { diff --git a/test/chain-test.js b/test/chain-test.js index 59161662..59e79a31 100644 --- a/test/chain-test.js +++ b/test/chain-test.js @@ -111,7 +111,7 @@ chain.on('disconnect', (entry, block) => { }); describe('Chain', function() { - this.timeout(60000); + this.timeout(process.browser ? 1200000 : 60000); it('should open chain and miner', async () => { await chain.open(); @@ -649,6 +649,9 @@ describe('Chain', function() { assert(await chain.add(block)); }); + if (process.browser) + return; + it('should mine fail to connect too much weight', async () => { const start = chain.height - 2000; const end = chain.height - 200; diff --git a/test/http-test.js b/test/http-test.js index 1f9d0471..810cb6d6 100644 --- a/test/http-test.js +++ b/test/http-test.js @@ -14,6 +14,9 @@ const pkg = require('../lib/pkg'); const Network = require('../lib/protocol/network'); const network = Network.get('regtest'); +if (process.browser) + return; + const node = new FullNode({ network: 'regtest', apiKey: 'foo', diff --git a/test/node-test.js b/test/node-test.js index 6106dc79..a5ab9579 100644 --- a/test/node-test.js +++ b/test/node-test.js @@ -85,7 +85,10 @@ async function mineCSV(fund) { } describe('Node', function() { - this.timeout(5000); + this.timeout(process.browser ? 20000 : 5000); + + if (process.browser) + return; it('should open chain and miner', async () => { miner.mempool = null; diff --git a/test/script-test.js b/test/script-test.js index 38bbcd88..03f40ac1 100644 --- a/test/script-test.js +++ b/test/script-test.js @@ -103,7 +103,7 @@ describe('Script', function() { input.execute(stack); output.execute(stack); - assert.deepEqual(stack.items, [[1], [3], [5]]); + assert.deepEqual(stack.items, [[1], [3], [5]].map(a => Buffer.from(a))); } { @@ -128,7 +128,7 @@ describe('Script', function() { input.execute(stack); output.execute(stack); - assert.deepEqual(stack.items, [[1], [4], [5]]); + assert.deepEqual(stack.items, [[1], [4], [5]].map(a => Buffer.from(a))); } { @@ -151,7 +151,7 @@ describe('Script', function() { input.execute(stack); output.execute(stack); - assert.deepEqual(stack.items, [[1], [3], [5]]); + assert.deepEqual(stack.items, [[1], [3], [5]].map(a => Buffer.from(a))); } { @@ -174,7 +174,7 @@ describe('Script', function() { input.execute(stack); output.execute(stack); - assert.deepEqual(stack.items, [[1], [5]]); + assert.deepEqual(stack.items, [[1], [5]].map(a => Buffer.from(a))); } { @@ -197,7 +197,7 @@ describe('Script', function() { input.execute(stack); output.execute(stack); - assert.deepEqual(stack.items, [[1], [3], [5]]); + assert.deepEqual(stack.items, [[1], [3], [5]].map(a => Buffer.from(a))); } }); diff --git a/test/utils-test.js b/test/utils-test.js index fe03257b..8c9cce8e 100644 --- a/test/utils-test.js +++ b/test/utils-test.js @@ -106,54 +106,54 @@ describe('Utils', function() { let b = Buffer.alloc(1, 0xff); encoding.writeVarint2(b, 0, 0); assert.strictEqual(encoding.readVarint2(b, 0).value, 0); - assert.deepEqual(b, [0]); + assert.strictEqual(b.toString('hex'), '00'); b = Buffer.alloc(1, 0xff); encoding.writeVarint2(b, 1, 0); assert.strictEqual(encoding.readVarint2(b, 0).value, 1); - assert.deepEqual(b, [1]); + assert.strictEqual(b.toString('hex'), '01'); b = Buffer.alloc(1, 0xff); encoding.writeVarint2(b, 127, 0); assert.strictEqual(encoding.readVarint2(b, 0).value, 127); - assert.deepEqual(b, [0x7f]); + assert.strictEqual(b.toString('hex'), '7f'); b = Buffer.alloc(2, 0xff); encoding.writeVarint2(b, 128, 0); assert.strictEqual(encoding.readVarint2(b, 0).value, 128); - assert.deepEqual(b, [0x80, 0x00]); + assert.strictEqual(b.toString('hex'), '8000'); b = Buffer.alloc(2, 0xff); encoding.writeVarint2(b, 255, 0); assert.strictEqual(encoding.readVarint2(b, 0).value, 255); - assert.deepEqual(b, [0x80, 0x7f]); + assert.strictEqual(b.toString('hex'), '807f'); b = Buffer.alloc(2, 0xff); encoding.writeVarint2(b, 16383, 0); assert.strictEqual(encoding.readVarint2(b, 0).value, 16383); - assert.deepEqual(b, [0xfe, 0x7f]); + assert.strictEqual(b.toString('hex'), 'fe7f'); b = Buffer.alloc(2, 0xff); encoding.writeVarint2(b, 16384, 0); assert.strictEqual(encoding.readVarint2(b, 0).value, 16384); - assert.deepEqual(b, [0xff, 0x00]); + assert.strictEqual(b.toString('hex'), 'ff00'); b = Buffer.alloc(3, 0xff); encoding.writeVarint2(b, 16511, 0); assert.strictEqual(encoding.readVarint2(b, 0).value, 16511); - assert.deepEqual(b.slice(0, 2), [0xff, 0x7f]); - // assert.deepEqual(b, [0x80, 0xff, 0x7f]); + assert.strictEqual(b.slice(0, 2).toString('hex'), 'ff7f'); + // assert.strictEqual(b.toString('hex'), '80ff7f'); b = Buffer.alloc(3, 0xff); encoding.writeVarint2(b, 65535, 0); assert.strictEqual(encoding.readVarint2(b, 0).value, 65535); - assert.deepEqual(b, [0x82, 0xfe, 0x7f]); - // assert.deepEqual(b, [0x82, 0xfd, 0x7f]); + assert.strictEqual(b.toString('hex'), '82fe7f'); + // assert.strictEqual(b.toString('hex'), '82fd7f'); b = Buffer.alloc(5, 0xff); encoding.writeVarint2(b, Math.pow(2, 32), 0); assert.strictEqual(encoding.readVarint2(b, 0).value, Math.pow(2, 32)); - assert.deepEqual(b, [0x8e, 0xfe, 0xfe, 0xff, 0x00]); + assert.strictEqual(b.toString('hex'), '8efefeff00'); }); it('should validate integers 0 and 1 as booleans', () => { diff --git a/test/wallet-test.js b/test/wallet-test.js index e48305df..035ecf5a 100644 --- a/test/wallet-test.js +++ b/test/wallet-test.js @@ -226,7 +226,7 @@ async function testP2SH(witness, nesting) { } describe('Wallet', function() { - this.timeout(5000); + this.timeout(process.browser ? 20000 : 5000); before(async () => { await wdb.open();