Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Liquid369 committed Mar 8, 2023
1 parent 4679799 commit 47403f2
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 43 deletions.
8 changes: 4 additions & 4 deletions doc/release-notes/draft-release-notes-6.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand Down Expand Up @@ -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:
Expand Down
14 changes: 7 additions & 7 deletions src/rpc/rpcevo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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"
Expand Down Expand Up @@ -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\"")
)
)
);
Expand Down Expand Up @@ -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);
}
Expand All @@ -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"
Expand Down Expand Up @@ -947,7 +947,7 @@ static const CRPCCommand commands[] =
#ifdef ENABLE_WALLET
{ "evo", "registerprotx", &registerprotx, 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"} },
Expand Down
20 changes: 10 additions & 10 deletions test/functional/test_framework/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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"]
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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'))
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
20 changes: 10 additions & 10 deletions test/functional/tiertwo_deterministicmns.py
Original file line number Diff line number Diff line change
Expand Up @@ -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...")
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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]
Expand All @@ -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)
Expand Down
Loading

0 comments on commit 47403f2

Please sign in to comment.