Skip to content

Commit

Permalink
Introduce new environment tests
Browse files Browse the repository at this point in the history
  • Loading branch information
martindale committed Feb 8, 2024
1 parent d20c589 commit 647203e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
4 changes: 4 additions & 0 deletions constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const BITCOIN_GENESIS = '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b
const BITCOIN_GENESIS_ROOT = '4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b';
const FABRIC_KEY_DERIVATION_PATH = "m/44'/7777'/0'/0/0";
const FIXTURE_SEED = 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about';
const FIXTURE_XPUB = 'xpub661MyMwAqRbcF6GygV6Q6XAg8dqhPvDuhYHGniequi6HMbYhNNH5XC13Np3qRANHVD2mmnNGtMGBfDT69s2ovpHLr7q8syoAuyWqtRGEsYQ';
const FIXTURE_XPRV = 'xprv9s21ZrQH143K2cCWaTZPjPDwac1CzTW4LKMfzLFEMNZJUoDYppxpyPgZXY7CZkjefGJTrTyqKnMrM4RG6nGn7Q9cwjHggCtn3CdFGJahaWY';

// Message Constants
const MAGIC_BYTES = 0xC0D3F33D;
Expand Down Expand Up @@ -126,6 +128,8 @@ module.exports = {
FABRIC_KEY_DERIVATION_PATH,
FABRIC_USER_AGENT,
FIXTURE_SEED,
FIXTURE_XPUB,
FIXTURE_XPRV,
HEADER_SIZE,
GENERIC_MESSAGE_TYPE,
LOG_MESSAGE_TYPE,
Expand Down
37 changes: 33 additions & 4 deletions tests/fabric.environment.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
'use strict';

// Constants
const {
FIXTURE_SEED,
FIXTURE_XPUB,
FIXTURE_XPRV
} = require('../constants');

// Dependencies
const assert = require('assert');

Expand All @@ -20,6 +27,27 @@ describe('@fabric/core/types/environment', function () {
assert.ok(environment);
});

it('can instantiate from a seed', async function () {
const environment = new Environment({ xpub: FIXTURE_SEED });
await environment.start();
await environment.stop()
assert.ok(environment);
});

it('can instantiate from an xpub', async function () {
const environment = new Environment({ xpub: FIXTURE_XPUB });
await environment.start();
await environment.stop()
assert.ok(environment);
});

it('can instantiate from an xprv', async function () {
const environment = new Environment({ xprv: FIXTURE_XPRV });
await environment.start();
await environment.stop()
assert.ok(environment);
});

it('can read an environment variable', async function () {
const environment = new Environment();
const home = environment.readVariable('HOME');
Expand All @@ -44,16 +72,13 @@ describe('@fabric/core/types/environment', function () {
});

environment.setWallet(wallet);

assert.ok(environment);

environment.destroyWallet();
});

it('can check for store', async function () {
const environment = new Environment();
const exists = environment.storeExists();

assert.ok(environment);
assert.equal(typeof exists, 'boolean');
});
Expand All @@ -68,9 +93,13 @@ describe('@fabric/core/types/environment', function () {

it('can touch the wallet', async function () {
const environment = new Environment();

environment.touchWallet();
assert.ok(environment);
});

it('can load the wallet', async function () {
const environment = new Environment();
environment.loadWallet();
assert.ok(environment);
});
});
Expand Down
1 change: 0 additions & 1 deletion types/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class Service extends Actor {
* @param {Boolean} [settings.networking=true] Whether or not to connect to the network.
* @param {Object} [settings.frequency] Interval frequency in hertz.
* @param {Object} [settings.state] Initial state to assign.
* @param {Object} [settings.@data] Internal data to assign.
*/
constructor (settings = {}) {
// Initialize Scribe, our logging tool
Expand Down

0 comments on commit 647203e

Please sign in to comment.