Merge pull request #2446 from codablock/pr_dip3_tests
Fix integration tests and add P2SH/multisig tests for DIP3 payees
This commit is contained in:
commit
102d127494
@ -73,7 +73,7 @@ script:
|
||||
- if [ $SECONDS -gt 1200 ]; then export DEPENDS_TIMEOUT="true"; false; fi # The "false" here ensures that the build is marked as failed even though the whole script returns 0
|
||||
- test "$DEPENDS_TIMEOUT" != "true" && $DOCKER_RUN_IN_BUILDER ./ci/build_src.sh
|
||||
- test "$DEPENDS_TIMEOUT" != "true" && $DOCKER_RUN_IN_BUILDER ./ci/test_unittests.sh
|
||||
- test "$DEPENDS_TIMEOUT" != "true" && $DOCKER_RUN_IN_BUILDER ./ci/test_integrationtests.sh
|
||||
- test "$DEPENDS_TIMEOUT" != "true" && $DOCKER_RUN_IN_BUILDER ./ci/test_integrationtests.sh -parallel=3
|
||||
- test "$DEPENDS_TIMEOUT" != "true" && if [ "$DOCKER_BUILD" = "true" ]; then BUILD_DIR=build-ci/dashcore-$BUILD_TARGET ./docker/build-docker.sh; fi
|
||||
after_script:
|
||||
- echo $TRAVIS_COMMIT_RANGE
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
set -e
|
||||
|
||||
PASS_ARGS="$@"
|
||||
|
||||
source ./ci/matrix.sh
|
||||
|
||||
if [ "$RUN_TESTS" != "true" ]; then
|
||||
@ -15,4 +17,4 @@ export LD_LIBRARY_PATH=$BUILD_DIR/depends/$HOST/lib
|
||||
|
||||
cd build-ci/dashcore-$BUILD_TARGET
|
||||
|
||||
./qa/pull-tester/rpc-tests.py --coverage
|
||||
./qa/pull-tester/rpc-tests.py --coverage $PASS_ARGS
|
||||
|
@ -294,6 +294,25 @@ class DIP3Test(BitcoinTestFramework):
|
||||
for mn in mns_protx:
|
||||
self.test_protx_update_service(mn)
|
||||
|
||||
print("testing P2SH/multisig for payee addresses")
|
||||
multisig = self.nodes[0].createmultisig(1, [self.nodes[0].getnewaddress(), self.nodes[0].getnewaddress()])['address']
|
||||
self.update_mn_payee(mns_protx[0], multisig)
|
||||
found_multisig_payee = False
|
||||
for i in range(len(mns_protx)):
|
||||
bt = self.nodes[0].getblocktemplate()
|
||||
expected_payee = bt['masternode'][0]['payee']
|
||||
expected_amount = bt['masternode'][0]['amount']
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
if expected_payee == multisig:
|
||||
block = self.nodes[0].getblock(self.nodes[0].getbestblockhash())
|
||||
cbtx = self.nodes[0].getrawtransaction(block['tx'][0], 1)
|
||||
for out in cbtx['vout']:
|
||||
if 'addresses' in out['scriptPubKey']:
|
||||
if expected_payee in out['scriptPubKey']['addresses'] and out['valueSat'] == expected_amount:
|
||||
found_multisig_payee = True
|
||||
assert(found_multisig_payee)
|
||||
|
||||
print("testing reusing of collaterals for replaced MNs")
|
||||
for i in range(0, 5):
|
||||
mn = mns_protx[i]
|
||||
@ -405,6 +424,13 @@ class DIP3Test(BitcoinTestFramework):
|
||||
mn = self.create_mn_protx(self.nodes[0], mn.idx, 'mn-protx-%d' % mn.idx, mn.collateral_txid, mn.collateral_vout, legacy_mn_key=mn.legacyMnkey)
|
||||
return mn
|
||||
|
||||
def update_mn_payee(self, mn, payee):
|
||||
self.nodes[0].protx('update_registrar', mn.protx_hash, '', '', payee)
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
info = self.nodes[0].protx('info', mn.protx_hash)
|
||||
assert(info['state']['payoutAddress'] == payee)
|
||||
|
||||
def test_protx_update_service(self, mn):
|
||||
self.nodes[0].protx('update_service', mn.protx_hash, '127.0.0.2:%d' % mn.p2p_port, mn.blsMnkey)
|
||||
self.nodes[0].generate(1)
|
||||
@ -655,7 +681,7 @@ class DIP3Test(BitcoinTestFramework):
|
||||
address = node.getnewaddress()
|
||||
key = node.getnewaddress()
|
||||
blsKey = node.bls('generate')
|
||||
assert_raises_jsonrpc(None, "bad-tx-type-dip3", node.protx, 'register_fund', address, '127.0.0.1:10000', key, blsKey['public'], key, 0, address)
|
||||
assert_raises_jsonrpc(None, "bad-tx-type", node.protx, 'register_fund', address, '127.0.0.1:10000', key, blsKey['public'], key, 0, address)
|
||||
|
||||
def test_success_create_protx(self, node):
|
||||
address = node.getnewaddress()
|
||||
|
@ -213,7 +213,7 @@ class TestManager(object):
|
||||
)
|
||||
|
||||
# --> error if not requested
|
||||
if not wait_until(blocks_requested, attempts=20*num_blocks):
|
||||
if not wait_until(blocks_requested, attempts=20*num_blocks, sleep=0.1):
|
||||
# print [ c.cb.block_request_map for c in self.connections ]
|
||||
raise AssertionError("Not all nodes requested block")
|
||||
|
||||
|
@ -1226,7 +1226,7 @@ class msg_reject(object):
|
||||
% (self.message, self.code, self.reason, self.data)
|
||||
|
||||
# Helper function
|
||||
def wait_until(predicate, *, attempts=float('inf'), timeout=float('inf')):
|
||||
def wait_until(predicate, *, attempts=float('inf'), timeout=float('inf'), sleep=0.05):
|
||||
attempt = 0
|
||||
elapsed = 0
|
||||
|
||||
@ -1235,8 +1235,8 @@ def wait_until(predicate, *, attempts=float('inf'), timeout=float('inf')):
|
||||
if predicate():
|
||||
return True
|
||||
attempt += 1
|
||||
elapsed += 0.05
|
||||
time.sleep(0.05)
|
||||
elapsed += sleep
|
||||
time.sleep(sleep)
|
||||
|
||||
return False
|
||||
|
||||
|
@ -553,6 +553,9 @@ UniValue protx_update_registrar(const JSONRPCRequest& request)
|
||||
tx.nVersion = 3;
|
||||
tx.nType = TRANSACTION_PROVIDER_UPDATE_REGISTRAR;
|
||||
|
||||
// make sure we get anough fees added
|
||||
ptx.vchSig.resize(65);
|
||||
|
||||
FundSpecialTx(tx, ptx);
|
||||
SignSpecialTxPayloadByHash(tx, ptx, keyOwner);
|
||||
SetTxPayload(tx, ptx);
|
||||
|
Loading…
Reference in New Issue
Block a user