mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 06:41:44 +01:00
test: test feerate changes.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
1305df6417
commit
72a9cfbbe2
4 changed files with 42 additions and 3 deletions
|
@ -290,6 +290,7 @@ static const struct json_command *cmdlist[] = {
|
||||||
&newaddr_command,
|
&newaddr_command,
|
||||||
&accept_payment_command,
|
&accept_payment_command,
|
||||||
&pay_command,
|
&pay_command,
|
||||||
|
&feerate_command,
|
||||||
/* Developer/debugging options. */
|
/* Developer/debugging options. */
|
||||||
&echo_command,
|
&echo_command,
|
||||||
&rhash_command,
|
&rhash_command,
|
||||||
|
|
|
@ -74,4 +74,5 @@ extern const struct json_command accept_payment_command;
|
||||||
extern const struct json_command add_route_command;
|
extern const struct json_command add_route_command;
|
||||||
extern const struct json_command routefail_command;
|
extern const struct json_command routefail_command;
|
||||||
extern const struct json_command pay_command;
|
extern const struct json_command pay_command;
|
||||||
|
extern const struct json_command feerate_command;
|
||||||
#endif /* LIGHTNING_DAEMON_JSONRPC_H */
|
#endif /* LIGHTNING_DAEMON_JSONRPC_H */
|
||||||
|
|
|
@ -4537,6 +4537,35 @@ const struct json_command close_command = {
|
||||||
"Returns an empty result on success"
|
"Returns an empty result on success"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void json_feerate(struct command *cmd,
|
||||||
|
const char *buffer, const jsmntok_t *params)
|
||||||
|
{
|
||||||
|
jsmntok_t *feeratetok;
|
||||||
|
u64 feerate;
|
||||||
|
|
||||||
|
if (!json_get_params(buffer, params,
|
||||||
|
"feerate", &feeratetok,
|
||||||
|
NULL)) {
|
||||||
|
command_fail(cmd, "Need feerate");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!json_tok_u64(buffer, feeratetok, &feerate)) {
|
||||||
|
command_fail(cmd, "Invalid feerate");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cmd->dstate->config.default_fee_rate = feerate;
|
||||||
|
|
||||||
|
command_success(cmd, null_response(cmd));
|
||||||
|
}
|
||||||
|
|
||||||
|
const struct json_command feerate_command = {
|
||||||
|
"dev-feerate",
|
||||||
|
json_feerate,
|
||||||
|
"Change the (default) fee rate to {feerate}",
|
||||||
|
"Returns an empty result on success"
|
||||||
|
};
|
||||||
|
|
||||||
static void json_disconnect(struct command *cmd,
|
static void json_disconnect(struct command *cmd,
|
||||||
const char *buffer, const jsmntok_t *params)
|
const char *buffer, const jsmntok_t *params)
|
||||||
{
|
{
|
||||||
|
|
|
@ -359,10 +359,10 @@ fi
|
||||||
|
|
||||||
if [ -n "$DIFFERENT_FEES" ]; then
|
if [ -n "$DIFFERENT_FEES" ]; then
|
||||||
# Simply override default fee (estimatefee fails on regtest anyway)
|
# Simply override default fee (estimatefee fails on regtest anyway)
|
||||||
CLOSE_FEE_RATE2=50000
|
DEFAULT_FEE_RATE2=50000
|
||||||
# We use 5x fee rate for commits, by defailt.
|
# We use 5x fee rate for commits, by defailt.
|
||||||
FEE_RATE2=$(($CLOSE_FEE_RATE2 * 5))
|
FEE_RATE2=$(($DEFAULT_FEE_RATE2 * 5))
|
||||||
echo "default-fee-rate=$CLOSE_FEE_RATE2" >> $DIR2/config
|
echo "default-fee-rate=$DEFAULT_FEE_RATE2" >> $DIR2/config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Need absolute path for re-exec testing.
|
# Need absolute path for re-exec testing.
|
||||||
|
@ -513,6 +513,14 @@ if [ -n "$DIFFERENT_FEES" ]; then
|
||||||
check_status_single lcli1 $(($AMOUNT - $HTLC_AMOUNT - $NO_HTLCS_FEE / 2)) $(($NO_HTLCS_FEE / 2)) "" $(($HTLC_AMOUNT - $NO_HTLCS_FEE / 2)) $(($NO_HTLCS_FEE / 2)) ""
|
check_status_single lcli1 $(($AMOUNT - $HTLC_AMOUNT - $NO_HTLCS_FEE / 2)) $(($NO_HTLCS_FEE / 2)) "" $(($HTLC_AMOUNT - $NO_HTLCS_FEE / 2)) $(($NO_HTLCS_FEE / 2)) ""
|
||||||
check_status_single lcli2 $(($HTLC_AMOUNT - $NO_HTLCS_FEE2 / 2)) $(($NO_HTLCS_FEE2 / 2)) "" $(($AMOUNT - $HTLC_AMOUNT - $NO_HTLCS_FEE2 / 2)) $(($NO_HTLCS_FEE2 / 2)) ""
|
check_status_single lcli2 $(($HTLC_AMOUNT - $NO_HTLCS_FEE2 / 2)) $(($NO_HTLCS_FEE2 / 2)) "" $(($AMOUNT - $HTLC_AMOUNT - $NO_HTLCS_FEE2 / 2)) $(($NO_HTLCS_FEE2 / 2)) ""
|
||||||
|
|
||||||
|
# Change fee rate on node2 to same as node1.
|
||||||
|
lcli2 dev-feerate 40000
|
||||||
|
$CLI generate 1
|
||||||
|
[ ! -n "$MANUALCOMMIT" ] || lcli2 commit $ID1
|
||||||
|
[ ! -n "$MANUALCOMMIT" ] || lcli1 commit $ID2
|
||||||
|
|
||||||
|
check_status $(($AMOUNT - $HTLC_AMOUNT - $NO_HTLCS_FEE / 2)) $(($NO_HTLCS_FEE / 2)) "" $(($HTLC_AMOUNT - $NO_HTLCS_FEE / 2)) $(($NO_HTLCS_FEE / 2)) ""
|
||||||
|
|
||||||
lcli1 close $ID2
|
lcli1 close $ID2
|
||||||
# Make sure they notice it.
|
# Make sure they notice it.
|
||||||
check_peerstate lcli1 STATE_MUTUAL_CLOSING
|
check_peerstate lcli1 STATE_MUTUAL_CLOSING
|
||||||
|
|
Loading…
Add table
Reference in a new issue