Skip to content

Commit

Permalink
Add llmq-signing.py tests
Browse files Browse the repository at this point in the history
  • Loading branch information
codablock committed Jan 21, 2019
1 parent d51d0c6 commit 8c415fc
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 1 deletion.
1 change: 1 addition & 0 deletions qa/pull-tester/rpc-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
'wallet-dump.py',
'listtransactions.py',
'multikeysporks.py',
'llmq-signing.py', # NOTE: needs dash_hash to pass
# vv Tests less than 60s vv
'sendheaders.py', # NOTE: needs dash_hash to pass
'zapwallettxes.py',
Expand Down
81 changes: 81 additions & 0 deletions qa/rpc-tests/llmq-signing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/usr/bin/env python3
# Copyright (c) 2015-2018 The Dash Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

from test_framework.mininode import *
from test_framework.test_framework import DashTestFramework
from test_framework.util import *
from time import *

'''
llmq-signing.py
Checks LLMQs signing sessions
'''

class LLMQSigningTest(DashTestFramework):
def __init__(self):
super().__init__(11, 10, [])

def run_test(self):

self.nodes[0].spork("SPORK_17_QUORUM_DKG_ENABLED", 0)
self.wait_for_sporks_same()

self.mine_quorum()

id = "0000000000000000000000000000000000000000000000000000000000000001"
msgHash = "0000000000000000000000000000000000000000000000000000000000000002"
msgHashConflict = "0000000000000000000000000000000000000000000000000000000000000003"

def assert_sigs(hasrecsigs, isconflicting1, isconflicting2):
for mn in self.mninfo:
assert(mn.node.quorum("hasrecsig", 100, id, msgHash) == hasrecsigs)
assert(mn.node.quorum("isconflicting", 100, id, msgHash) == isconflicting1)
assert(mn.node.quorum("isconflicting", 100, id, msgHashConflict) == isconflicting2)

# Initial state
assert_sigs(False, False, False)

# Sign 5 shares, should not result in recovered sig
for i in range(5):
self.mninfo[i].node.quorum("sign", 100, id, msgHash)
sleep(2)
assert_sigs(False, False, False)

# Sign one more share, should result in recovered sig and conflict for msgHashConflict
self.mninfo[6].node.quorum("sign", 100, id, msgHash)
sleep(2)
assert_sigs(True, False, True)

# Mine one more quorum, so that we have 2 active ones, nothing should change
self.mine_quorum()
assert_sigs(True, False, True)

# Mine 2 more quorums, so that the one used for the the recovered sig should become inactive, nothing should change
self.mine_quorum()
self.mine_quorum()
assert_sigs(True, False, True)

# fast forward 6.5 days, recovered sig should still be valid
set_mocktime(get_mocktime() + int(60 * 60 * 24 * 6.5))
set_node_times(self.nodes, get_mocktime())
sleep(6) # Cleanup starts every 5 seconds
assert_sigs(True, False, True)
# fast forward 1 day, recovered sig should not be valid anymore
set_mocktime(get_mocktime() + int(60 * 60 * 24 * 1))
set_node_times(self.nodes, get_mocktime())
sleep(6) # Cleanup starts every 5 seconds
assert_sigs(False, False, False)

for i in range(4):
self.mninfo[i].node.quorum("sign", 100, id, msgHashConflict)
for i in range(4, 10):
self.mninfo[i].node.quorum("sign", 100, id, msgHash)
sleep(2)
assert_sigs(True, False, True)

if __name__ == '__main__':
LLMQSigningTest().main()
2 changes: 1 addition & 1 deletion qa/rpc-tests/test_framework/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ def mine_quorum(self, expected_valid_count=10):
set_node_times(self.nodes, get_mocktime())
self.nodes[0].generate(1)


sync_blocks(self.nodes)

# Test framework for doing p2p comparison testing, which sets up some bitcoind
# binaries:
Expand Down

0 comments on commit 8c415fc

Please sign in to comment.