Make error messages distinct at each failure location.

This commit is contained in:
Glenn Willen 2020-07-23 02:39:13 -07:00 committed by Steven Roose
parent f335ff8456
commit 91ec3dd165
No known key found for this signature in database
GPG key ID: 2F2A88D7F8D68E87
2 changed files with 5 additions and 5 deletions

View file

@ -2740,11 +2740,11 @@ UniValue rawissueasset(const JSONRPCRequest& request)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Transaction must have at least one output.");
}
if (!mtx.vout[mtx.vout.size() - 1].IsFee()) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Transaction must have exactly one fee output, which must be last");
throw JSONRPCError(RPC_INVALID_PARAMETER, "Last transaction output must be fee.");
}
for (size_t i = 0; i < mtx.vout.size() - 1; i++) {
if (mtx.vout[i].IsFee()) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Transaction must have exactly one fee output, which must be last");
throw JSONRPCError(RPC_INVALID_PARAMETER, "Transaction can only have one fee output.");
}
}
@ -2868,11 +2868,11 @@ UniValue rawreissueasset(const JSONRPCRequest& request)
// Validate fee output location, required by the implementation of reissueasset_base
if (!mtx.vout[mtx.vout.size() - 1].IsFee()) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Transaction must have exactly one fee output, which must be last");
throw JSONRPCError(RPC_INVALID_PARAMETER, "Last transaction output must be fee.");
}
for (size_t i = 0; i < mtx.vout.size() - 1; i++) {
if (mtx.vout[i].IsFee()) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Transaction must have exactly one fee output, which must be last");
throw JSONRPCError(RPC_INVALID_PARAMETER, "Transaction can only have one fee output.");
}
}

View file

@ -297,7 +297,7 @@ class IssuanceTest(BitcoinTestFramework):
assert_raises_rpc_error(-8, "Transaction must have at least one output.",
self.nodes[0].rawissueasset, raw_tx, [{"asset_amount": 1, "asset_address": valid_addr}])
raw_tx = self.nodes[0].createrawtransaction([], {valid_addr: Decimal("1")})
assert_raises_rpc_error(-8, "Transaction must have exactly one fee output, which must be last",
assert_raises_rpc_error(-8, "Last transaction output must be fee.",
self.nodes[0].rawissueasset, raw_tx, [{"asset_amount": 1, "asset_address": valid_addr}])
# Make sure that invalid addresses are rejected.