diff --git a/test/provider.js b/test/accountParser.js similarity index 64% rename from test/provider.js rename to test/accountParser.js index 1fc0ebbf4..f6e6e79d6 100644 --- a/test/provider.js +++ b/test/accountParser.js @@ -1,44 +1,34 @@ -/*global describe, it, before*/ +/*global describe, it*/ const assert = require('assert'); const sinon = require('sinon'); -const Provider = require('../lib/contracts/provider'); +const AccountParser = require('../lib/contracts/accountParser'); let TestLogger = require('../lib/tests/test_logger.js'); -describe('embark.provider', function () { +describe('embark.AccountParser', function () { describe('#getAccount', function () { - let provider; - - before(() => { - const web3 = { - eth: { - accounts: { - privateKeyToAccount: sinon.stub().callsFake((key) => { - return {key}; - }) - } + const web3 = { + eth: { + accounts: { + privateKeyToAccount: sinon.stub().callsFake((key) => { + return {key}; + }) } - }; - - provider = new Provider({ - accountsConfig: [], - logger: new TestLogger({}), - web3Endpoint: 'http:localhost:555', - web3 - }); - }); + } + }; + const testLogger = new TestLogger({}); it('should return one account with the key', function () { - const account = provider.getAccount({ + const account = AccountParser.getAccount({ privateKey: 'myKey' - }); + }, web3, testLogger); assert.deepEqual(account, {key: '0xmyKey'}); }); it('should return two accounts from the keys in the file', function () { - const account = provider.getAccount({ + const account = AccountParser.getAccount({ privateKeyFile: 'test/keyFiles/twoKeys' - }); + }, web3, testLogger); assert.deepEqual(account, [ {key: '0xkey1'}, @@ -47,20 +37,19 @@ describe('embark.provider', function () { }); it('should return one account from the mnemonic', function () { - const account = provider.getAccount({ + const account = AccountParser.getAccount({ mnemonic: 'example exile argue silk regular smile grass bomb merge arm assist farm' - }); - + }, web3, testLogger); assert.deepEqual(account, [{key: "0xf942d5d524ec07158df4354402bfba8d928c99d0ab34d0799a6158d56156d986"}]); }); it('should return two accounts from the mnemonic using numAddresses', function () { - const account = provider.getAccount({ + const account = AccountParser.getAccount({ mnemonic: 'example exile argue silk regular smile grass bomb merge arm assist farm', numAddresses: 2 - }); + }, web3, testLogger); assert.deepEqual(account, [ @@ -70,9 +59,9 @@ describe('embark.provider', function () { }); it('should return nothing with bad config', function () { - const account = provider.getAccount({ + const account = AccountParser.getAccount({ badConfig: 'not working' - }); + }, web3, testLogger); assert.strictEqual(account, null); });