mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-21 14:34:55 +01:00
TST
This commit is contained in:
parent
3b9e3dbea1
commit
4000519dfc
3 changed files with 52 additions and 49 deletions
49
App.test.js
49
App.test.js
|
@ -1,6 +1,6 @@
|
|||
/* global describe, it, expect, jest, jasmine */
|
||||
import React from 'react';
|
||||
import { WatchOnlyWallet, LegacyWallet, SegwitP2SHWallet, AppStorage } from './class';
|
||||
import { LegacyWallet, SegwitP2SHWallet, AppStorage } from './class';
|
||||
import TestRenderer from 'react-test-renderer';
|
||||
import Settings from './screen/settings/settings';
|
||||
import Selftest from './screen/selftest';
|
||||
|
@ -301,50 +301,3 @@ describe('currency', () => {
|
|||
assert.ok(cur[currency.STRUCT.BTC_USD] > 0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Watch only wallet', () => {
|
||||
it('can fetch balance', async () => {
|
||||
let w = new WatchOnlyWallet();
|
||||
w.setSecret('1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa');
|
||||
await w.fetchBalance();
|
||||
assert.ok(w.getBalance() > 16);
|
||||
});
|
||||
|
||||
it('can fetch tx', async () => {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 60 * 1000;
|
||||
let w = new WatchOnlyWallet();
|
||||
|
||||
w.setSecret('167zK5iZrs1U6piDqubD3FjRqUTM2CZnb8');
|
||||
await w.fetchTransactions();
|
||||
assert.equal(w.getTransactions().length, 233);
|
||||
|
||||
w = new WatchOnlyWallet();
|
||||
w.setSecret('1BiJW1jyUaxcJp2JWwbPLPzB1toPNWTFJV');
|
||||
await w.fetchTransactions();
|
||||
assert.equal(w.getTransactions().length, 2);
|
||||
|
||||
// fetch again and make sure no duplicates
|
||||
await w.fetchTransactions();
|
||||
assert.equal(w.getTransactions().length, 2);
|
||||
});
|
||||
|
||||
it('can fetch complex TXs', async () => {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30 * 1000;
|
||||
let w = new WatchOnlyWallet();
|
||||
w.setSecret('3NLnALo49CFEF4tCRhCvz45ySSfz3UktZC');
|
||||
await w.fetchTransactions();
|
||||
for (let tx of w.getTransactions()) {
|
||||
assert.ok(tx.value, 'incorrect tx.value');
|
||||
}
|
||||
});
|
||||
|
||||
it('can validate address', async () => {
|
||||
let w = new WatchOnlyWallet();
|
||||
w.setSecret('12eQ9m4sgAwTSQoNXkRABKhCXCsjm2jdVG');
|
||||
assert.ok(w.valid());
|
||||
w.setSecret('3BDsBDxDimYgNZzsqszNZobqQq3yeUoJf2');
|
||||
assert.ok(w.valid());
|
||||
w.setSecret('not valid');
|
||||
assert.ok(!w.valid());
|
||||
});
|
||||
});
|
||||
|
|
50
App2.test.js
50
App2.test.js
|
@ -1,4 +1,5 @@
|
|||
/* global it, jasmine */
|
||||
/* global it, describe, jasmine */
|
||||
import { WatchOnlyWallet } from './class';
|
||||
let assert = require('assert');
|
||||
|
||||
it('bip38 decodes', async () => {
|
||||
|
@ -30,3 +31,50 @@ it('bip38 decodes slow', async () => {
|
|||
|
||||
assert.equal(wif.encode(0x80, decryptedKey.privateKey, decryptedKey.compressed), 'KxqRtpd9vFju297ACPKHrGkgXuberTveZPXbRDiQ3MXZycSQYtjc');
|
||||
});
|
||||
|
||||
describe('Watch only wallet', () => {
|
||||
it('can fetch balance', async () => {
|
||||
let w = new WatchOnlyWallet();
|
||||
w.setSecret('1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa');
|
||||
await w.fetchBalance();
|
||||
assert.ok(w.getBalance() > 16);
|
||||
});
|
||||
|
||||
it('can fetch tx', async () => {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 150 * 1000;
|
||||
let w = new WatchOnlyWallet();
|
||||
|
||||
w.setSecret('167zK5iZrs1U6piDqubD3FjRqUTM2CZnb8');
|
||||
await w.fetchTransactions();
|
||||
assert.equal(w.getTransactions().length, 233);
|
||||
|
||||
w = new WatchOnlyWallet();
|
||||
w.setSecret('1BiJW1jyUaxcJp2JWwbPLPzB1toPNWTFJV');
|
||||
await w.fetchTransactions();
|
||||
assert.equal(w.getTransactions().length, 2);
|
||||
|
||||
// fetch again and make sure no duplicates
|
||||
await w.fetchTransactions();
|
||||
assert.equal(w.getTransactions().length, 2);
|
||||
});
|
||||
|
||||
it('can fetch complex TXs', async () => {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 120 * 1000;
|
||||
let w = new WatchOnlyWallet();
|
||||
w.setSecret('3NLnALo49CFEF4tCRhCvz45ySSfz3UktZC');
|
||||
await w.fetchTransactions();
|
||||
for (let tx of w.getTransactions()) {
|
||||
assert.ok(tx.value, 'incorrect tx.value');
|
||||
}
|
||||
});
|
||||
|
||||
it('can validate address', async () => {
|
||||
let w = new WatchOnlyWallet();
|
||||
w.setSecret('12eQ9m4sgAwTSQoNXkRABKhCXCsjm2jdVG');
|
||||
assert.ok(w.valid());
|
||||
w.setSecret('3BDsBDxDimYgNZzsqszNZobqQq3yeUoJf2');
|
||||
assert.ok(w.valid());
|
||||
w.setSecret('not valid');
|
||||
assert.ok(!w.valid());
|
||||
});
|
||||
});
|
||||
|
|
|
@ -302,6 +302,7 @@ export class LegacyWallet extends AbstractWallet {
|
|||
});
|
||||
|
||||
do {
|
||||
await (() => new Promise(resolve => setTimeout(resolve, 1000)))();
|
||||
nextOutputs = nextOutputs.replace(baseURI, '');
|
||||
|
||||
let response = await api.get(nextOutputs + ((useBlockcypherTokens && '&token=' + this.getRandomBlockcypherToken()) || ''));
|
||||
|
@ -330,6 +331,7 @@ export class LegacyWallet extends AbstractWallet {
|
|||
});
|
||||
|
||||
do {
|
||||
await (() => new Promise(resolve => setTimeout(resolve, 1000)))();
|
||||
nextInputs = nextInputs.replace(baseURI, '');
|
||||
|
||||
let response = await api.get(nextInputs + ((useBlockcypherTokens && '&token=' + this.getRandomBlockcypherToken()) || ''));
|
||||
|
|
Loading…
Add table
Reference in a new issue