TST: RN selftest HD bech32

This commit is contained in:
Overtorment 2019-05-22 13:07:44 +01:00
parent ae50aba6b4
commit 8a89405746
2 changed files with 11 additions and 2 deletions

View file

@ -15,7 +15,6 @@ beforeAll(async () => {
// awaiting for Electrum to be connected. For RN Electrum would naturally connect
// while app starts up, but for tests we need to wait for it
await BlueElectrum.waitTillConnected();
console.log('electrum connected');
});
describe('Bech32 Segwit HD (BIP84)', () => {

View file

@ -2,7 +2,7 @@ import React, { Component } from 'react';
import { ScrollView, View } from 'react-native';
import { BlueLoading, BlueSpacing20, SafeBlueArea, BlueCard, BlueText, BlueNavigationStyle } from '../BlueComponents';
import PropTypes from 'prop-types';
import { SegwitP2SHWallet, LegacyWallet, HDSegwitP2SHWallet } from '../class';
import { SegwitP2SHWallet, LegacyWallet, HDSegwitP2SHWallet, HDSegwitBech32Wallet } from '../class';
let BigNumber = require('bignumber.js');
let encryption = require('../encryption');
let bitcoin = require('bitcoinjs-lib');
@ -262,6 +262,16 @@ export default class Selftest extends Component {
if (hd3.getBalance() !== 26000) throw new Error('Could not fetch HD balance');
await hd3.fetchTransactions();
if (hd3.transactions.length !== 7) throw new Error('Could not fetch HD transactions');
//
let hd4 = new HDSegwitBech32Wallet();
hd4._xpub = 'zpub6r7jhKKm7BAVx3b3nSnuadY1WnshZYkhK8gKFoRLwK9rF3Mzv28BrGcCGA3ugGtawi1WLb2vyjQAX9ZTDGU5gNk2bLdTc3iEXr6tzR1ipNP';
await hd4.fetchBalance();
if (hd4.getBalance() !== 200000) throw new Error('Could not fetch HD Bech32 balance');
await hd4.fetchTransactions();
if (hd4.getTransactions().length !== 4)
throw new Error('Could not fetch HD Bech32 transactions');
} else {
console.warn('skipping RN-specific test');
}