-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest.js
31 lines (23 loc) · 916 Bytes
/
test.js
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
// TODO: use real testing framework
Ledger = require('hashgraph-ledger');
fs = require('fs');
exploitingContract = 'function(resolve, reject){ derp() }); function derp(){ asdf() };function(){ }'
var testPublicKey = fs.readFileSync('./test_identity_public_key.pem').toString()
var testPrivateKey = fs.readFileSync('./test_identity_private_key.pem').toString()
var tx = {
contract: Ledger.templates.storeValue,
//contract: exploitingContract,
args: {identifier: 'some_id', value: 'some_value123'},
publicKey: testPublicKey
}
var serializedTransaction = Ledger.serializeAndSign(tx, testPrivateKey);
var hashgraph = require('hashgraph')({
database: '',
publicKey: testPublicKey
});
hashgraph.on('ready', function() {
hashgraph.sendTransaction(serializedTransaction);
})
hashgraph.on('consensus', function(transactions) {
Ledger.commitTransactions(transactions);
})