blockchain-wallet-ts
Version:
TypeScript wrapper for Blockchain.info's wallet API
53 lines (52 loc) • 2.77 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const BlockchainApi_1 = __importDefault(require("./BlockchainApi"));
const LocalConfig_1 = __importDefault(require("./Interfaces/LocalConfig"));
const BlockchainHDWallet_1 = __importDefault(require("./BlockchainHDWallet"));
describe('BlockchainWallet', () => {
let wallet;
const blockchain = new BlockchainApi_1.default({
apiKey: LocalConfig_1.default.blockchain.apiKey,
apiUrl: LocalConfig_1.default.blockchain.apiUrl,
});
beforeAll(() => __awaiter(void 0, void 0, void 0, function* () {
wallet = yield blockchain.getWallet({
guid: LocalConfig_1.default.wallet.guid,
password: LocalConfig_1.default.wallet.password,
});
}));
test('Can convert wallet to HD wallet', () => __awaiter(void 0, void 0, void 0, function* () {
const wallet = yield blockchain.createWallet({ password: 'some-placeholder-password', hd: false });
yield wallet.enableHD();
}));
test('Can get balance', () => __awaiter(void 0, void 0, void 0, function* () {
const { balance } = yield wallet.balance;
expect(balance).toBeDefined();
expect(balance).toBeGreaterThanOrEqual(0);
}));
test('Can create HD accounts', () => __awaiter(void 0, void 0, void 0, function* () {
const account = yield wallet.createHD();
expect(account).toBeDefined();
expect(account).toBeInstanceOf(BlockchainHDWallet_1.default);
}));
test('Can list HD accounts', () => __awaiter(void 0, void 0, void 0, function* () {
const accounts = yield wallet.accounts;
expect(accounts.length).toBeGreaterThan(0);
}));
test('Can list xPubs', () => __awaiter(void 0, void 0, void 0, function* () {
const xpubs = yield wallet.xpubs;
expect(xpubs.length).toBeGreaterThan(0);
}));
});