Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
James Calfee
committed
Oct 13, 2015
1 parent
50f7d94
commit 7bdf5db
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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{")) | ||
}) | ||
|
||
}) |