diff options
| author | Gokulnath Reddy <[email protected]> | 2017-06-19 22:43:15 +1000 |
|---|---|---|
| committer | Gokulnath Reddy <[email protected]> | 2017-06-19 22:43:49 +1000 |
| commit | 97a479b62e02764befaf3ba27a2abcb80216b8bd (patch) | |
| tree | 3dc9baaab95f97fad37d5468f2a9d191ac9630ae | |
| parent | df296352d46730b2e79a05506c2e416e5fce2c9d (diff) | |
| download | faker-97a479b62e02764befaf3ba27a2abcb80216b8bd.tar.xz faker-97a479b62e02764befaf3ba27a2abcb80216b8bd.zip | |
Generate an ethereum address
| -rw-r--r-- | Readme.md | 1 | ||||
| -rw-r--r-- | lib/finance.js | 11 | ||||
| -rw-r--r-- | test/finance.unit.js | 8 |
3 files changed, 20 insertions, 0 deletions
@@ -125,6 +125,7 @@ This will interpolate the format string with the value of methods `name.lastName * currencyName * currencySymbol * bitcoinAddress + * ethereumAddress * iban * bic * hacker diff --git a/lib/finance.js b/lib/finance.js index 87a89411..41cae3b1 100644 --- a/lib/finance.js +++ b/lib/finance.js @@ -151,6 +151,17 @@ var Finance = function (faker) { }; /** + * ethereumAddress + * + * @method faker.finance.ethereumAddress + */ + self.ethereumAddress = function () { + var address = faker.random.hexaDecimal(40); + + return address; + }; + + /** * iban * * @method faker.finance.iban diff --git a/test/finance.unit.js b/test/finance.unit.js index 3593ce72..61ae7b6c 100644 --- a/test/finance.unit.js +++ b/test/finance.unit.js @@ -227,6 +227,14 @@ describe('finance.js', function () { }); }); + describe("ethereumAddress()", function(){ + it("returns a random ethereum address", function(){ + var ethereumAddress = faker.finance.ethereumAddress(); + + assert.ok(ethereumAddress.match(/^(0x)[0-9a-f]{40}$/i)); + }); + }); + describe("iban()", function () { var ibanLib = require('../lib/iban'); it("returns a random yet formally correct IBAN number", function () { |
