-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
39 lines (32 loc) · 1.28 KB
/
test.js
File metadata and controls
39 lines (32 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const BlockChain = require('./modules/blockchain.js');
const Transaction = require('./modules/transaction.js');
const BlockHeader = require('./modules/blockheader.js');
const Block = require('./modules/block.js');
const Security = require('./logic/security');
const coinbase = 'c4382b76386e73a8a37aff842fbfc1a02fd2b1f2eda74805911ac0505a69062d';
const privateKey = '0000000300050004000500050901000008060003000607000604050400000904c4382b76386e73a8a37aff842fbfc1a02fd2b1f2eda74805911ac0505a69062d';
const data = {
senderpubkey: coinbase,
receiveraddress: 'fred',
amount: 1,
timestamp: Date.now(),
};
process.setMaxListeners(0);
Security.signDetached(data, privateKey).then((signature) => {
data.signature = signature;
let blockchain = new BlockChain(coinbase, 'v1.1');
var promises = []
for (let i = 0; i < 100; i++) {
promises.push(blockchain.addTransaction(new Transaction(data)));
}
Promise.all(promises).then(() => {
console.log('here')
console.log(blockchain.blocks.length);
console.log(blockchain.getBalanceOf(coinbase));
console.log(blockchain.getBalanceOf('fred'));
console.log(JSON.stringify(blockchain));
console.log(blockchain.isValid());
}).catch((err) => {
console.log(err);
});
});