Skip to content

Commit

Permalink
Merge pull request #597 from johnmaia/feature/lite-coin
Browse files Browse the repository at this point in the history
Add litecoinAddress generator
  • Loading branch information
Marak authored Jun 11, 2020
2 parents 4635e5a + 0326dda commit 3388dbf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/finance.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,22 @@ var Finance = function (faker) {
return address;
}

/**
* litecoinAddress
*
* @method faker.finance.litecoinAddress
*/
self.litecoinAddress = function () {
var addressLength = faker.random.number({ min: 26, max: 33 });

var address = faker.random.arrayElement(['L', 'M', '3']);

for (var i = 0; i < addressLength - 1; i++)
address += faker.random.arrayElement('123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'.split(''));

return address;
}

/**
* Credit card number
* @method faker.finance.creditCardNumber
Expand Down
8 changes: 8 additions & 0 deletions test/finance.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,14 @@ describe('finance.js', function () {
});
});

describe("litecoinAddress()", function(){
it("returns a random litecoin address", function(){
var litecoinAddress = faker.finance.litecoinAddress();

assert.ok(litecoinAddress.match(/^[LM3][a-km-zA-HJ-NP-Z1-9]{26,33}$/));
});
});

describe("ethereumAddress()", function(){
it("returns a random ethereum address", function(){
var ethereumAddress = faker.finance.ethereumAddress();
Expand Down

0 comments on commit 3388dbf

Please sign in to comment.