From 7bdf5db33d5167957bc6af3daa9ba8362756d553 Mon Sep 17 00:00:00 2001 From: James Calfee Date: Mon, 12 Oct 2015 14:44:21 -0500 Subject: [PATCH] Util for creating testkeys #319 --- dl/test/testkeys.js | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 dl/test/testkeys.js diff --git a/dl/test/testkeys.js b/dl/test/testkeys.js new file mode 100644 index 000000000..cac5cd4b6 --- /dev/null +++ b/dl/test/testkeys.js @@ -0,0 +1,43 @@ +var Aes = require ('ecc/aes') +import key from "common/key_utils" +import hash from "common/hash" +import PrivateKey from "ecc/key_private" + +/** Usage: TESTWALLET=true npm test -- test/testwallet.js -g import_keys >t +*/ +describe( "testkeys", ()=> { + + it( "import_keys", () => { + if( ! process.env.TESTWALLET) return + // some keys may overlaop with "initial_genesis_balances" + var a=[], b=[] + var aes = Aes.fromSeed("") + for (var i = 0; i < 130 * 1000; i++) { + var d = PrivateKey.fromBuffer(hash.sha256(""+i)) + a.push( aes.encryptHex(d.toBuffer().toString('hex')) ) + b.push( d.toPublicKey().toPublicKeyString() ) + } + var o = {} + o.encrypted_private_keys = a + o.public_keys = b + console.log(JSON.stringify(o,null,1)) + }) + + it( "initial_genesis_balances", ()=> { + if( ! process.env.TESTWALLET) return + // some keys may overlaop with "import_keys" + var initial_balances = [] + for (var i = 0; i < 1000; i++) { + var d = PrivateKey.fromBuffer(hash.sha256(""+i)) + var owner = d.toPublicKey().toAddressString() + initial_balances.push({ + owner, + asset_symbol: "CORE", + amount: "1" + }) + } + var balstr = JSON.stringify(initial_balances) + console.log(balstr.split("},{").join("},\n{")) + }) + +}) \ No newline at end of file