-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstress_test2.py
More file actions
executable file
·86 lines (65 loc) · 2.49 KB
/
stress_test2.py
File metadata and controls
executable file
·86 lines (65 loc) · 2.49 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# sudo apt install python-pip
# sudo pip install python-bitcoinrpc simplejson sortedcontainers
import time
import testtools
from models import Proposal
from dashd import DashDaemon
def now():
return int(time.time())
#CTestNetParams
nPowTargetSpacing = 1 * 60
#node1 should be a masternode started with "-govtest" parameter
node1 = DashDaemon(host = '127.0.0.1', user='user', password = '1', port = '20101')
#node2 and node3 are regular masternodes
node2 = DashDaemon(host = '127.0.0.1', user='user', password = '1', port = '20002')
node3 = DashDaemon(host = '127.0.0.1', user='user', password = '1', port = '20003')
#log1 = testtools.LogListener('/tmp/node101', 10)
#log2 = testtools.LogListener('/tmp/node2', 10)
#log3 = testtools.LogListener('/tmp/node3', 10)
nSuperblockCycleSeconds = node1.superblockcycle() * nPowTargetSpacing
while(not node1.is_synced() or not node2.is_synced() or not node3.is_synced()):
print('not yet synced, sleep 30 sec')
time.sleep(30)
# create proposal
payout_amount = 0.2
payout_month = 50
curunixtime = now()
payout_address = node1.rpc_command("getnewaddress")
proposalfee = node1.proposalfee()
superblockcycle = node1.superblockcycle()
nextsuperblock = node1.next_superblock_height()
curblock = node1.last_superblock_height()
if nextsuperblock - curblock > 10:
start_epoch = curunixtime
else:
start_epoch = int(curunixtime + (superblockcycle * 2.6 * 60))
end_epoch = int(start_epoch + payout_month * (superblockcycle * 2.6 * 60) + ((superblockcycle/2) * 2.6 * 60) )
proposal = Proposal(
name='proposal_'+str(curblock),
url='https://dashcentral.com/proposal_' +str(curblock) + '_' + str(curunixtime),
payment_address=payout_address,
payment_amount=payout_amount,
start_epoch=start_epoch,
end_epoch=end_epoch,
govobj_type=0
)
print proposal.govobj_type
proposal.govobj_type = 0
#cmd = ['gobject', 'submit', '0', '1', str(curunixtime), proposal.dashd_serialise(), '0463c5b7194605e598441422a3dc99c7c96df4c943dd047310646ae2d8c43add']
cmd = ['gobject', 'submit', '0', '1', str(curunixtime), proposal.dashd_serialise(), '0000000000000000000000000000000000000000000000000000000000000000']
count = 0
while True:
try:
object_hash = node1.rpc_command(*cmd)
except:
time.sleep(1)
continue
print 'submit invalid proposal #{0}: {1}'.format(count, object_hash)
count += 1
curunixtime += 1
cmd[4] = str(curunixtime)
#log1.close()
#log2.close()
#log3.close()