Skip to content

Commit

Permalink
WIP #122 - [Devnet testing] Add script to monitor unconfirmed TXs;
Browse files Browse the repository at this point in the history
Added broadcastVotes to .devutils/broadcast.ts to test vote transactions
  • Loading branch information
mcanever committed Aug 28, 2018
1 parent 3bfb820 commit d6132bf
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
37 changes: 31 additions & 6 deletions .devutils/broadcast.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { dposAPI } from 'dpos-api-wrapper';
import { LiskWallet, SendTx } from 'dpos-offline';
import * as moment from 'moment';
import { createSendTransaction } from '../tests/utils/txCrafter';

import { createSendTransaction, createVoteTransaction } from '../tests/utils/txCrafter';
const cfg = require('../etc/devnet/config.json');

const nodes = [
'http://localhost:10001',
'http://localhost:10002',
'http://localhost:10006',
'http://localhost:10003',
'http://localhost:10004',
'http://localhost:10005',
];
Expand All @@ -17,7 +17,7 @@ const wrappers = nodes.map((node) => dposAPI.newWrapper(node, {timeout: 100000})
async function broadcast() {
await Promise.all(wrappers.map((w) => w.buildTransport()));

for (let i = 0; i < 1000; i++) {
for (let i = 0; i < 200; i++) {
const tx = createSendTransaction(
new LiskWallet('diamond grain object regular enact tool gadget recipe cactus neutral nominee exile', 'R'),
'1R',
Expand All @@ -38,6 +38,31 @@ async function broadcast() {
}
}

broadcast().then(() => {
console.log('ou')
async function broadcastVotes(add: boolean) {
await Promise.all(wrappers.map((w) => w.buildTransport()));
const delegateSecrets = cfg.forging.secret;
for (let i = 0; i < delegateSecrets.length; i++) {
const delegate = new LiskWallet(delegateSecrets[i], 'R');
const tx = createVoteTransaction(
delegate,
100000000,
{
amount: 0,
timestamp: moment.utc()
.diff(
new Date(Date.UTC(2016, 4, 24, 17, 0, 0, 0)),
'seconds'
),
asset: {votes: [`${add ? '+' : '-'}${delegate.publicKey}`]},
}
);
console.log(i);
wrappers[i % wrappers.length].buildTransport()
.then((t) => t.postTransaction(tx));

}
}

broadcastVotes(false).then(() => {
console.log('done');
});
10 changes: 10 additions & 0 deletions .devutils/devnet_unconfirmed_txs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# default = 4 peers
NUMPEERS=${1:-5}

for (( i=1; i <= NUMPEERS; i++ )) do
echo "PEER $((10000 + $i)):"
curl --silent http://127.0.0.1:$(( 10000 + $i ))/api/transactions/unconfirmed | jq '.count,(.transactions | map(.id) | join(","))'
echo;
done

0 comments on commit d6132bf

Please sign in to comment.