From 47403f2ea1a070d92b008af29caa95cf368000e8 Mon Sep 17 00:00:00 2001 From: Liquid Date: Wed, 8 Mar 2023 10:10:37 -0600 Subject: [PATCH] Fix tests --- .../draft-release-notes-6.0.0.md | 8 +++---- src/rpc/rpcevo.cpp | 14 +++++------ .../test_framework/test_framework.py | 20 ++++++++-------- test/functional/tiertwo_deterministicmns.py | 20 ++++++++-------- test/functional/tiertwo_reorg_mempool.py | 24 +++++++++---------- 5 files changed, 43 insertions(+), 43 deletions(-) diff --git a/doc/release-notes/draft-release-notes-6.0.0.md b/doc/release-notes/draft-release-notes-6.0.0.md index 167a2e85e5ada..e7c946af7717a 100644 --- a/doc/release-notes/draft-release-notes-6.0.0.md +++ b/doc/release-notes/draft-release-notes-6.0.0.md @@ -115,9 +115,9 @@ Upgrade instructions: !TODO "txid" (string) The transaction id. ``` -* `preprareprotxregistration` +* `prepareprotxregistration` ``` - preprareprotxregistration "collateralHash" collateralIndex "ipAndPort" "ownerAddress" "operatorPubKey" "votingAddress" "payoutAddress" (operatorReward "operatorPayoutAddress") + prepareprotxregistration "collateralHash" collateralIndex "ipAndPort" "ownerAddress" "operatorPubKey" "votingAddress" "payoutAddress" (operatorReward "operatorPayoutAddress") Creates an unsigned ProTx and returns it. The ProTx must be signed externally with the collateral key and then passed to "submitprotxregistration". @@ -156,10 +156,10 @@ Upgrade instructions: !TODO submitprotxregistration "tx" "sig" Submits the specified ProTx to the network. This command will also sign the inputs of the transaction - which were previously added by "preprareprotxregistration" to cover transaction fees + which were previously added by "prepareprotxregistration" to cover transaction fees Arguments: - 1. "tx" (string, required) The serialized transaction previously returned by "preprareprotxregistration" + 1. "tx" (string, required) The serialized transaction previously returned by "prepareprotxregistration" 2. "sig" (string, required) The signature signed with the collateral key. Must be in base64 format. Result: diff --git a/src/rpc/rpcevo.cpp b/src/rpc/rpcevo.cpp index 2dbf572b88251..c19a09add1dd7 100644 --- a/src/rpc/rpcevo.cpp +++ b/src/rpc/rpcevo.cpp @@ -314,7 +314,7 @@ static ProRegPL ParseProRegPLParams(const UniValue& params, unsigned int paramId return pl; } -// handles registerprotx, and preprareprotxregistration +// handles registerprotx, and prepareprotxregistration static UniValue ProTxRegister(const JSONRPCRequest& request, bool fSignAndSend) { CWallet * const pwallet = GetWalletForJSONRPCRequest(request); @@ -329,7 +329,7 @@ static UniValue ProTxRegister(const JSONRPCRequest& request, bool fSignAndSend) "The collateral is specified through \"collateralHash\" and \"collateralIndex\" and must be an unspent\n" "transaction output spendable by this wallet. It must also not be used by any other masternode.\n" : - "preprareprotxregistration \"collateralHash\" collateralIndex \"ipAndPort\" \"ownerAddress\" \"operatorPubKey\" \"votingAddress\" \"payoutAddress\" (operatorReward \"operatorPayoutAddress\")\n" + "prepareprotxregistration \"collateralHash\" collateralIndex \"ipAndPort\" \"ownerAddress\" \"operatorPubKey\" \"votingAddress\" \"payoutAddress\" (operatorReward \"operatorPayoutAddress\")\n" "\nCreates an unsigned ProTx and returns it. The ProTx must be signed externally with the collateral\n" "key and then passed to \"submitprotxregistration\".\n" "The collateral is specified through \"collateralHash\" and \"collateralIndex\" and must be an unspent transaction output.\n" @@ -357,7 +357,7 @@ static UniValue ProTxRegister(const JSONRPCRequest& request, bool fSignAndSend) " \"signMessage\" : (string) The string message that needs to be signed with the collateral key\n" "}\n" "\nExamples:\n" - + HelpExampleCli("preprareprotxregistration", "\"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\" 0 \"168.192.1.100:51472\" \"DMJRSsuU9zfyrvxVaAEFQqK4MxZg6vgeS6\" \"DMJRSsuU9zfyrvxVaAEFQqK4MxZg6vgeS6\" \"DMJRSsuU9zfyrvxVaAEFQqK4MxZg6vgeS6\" \"DMJRSsuU9zfyrvxVaAEFQqK4MxZg6vgeS6\"") + + HelpExampleCli("prepareprotxregistration", "\"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\" 0 \"168.192.1.100:51472\" \"DMJRSsuU9zfyrvxVaAEFQqK4MxZg6vgeS6\" \"DMJRSsuU9zfyrvxVaAEFQqK4MxZg6vgeS6\" \"DMJRSsuU9zfyrvxVaAEFQqK4MxZg6vgeS6\" \"DMJRSsuU9zfyrvxVaAEFQqK4MxZg6vgeS6\"") ) ) ); @@ -427,7 +427,7 @@ UniValue registerprotx(const JSONRPCRequest& request) return ProTxRegister(request, true); } -UniValue preprareprotxregistration(const JSONRPCRequest& request) +UniValue prepareprotxregistration(const JSONRPCRequest& request) { return ProTxRegister(request, false); } @@ -443,10 +443,10 @@ UniValue submitprotxregistration(const JSONRPCRequest& request) throw std::runtime_error( "submitprotxregistration \"tx\" \"sig\"\n" "\nSubmits the specified ProTx to the network. This command will also sign the inputs of the transaction\n" - "which were previously added by \"preprareprotxregistration\" to cover transaction fees\n" + "which were previously added by \"prepareprotxregistration\" to cover transaction fees\n" + HelpRequiringPassphrase(pwallet) + "\n" "\nArguments:\n" - "1. \"tx\" (string, required) The serialized transaction previously returned by \"preprareprotxregistration\"\n" + "1. \"tx\" (string, required) The serialized transaction previously returned by \"prepareprotxregistration\"\n" "2. \"sig\" (string, required) The signature signed with the collateral key. Must be in base64 format.\n" "\nResult:\n" "\"txid\" (string) The transaction id.\n" @@ -947,7 +947,7 @@ static const CRPCCommand commands[] = #ifdef ENABLE_WALLET { "evo", "registerprotx", ®isterprotx, true, {"collateralHash","collateralIndex","ipAndPort","ownerAddress","operatorPubKey","votingAddress","payoutAddress","operatorReward","operatorPayoutAddress"} }, { "evo", "fundprotxregistration", &fundprotxregistration, true, {"collateralAddress","ipAndPort","ownerAddress","operatorPubKey","votingAddress","payoutAddress","operatorReward","operatorPayoutAddress"} }, - { "evo", "preprareprotxregistration", &preprareprotxregistration, true, {"collateralHash","collateralIndex","ipAndPort","ownerAddress","operatorPubKey","votingAddress","payoutAddress","operatorReward","operatorPayoutAddress"} }, + { "evo", "prepareprotxregistration", &prepareprotxregistration, true, {"collateralHash","collateralIndex","ipAndPort","ownerAddress","operatorPubKey","votingAddress","payoutAddress","operatorReward","operatorPayoutAddress"} }, { "evo", "submitprotxregistration", &submitprotxregistration, true, {"tx","sig"} }, { "evo", "revokeprotx", &revokeprotx, true, {"proTxHash","operatorKey","reason"} }, { "evo", "updateprotxregistrar", &updateprotxregistrar, true, {"proTxHash","operatorPubKey","votingAddress","payoutAddress","ownerKey"} }, diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index 2466654511d57..280e722e7ea48 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -1079,7 +1079,7 @@ def setupDMN(self, self.stake_and_sync(self.nodes.index(miner), 1) assert_greater_than(mnOwner.getrawtransaction(fundingTxId, 1)["confirmations"], 0) # create and send the ProRegTx funding the collateral - proTxId = mnOwner.fundprotxregistration(collateralAdd, ipport, ownerAdd, + proTxId = mnOwner.fund_protx_registration(collateralAdd, ipport, ownerAdd, bls_keypair["public"], votingAdd, collateralAdd) elif strType == "internal": mnOwner.getnewaddress("dust") @@ -1096,13 +1096,13 @@ def setupDMN(self, break assert_greater_than(collateralTxId_n, -1) assert_greater_than(json_tx["confirmations"], 0) - proTxId = mnOwner.registerprotx(collateralTxId, collateralTxId_n, ipport, ownerAdd, + proTxId = mnOwner.register_protx(collateralTxId, collateralTxId_n, ipport, ownerAdd, bls_keypair["public"], votingAdd, collateralAdd) elif strType == "external": self.log.info("Setting up ProRegTx with collateral externally-signed...") # send the tx from the miner payoutAdd = mnOwner.getnewaddress("payout") - register_res = miner.preprareprotxregistration(outpoint.hash, outpoint.n, ipport, ownerAdd, + register_res = miner.prepareprotxregistration(outpoint.hash, outpoint.n, ipport, ownerAdd, bls_keypair["public"], votingAdd, payoutAdd) self.log.info("ProTx prepared") message_to_sign = register_res["signMessage"] @@ -1175,7 +1175,7 @@ def not_found(): """ Create a ProReg tx, which has the collateral as one of its outputs """ - def fundprotxregistration(self, miner, controller, dmn, collateral_addr, op_rew=None): + def fund_protx_registration(self, miner, controller, dmn, collateral_addr, op_rew=None): # send to the owner the collateral tx + some dust for the ProReg and fee funding_txid = miner.sendtoaddress(collateral_addr, Decimal('101')) # confirm and verify reception @@ -1197,7 +1197,7 @@ def fundprotxregistration(self, miner, controller, dmn, collateral_addr, op_rew= Create a ProReg tx, which references an 100 PIV UTXO as collateral. The controller node owns the collateral and creates the ProReg tx. """ - def registerprotx(self, miner, controller, dmn, collateral_addr): + def register_protx(self, miner, controller, dmn, collateral_addr): # send to the owner the exact collateral tx amount funding_txid = miner.sendtoaddress(collateral_addr, Decimal('100')) # send another output to be used for the fee of the proReg tx @@ -1216,7 +1216,7 @@ def registerprotx(self, miner, controller, dmn, collateral_addr): Create a ProReg tx, referencing a collateral signed externally (eg. HW wallets). Here the controller node owns the collateral (and signs), but the miner creates the ProReg tx. """ - def registerprotx_ext(self, miner, controller, dmn, outpoint, fSubmit): + def register_protx_ext(self, miner, controller, dmn, outpoint, fSubmit): # send to the owner the collateral tx if the outpoint is not specified if outpoint is None: funding_txid = miner.sendtoaddress(controller.getnewaddress("collateral"), Decimal('100')) @@ -1228,7 +1228,7 @@ def registerprotx_ext(self, miner, controller, dmn, outpoint, fSubmit): outpoint = COutPoint(int(funding_txid, 16), get_collateral_vout(json_tx)) dmn.collateral = outpoint # Prepare the message to be signed externally by the owner of the collateral (the controller) - reg_tx = miner.preprareprotxregistration("%064x" % outpoint.hash, outpoint.n, dmn.ipport, dmn.owner, + reg_tx = miner.prepareprotxregistration("%064x" % outpoint.hash, outpoint.n, dmn.ipport, dmn.owner, dmn.operator_pk, dmn.voting, dmn.payee) sig = controller.signmessage(reg_tx["collateralAddress"], reg_tx["signMessage"]) if fSubmit: @@ -1268,11 +1268,11 @@ def register_new_dmn(self, idx, miner_idx, controller_idx, strType, self.log.info("Creating%s proRegTx for deterministic masternode idx=%d..." % ( " and funding" if strType == "fund" else "", idx)) if strType == "fund": - self.fundprotxregistration(miner_node, controller_node, dmn, collateral_addr) + self.fund_protx_registration(miner_node, controller_node, dmn, collateral_addr) elif strType == "internal": - self.registerprotx(miner_node, controller_node, dmn, collateral_addr) + self.register_protx(miner_node, controller_node, dmn, collateral_addr) elif strType == "external": - self.registerprotx_ext(miner_node, controller_node, dmn, outpoint, True) + self.register_protx_ext(miner_node, controller_node, dmn, outpoint, True) else: raise Exception("Type %s not available" % strType) time.sleep(1) diff --git a/test/functional/tiertwo_deterministicmns.py b/test/functional/tiertwo_deterministicmns.py index 616ebe7fb2433..0fb5df99ca8d7 100755 --- a/test/functional/tiertwo_deterministicmns.py +++ b/test/functional/tiertwo_deterministicmns.py @@ -122,7 +122,7 @@ def run_test(self): assert_raises_rpc_error(-1, "Evo upgrade is not active yet", self.add_new_dmn, mns, "fund") # Can create the raw proReg dmn = create_new_dmn(2, controller, dummy_add, None) - tx, sig = self.registerprotx_ext(miner, controller, dmn, None, False) + tx, sig = self.register_protx_ext(miner, controller, dmn, None, False) # but cannot send it assert_raises_rpc_error(-1, "Evo upgrade is not active yet", miner.submitprotxregistration, tx, sig) self.log.info("Done. Now mine blocks till enforcement...") @@ -233,20 +233,20 @@ def run_test(self): self.log.info("Trying duplicate operator key...") dmn2b = create_new_dmn(dmn2.idx, controller, dummy_add, dmn_keys) assert_raises_rpc_error(RPC_VERIFY_REJECTED, "bad-protx-dup-operator-key", - self.fundprotxregistration, miner, controller, dmn2b, dummy_add) + self.fund_protx_registration, miner, controller, dmn2b, dummy_add) # Now try with duplicate owner key self.log.info("Trying duplicate owner key...") dmn2c = create_new_dmn(dmn2.idx, controller, dummy_add, dmn2_keys) dmn2c.owner = mns[randrange(len(mns))].owner assert_raises_rpc_error(RPC_VERIFY_REJECTED, "bad-protx-dup-owner-key", - self.fundprotxregistration, miner, controller, dmn2c, dummy_add) + self.fund_protx_registration, miner, controller, dmn2c, dummy_add) # Finally, register it properly. This time setting 10% of the reward for the operator op_rew = {"reward": 10.00, "address": self.nodes[dmn2.idx].getnewaddress()} self.log.info("Reactivating the node with a new registration (with operator reward)...") dmn2c = create_new_dmn(dmn2.idx, controller, dummy_add, dmn2_keys) - self.fundprotxregistration(miner, controller, dmn2c, dummy_add, op_rew) + self.fund_protx_registration(miner, controller, dmn2c, dummy_add, op_rew) mns.append(dmn2c) time.sleep(1) self.sync_mempools([miner, controller]) @@ -314,7 +314,7 @@ def run_test(self): miner.generate(1) self.sync_blocks() # Then send the ProUpServ tx from the masternode - remote_node.updateprotxservice(mns[0].proTx, mns[0].ipport) + remote_node.update_protx_service(mns[0].proTx, mns[0].ipport) self.sync_mempools([miner, remote_node]) miner.generate(1) self.sync_blocks() @@ -334,17 +334,17 @@ def run_test(self): assert_raises_rpc_error(-8, "not found", miner.updateprotxregistrar, "%064x" % getrandbits(256), "", "", "") self.log.info("Trying to update an operator address to an already used one...") - assert_raises_rpc_error(RPC_VERIFY_REJECTED, "bad-protx-dup-key", controller.updateprotxregistrar, + assert_raises_rpc_error(RPC_VERIFY_REJECTED, "bad-protx-dup-key", controller.update_protx_registrar, mns[0].proTx, mns[1].operator_pk, "", "") self.log.info("Trying to update the payee to an invalid address...") - assert_raises_rpc_error(-5, "invalid PIVX address InvalidPayee", controller.updateprotxregistrar, + assert_raises_rpc_error(-5, "invalid PIVX address InvalidPayee", controller.update_protx_registrar, mns[0].proTx, "", "", "InvalidPayee") self.log.info("Update operator keys...") bls_keypair = self.nodes[mns[0].idx].generateblskeypair() mns[0].operator_pk = bls_keypair["public"] mns[0].operator_sk = bls_keypair["secret"] # Controller should already have the key (as it was generated there), no need to pass it - controller.updateprotxregistrar(mns[0].proTx, mns[0].operator_pk, "", "") + controller.update_protx_registrar(mns[0].proTx, mns[0].operator_pk, "", "") self.sync_mempools([miner, controller]) miner.generate(1) self.sync_blocks() @@ -398,7 +398,7 @@ def run_test(self): assert_raises_rpc_error(-8, "not found", miner.revokeprotx, "%064x" % getrandbits(256)) self.log.info("Trying to revoke with invalid reason...") - assert_raises_rpc_error(-8, "invalid reason", controller.revokeprotx, mns[3].proTx, mns[3].operator_sk, 100) + assert_raises_rpc_error(-8, "invalid reason", controller.revoke_protx, mns[3].proTx, mns[3].operator_sk, 100) self.log.info("Revoke masternode...") # Do it from the remote node (so no need to pass the operator BLS secret key) remote_node = self.nodes[mns[3].idx] @@ -407,7 +407,7 @@ def run_test(self): miner.generate(1) self.sync_blocks() # Then send the ProUpRev tx from the masternode - remote_node.revokeprotx(mns[3].proTx, "", 1) + remote_node.revoke_protx(mns[3].proTx, "", 1) mns[3].revoked() self.sync_mempools([miner, remote_node]) miner.generate(1) diff --git a/test/functional/tiertwo_reorg_mempool.py b/test/functional/tiertwo_reorg_mempool.py index 2dc5fea21c77a..c86eafe795745 100755 --- a/test/functional/tiertwo_reorg_mempool.py +++ b/test/functional/tiertwo_reorg_mempool.py @@ -50,7 +50,7 @@ def disconnect_all(self): self.log.info("Nodes disconnected") def register_masternode(self, from_node, dmn, collateral_addr): - dmn.proTx = from_node.fundprotxregistration(collateral_addr, dmn.ipport, dmn.owner, + dmn.proTx = from_node.fund_protx_registration(collateral_addr, dmn.ipport, dmn.owner, dmn.operator_pk, dmn.voting, dmn.payee) dmn.collateral = COutPoint(int(dmn.proTx, 16), get_collateral_vout(from_node.getrawtransaction(dmn.proTx, True))) @@ -168,41 +168,41 @@ def run_test(self): # Send to the mempool a ProRegTx using the collateral mined after the split mempool_dmn4 = create_new_dmn(free_idx, nodeA, collateral_addr, None) mempool_dmn4.collateral = initial_collateral - self.registerprotx_ext(nodeA, nodeA, mempool_dmn4, mempool_dmn4.collateral, True) + self.register_protx_ext(nodeA, nodeA, mempool_dmn4, mempool_dmn4.collateral, True) # Now send a valid proUpServ tx to the mempool, without mining it - proupserv1_txid = nodeA.updateprotxservice(pre_split_mn1.proTx, + proupserv1_txid = nodeA.update_protx_service(pre_split_mn1.proTx, "127.0.0.1:1000", "", pre_split_mn1.operator_sk) # Try sending another update, reusing the same ip of the previous mempool tx self.log.info("Testing proUpServ in-mempool duplicate-IP rejection...") - assert_raises_rpc_error(-26, "protx-dup", nodeA.updateprotxservice, + assert_raises_rpc_error(-26, "protx-dup", nodeA.update_protx_service, mnsA[0].proTx, "127.0.0.1:1000", "", mnsA[0].operator_sk) # Now send other two valid proUpServ txes to the mempool, without mining them - proupserv2_txid = nodeA.updateprotxservice(mnsA[3].proTx, + proupserv2_txid = nodeA.update_protx_service(mnsA[3].proTx, "127.0.0.1:2000", "", mnsA[3].operator_sk) - proupserv3_txid = nodeA.updateprotxservice(pre_split_mn1.proTx, + proupserv3_txid = nodeA.update_protx_service(pre_split_mn1.proTx, "127.0.0.1:1001", "", pre_split_mn1.operator_sk) # Send valid proUpReg tx to the mempool operator_to_reuse = nodeA.generateblskeypair()["public"] - proupreg1_txid = nodeA.updateprotxregistrar(mnsA[4].proTx, operator_to_reuse, "", "") + proupreg1_txid = nodeA.update_protx_registrar(mnsA[4].proTx, operator_to_reuse, "", "") # Try sending another one, reusing the operator key used by another mempool proTx self.log.info("Testing proUpReg in-mempool duplicate-operator-key rejection...") - assert_raises_rpc_error(-26, "protx-dup", nodeA.updateprotxregistrar, + assert_raises_rpc_error(-26, "protx-dup", nodeA.update_protx_registrar, mnsA[5].proTx, mempool_dmn1.operator_pk, "", "") # Now send other two valid proUpServ txes to the mempool, without mining them new_voting_address = nodeA.getnewaddress() - proupreg2_txid = nodeA.updateprotxregistrar(mnsA[5].proTx, "", new_voting_address, "") - proupreg3_txid = nodeA.updateprotxregistrar(pre_split_mn1.proTx, "", new_voting_address, "") + proupreg2_txid = nodeA.update_protx_registrar(mnsA[5].proTx, "", new_voting_address, "") + proupreg3_txid = nodeA.update_protx_registrar(pre_split_mn1.proTx, "", new_voting_address, "") # Send two valid proUpRev txes to the mempool, without mining them self.log.info("Revoking two masternodes...") - prouprev1_txid = nodeA.revokeprotx(mnsA[6].proTx, mnsA[6].operator_sk) - prouprev2_txid = nodeA.revokeprotx(pre_split_mn2.proTx, pre_split_mn2.operator_sk) + prouprev1_txid = nodeA.revoke_protx(mnsA[6].proTx, mnsA[6].operator_sk) + prouprev2_txid = nodeA.revoke_protx(pre_split_mn2.proTx, pre_split_mn2.operator_sk) # Now nodeA has 4 proReg txes in its mempool, 3 proUpServ txes, 3 proUpReg txes, and 2 proUpRev mempoolA = nodeA.getrawmempool()