1 | let ScryptaCore = require('../src/index.js')
|
2 | let scrypta = new ScryptaCore
|
3 |
|
4 |
|
5 |
|
6 | async function testnodes(){
|
7 | let nodes = await scrypta.returnNodes()
|
8 | console.log('SHOULD RETURN ALL NODES')
|
9 | console.log(nodes)
|
10 | }
|
11 | testnodes()
|
12 |
|
13 |
|
14 | let password = '123456'
|
15 | scrypta.createAddress(password, true).then(async res => {
|
16 |
|
17 |
|
18 | console.log('SHOULD GET FIRST IDANODE')
|
19 | let getinfo = await scrypta.get('/wallet/getinfo')
|
20 | console.log(JSON.stringify(getinfo))
|
21 |
|
22 |
|
23 | console.log('CREATED NEW ADDRESS ' + res.pub)
|
24 | let walletstore = await scrypta.returnKey(res.pub)
|
25 | console.log(walletstore)
|
26 | let readKey = await scrypta.readKey(password, walletstore)
|
27 | console.log(readKey)
|
28 |
|
29 |
|
30 | let oldwallet = 'LbMsc12yAWjGeoRbfUu9bb6EE19CK2Pjbd:5c6b0b6095e94a1948b54ebbd1681cc78f0809e32c5036ee323a8dfc2abda2ceb0df85fe839df9701d97819867d5d92a79ed10386cd51a0af3cde27f7215afabe13a47688f14f22e6cb4743a11be86744ff8945992bc48f8b0dccce107f6d9ec665a43bc12a2e363ad66b7937827fd29a58d4a47728e8de3163afb7cd8d9dffab8ce7d01e7aac752a9edca2dd689a93fbb48fdc94314a72a580ebc6358c3cf39a0115aaf461604034d870a534f1f1aaf52af60990d96d2ccbda9e5c55a3c8db4'
|
31 | let readKeyOld = await scrypta.readKey(password, oldwallet)
|
32 | console.log(readKeyOld)
|
33 |
|
34 |
|
35 | let init = await scrypta.post('/init',{address: res.pub})
|
36 | console.log(JSON.stringify(init))
|
37 |
|
38 |
|
39 | console.log('SHOULD CONNECT TO ALL IDANODES WITH ADDRESS ' + res.pub)
|
40 | scrypta.connectP2P(function(received){
|
41 | console.log('Received ' + JSON.stringify(received))
|
42 | })
|
43 |
|
44 |
|
45 | setInterval(function(){
|
46 | scrypta.broadcast(res.pub, password, 'message', 'Now are '+ new Date() +'!')
|
47 | },2500)
|
48 | }) |
\ | No newline at end of file |