From ba923763099be9710ff19de8222bb4757421425c Mon Sep 17 00:00:00 2001 From: junderw Date: Fri, 24 Feb 2023 22:29:06 -0700 Subject: [PATCH] Restore README 2 test --- test/readme.js | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/test/readme.js b/test/readme.js index 2a15678..d9c5e10 100644 --- a/test/readme.js +++ b/test/readme.js @@ -15,21 +15,23 @@ test('README example 1', function (t) { t.equal(bip39.mnemonicToEntropy(mnemonic), entropy) }) -// test('README example 2', function (t) { -// const stub = { -// randombytes: function (size) { -// return Buffer.from('qwertyuiopasdfghjklzxcvbnm[];,./'.slice(0, size), 'utf8') -// } -// } -// const proxiedbip39 = proxyquire('../', stub) - -// // mnemonic strength defaults to 128 bits -// const mnemonic = proxiedbip39.generateMnemonic() - -// t.plan(2) -// t.equal(mnemonic, 'imitate robot frame trophy nuclear regret saddle around inflict case oil spice') -// t.equal(bip39.validateMnemonic(mnemonic), true) -// }) +test('README example 2', function (t) { + const stub = { + '@noble/hashes/utils': { + randomBytes: function (size) { + return Uint8Array.from(Buffer.from('qwertyuiopasdfghjklzxcvbnm[];,./'.slice(0, size), 'utf8')) + } + } + } + const proxiedbip39 = proxyquire('../', stub) + + // mnemonic strength defaults to 128 bits + const mnemonic = proxiedbip39.generateMnemonic() + + t.plan(2) + t.equal(mnemonic, 'imitate robot frame trophy nuclear regret saddle around inflict case oil spice') + t.equal(bip39.validateMnemonic(mnemonic), true) +}) test('README example 3', function (t) { const mnemonic = 'basket actual'