Skip to content

Commit

Permalink
Add wallet protection method tests
Browse files Browse the repository at this point in the history
These tests are meant to be run against rpc methods in PR bisq-network#4214.
This change should not be merged before PR bisq-network#4214.
  • Loading branch information
ghubstan committed May 7, 2020
1 parent bb2484a commit 52f9b12
Showing 1 changed file with 85 additions and 3 deletions.
88 changes: 85 additions & 3 deletions cli/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,89 @@
[ "$output" = "1.3.2" ]
}

@test "test getbalance (available & unlocked wallet with 0 btc balance)" {
@test "test setwalletpassword \"a b c\"" {
run ./bisq-cli --password=xyz setwalletpassword "a b c"
[ "$status" -eq 0 ]
echo "actual output: $output" >&2
[ "$output" = "wallet encrypted" ]
sleep 1
}

@test "test unlockwallet without password & timeout args" {
run ./bisq-cli --password=xyz unlockwallet
[ "$status" -eq 1 ]
echo "actual output: $output" >&2
[ "$output" = "Error: no password specified" ]
}

@test "test unlockwallet without timeout arg" {
run ./bisq-cli --password=xyz unlockwallet "a b c"
[ "$status" -eq 1 ]
echo "actual output: $output" >&2
[ "$output" = "Error: no unlock timeout specified" ]
}


@test "test unlockwallet \"a b c\" 8" {
run ./bisq-cli --password=xyz unlockwallet "a b c" 8
[ "$status" -eq 0 ]
echo "actual output: $output" >&2
[ "$output" = "wallet unlocked" ]
}

@test "test getbalance while wallet unlocked for 8s" {
run ./bisq-cli --password=xyz getbalance
[ "$status" -eq 0 ]
echo "actual output: $output" >&2
[ "$output" = "0.00000000" ]
sleep 8
}

@test "test unlockwallet \"a b c\" 6" {
run ./bisq-cli --password=xyz unlockwallet "a b c" 6
[ "$status" -eq 0 ]
echo "actual output: $output" >&2
[ "$output" = "wallet unlocked" ]
}

@test "test lockwallet before unlockwallet timeout=6s expires" {
run ./bisq-cli --password=xyz lockwallet
[ "$status" -eq 0 ]
echo "actual output: $output" >&2
[ "$output" = "wallet locked" ]
}

@test "test setwalletpassword incorrect old pwd error" {
run ./bisq-cli --password=xyz setwalletpassword "z z z" "d e f"
[ "$status" -eq 1 ]
echo "actual output: $output" >&2
[ "$output" = "Error: incorrect old password" ]
}

@test "test setwalletpassword oldpwd newpwd" {
run ./bisq-cli --password=xyz setwalletpassword "a b c" "d e f"
[ "$status" -eq 0 ]
echo "actual output: $output" >&2
[ "$output" = "wallet encrypted with new password" ]
sleep 1
}

@test "test getbalance wallet locked error" {
run ./bisq-cli --password=xyz getbalance
[ "$status" -eq 1 ]
echo "actual output: $output" >&2
[ "$output" = "Error: wallet is locked" ]
}

@test "test removewalletpassword" {
run ./bisq-cli --password=xyz removewalletpassword "d e f"
[ "$status" -eq 0 ]
echo "actual output: $output" >&2
[ "$output" = "wallet decrypted" ]
sleep 1
}

@test "test getbalance when wallet available & unlocked with 0 btc balance" {
run ./bisq-cli --password=xyz getbalance
[ "$status" -eq 0 ]
echo "actual output: $output" >&2
Expand All @@ -69,14 +151,14 @@
run ./bisq-cli
[ "$status" -eq 1 ]
[ "${lines[0]}" = "Bisq RPC Client" ]
[ "${lines[1]}" = "Usage: bisq-cli [options] <method>" ]
[ "${lines[1]}" = "Usage: bisq-cli [options] <method> [params]" ]
# TODO add asserts after help text is modified for new endpoints
}

@test "test --help option" {
run ./bisq-cli --help
[ "$status" -eq 0 ]
[ "${lines[0]}" = "Bisq RPC Client" ]
[ "${lines[1]}" = "Usage: bisq-cli [options] <method>" ]
[ "${lines[1]}" = "Usage: bisq-cli [options] <method> [params]" ]
# TODO add asserts after help text is modified for new endpoints
}

0 comments on commit 52f9b12

Please sign in to comment.