Add unit test for generateWallet and reorganize API files

This commit is contained in:
Chris Clark
2015-06-24 16:41:46 -07:00
parent 81a9bc0739
commit 2446e2f6da
15 changed files with 332 additions and 465 deletions

View File

@@ -25,6 +25,7 @@ const transactionResponse = require('./fixtures/transaction-response');
const accountTransactionsResponse =
require('./fixtures/account-transactions-response');
const trustlinesResponse = require('./fixtures/trustlines-response');
const walletResponse = require('./fixtures/wallet.json');
function checkResult(expected, done, error, response) {
if (error) {
@@ -117,4 +118,10 @@ describe('RippleAPI', function() {
this.api.getTrustlines(address, options,
_.partial(checkResult, trustlinesResponse, done));
});
it('generateWallet', function() {
withDeterministicPRNG(() => {
assert.deepEqual(this.api.generateWallet(), walletResponse);
});
});
});

4
test/fixtures/wallet.json vendored Normal file
View File

@@ -0,0 +1,4 @@
{
"address": "ra2d1wnhDFyZGFz62wT3GSRhAEjpLuqfnj",
"secret": "ss4JedFMSQJa4mHQz3VZ58ZG4TYWg"
}

View File

@@ -12,6 +12,10 @@ function MockPRNG(seed) {
this.seed = seed || SEED;
}
/* eslint-disable no-unused-vars */
MockPRNG.prototype.addEntropy = function(data, estimatedEntropy, source) {};
/* eslint-enable no-unused-vars */
MockPRNG.prototype.randomWord = function() {
const i = this.position;
this.position = (i + 8) % this.seed.length;