2020-04-26 20:35:09 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2020-04-26 20:46:52 +02:00
|
|
|
# References & examples for expect:
|
2020-04-26 20:35:09 +02:00
|
|
|
#
|
2020-04-26 20:46:52 +02:00
|
|
|
# - https://pantz.org/software/expect/expect_examples_and_tips.html
|
|
|
|
# - https://stackoverflow.com/questions/13982310/else-string-matching-in-expect
|
|
|
|
# - https://gist.github.com/Fluidbyte/6294378
|
|
|
|
# - https://www.oreilly.com/library/view/exploring-expect/9781565920903/ch04.html
|
2020-04-26 20:30:58 +02:00
|
|
|
#
|
2020-04-26 20:46:52 +02:00
|
|
|
# Prior to running this script, run:
|
|
|
|
#
|
2020-04-26 21:10:25 +02:00
|
|
|
# ./bisq-daemon --apiPassword=xyz
|
2020-04-26 20:46:52 +02:00
|
|
|
#
|
2020-04-26 21:10:25 +02:00
|
|
|
# The data directory used must contain an unencrypted wallet with a 0 BTC balance
|
2020-04-26 20:46:52 +02:00
|
|
|
|
|
|
|
# Ensure project root is the current working directory
|
|
|
|
cd $(dirname $0)/..
|
2020-04-26 20:30:58 +02:00
|
|
|
|
2020-04-26 20:35:09 +02:00
|
|
|
OUTPUT=$(expect -c '
|
|
|
|
# exp_internal 1
|
|
|
|
puts "TEST unsupported cmd error"
|
2020-04-26 20:46:52 +02:00
|
|
|
set expected "Error: '\''bogus'\'' is not a supported method"
|
|
|
|
spawn ./bisq-cli --password=xyz bogus
|
2020-04-26 20:30:58 +02:00
|
|
|
expect {
|
2020-04-26 20:35:09 +02:00
|
|
|
$expected { puts "PASS" }
|
|
|
|
default {
|
|
|
|
set results $expect_out(buffer)
|
|
|
|
puts "FAIL expected = $expected"
|
|
|
|
puts " actual = $results"
|
|
|
|
}
|
|
|
|
}
|
2020-04-26 20:30:58 +02:00
|
|
|
')
|
|
|
|
echo "$OUTPUT"
|
|
|
|
echo "========================================================================"
|
|
|
|
|
|
|
|
OUTPUT=$(expect -c '
|
2020-04-26 21:04:06 +02:00
|
|
|
puts "TEST unrecognized option error"
|
|
|
|
set expected "Error: bogus is not a recognized option"
|
|
|
|
spawn ./bisq-cli --bogus getversion
|
2020-04-26 20:30:58 +02:00
|
|
|
expect {
|
2020-04-26 20:35:09 +02:00
|
|
|
$expected { puts "PASS" }
|
|
|
|
default {
|
|
|
|
set results $expect_out(buffer)
|
|
|
|
puts "FAIL expected = $expected"
|
|
|
|
puts " actual = $results"
|
|
|
|
}
|
2020-04-26 20:30:58 +02:00
|
|
|
}
|
|
|
|
')
|
|
|
|
echo "$OUTPUT"
|
|
|
|
echo "========================================================================"
|
|
|
|
|
2020-04-26 20:35:09 +02:00
|
|
|
OUTPUT=$(expect -c '
|
|
|
|
# exp_internal 1
|
2020-04-26 21:05:22 +02:00
|
|
|
puts "TEST missing required password option error"
|
2020-04-26 21:44:03 +02:00
|
|
|
set expected "Error: missing required '\''password'\'' option"
|
|
|
|
spawn ./bisq-cli getversion
|
2020-04-26 20:30:58 +02:00
|
|
|
expect {
|
2020-04-26 20:35:09 +02:00
|
|
|
$expected { puts "PASS" }
|
|
|
|
default {
|
|
|
|
set results $expect_out(buffer)
|
|
|
|
puts "FAIL expected = $expected"
|
|
|
|
puts " actual = $results"
|
|
|
|
}
|
|
|
|
}
|
2020-04-26 20:30:58 +02:00
|
|
|
')
|
|
|
|
echo "$OUTPUT"
|
|
|
|
echo "========================================================================"
|
|
|
|
|
|
|
|
OUTPUT=$(expect -c '
|
|
|
|
# exp_internal 1
|
2020-04-26 21:04:06 +02:00
|
|
|
puts "TEST getversion (incorrect password error)"
|
2020-04-26 20:35:09 +02:00
|
|
|
set expected "Error: incorrect '\''password'\'' rpc header value"
|
2020-04-26 21:04:06 +02:00
|
|
|
spawn ./bisq-cli --password=bogus getversion
|
2020-04-26 20:30:58 +02:00
|
|
|
expect {
|
2020-04-26 20:35:09 +02:00
|
|
|
$expected { puts "PASS\n" }
|
|
|
|
default {
|
|
|
|
set results $expect_out(buffer)
|
|
|
|
puts "FAIL expected = $expected"
|
|
|
|
puts " actual = $results"
|
|
|
|
}
|
2020-04-26 20:30:58 +02:00
|
|
|
}
|
|
|
|
')
|
|
|
|
echo "$OUTPUT"
|
|
|
|
echo "========================================================================"
|
|
|
|
|
|
|
|
OUTPUT=$(expect -c '
|
|
|
|
# exp_internal 1
|
2020-04-26 21:04:06 +02:00
|
|
|
puts "TEST getversion (password value in quotes) COMMIT"
|
2020-04-26 20:35:09 +02:00
|
|
|
set expected "1.3.2"
|
2020-04-26 20:46:52 +02:00
|
|
|
# Note: have to define quoted argument in a variable as "''value''"
|
2020-04-26 20:35:09 +02:00
|
|
|
set pwd_in_quotes "''xyz''"
|
|
|
|
spawn ./bisq-cli --password=$pwd_in_quotes getversion
|
2020-04-26 20:30:58 +02:00
|
|
|
expect {
|
2020-04-26 20:35:09 +02:00
|
|
|
$expected { puts "PASS" }
|
|
|
|
default {
|
|
|
|
set results $expect_out(buffer)
|
|
|
|
puts "FAIL expected = $expected"
|
|
|
|
puts " actual = $results"
|
|
|
|
}
|
2020-04-26 20:30:58 +02:00
|
|
|
}
|
|
|
|
')
|
|
|
|
echo "$OUTPUT"
|
|
|
|
echo "========================================================================"
|
|
|
|
|
|
|
|
OUTPUT=$(expect -c '
|
2020-04-26 20:35:09 +02:00
|
|
|
puts "TEST getversion"
|
|
|
|
set expected "1.3.2"
|
2020-04-26 20:46:52 +02:00
|
|
|
spawn ./bisq-cli --password=xyz getversion
|
2020-04-26 20:30:58 +02:00
|
|
|
expect {
|
2020-04-26 20:35:09 +02:00
|
|
|
$expected { puts "PASS" }
|
|
|
|
default {
|
|
|
|
set results $expect_out(buffer)
|
|
|
|
puts "FAIL expected = $expected"
|
|
|
|
puts " actual = $results"
|
|
|
|
}
|
2020-04-26 20:30:58 +02:00
|
|
|
}
|
|
|
|
')
|
|
|
|
echo "$OUTPUT"
|
|
|
|
echo "========================================================================"
|
|
|
|
|
2020-04-26 20:35:09 +02:00
|
|
|
OUTPUT=$(expect -c '
|
|
|
|
puts "TEST getbalance"
|
|
|
|
# exp_internal 1
|
|
|
|
set expected "0.00000000"
|
2020-04-26 20:46:52 +02:00
|
|
|
spawn ./bisq-cli --password=xyz getbalance
|
2020-04-26 20:30:58 +02:00
|
|
|
expect {
|
2020-04-26 20:35:09 +02:00
|
|
|
$expected { puts "PASS" }
|
|
|
|
default {
|
|
|
|
set results $expect_out(buffer)
|
|
|
|
puts "FAIL expected = $expected"
|
|
|
|
puts " actual = $results"
|
|
|
|
}
|
|
|
|
}
|
2020-04-26 20:30:58 +02:00
|
|
|
')
|
|
|
|
echo "$OUTPUT"
|
2020-04-26 21:44:03 +02:00
|
|
|
echo "========================================================================"
|
2020-04-26 20:30:58 +02:00
|
|
|
|
2020-04-26 21:44:03 +02:00
|
|
|
OUTPUT=$(expect -c '
|
|
|
|
puts "TEST running with no options or arguments prints help text"
|
|
|
|
# exp_internal 1
|
|
|
|
set expected "Bisq RPC Client"
|
|
|
|
spawn ./bisq-cli
|
|
|
|
expect {
|
|
|
|
$expected { puts "PASS" }
|
|
|
|
default {
|
|
|
|
set results $expect_out(buffer)
|
|
|
|
puts "FAIL expected = $expected"
|
|
|
|
puts " actual = $results"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
')
|
|
|
|
echo "$OUTPUT"
|
2020-04-26 20:30:58 +02:00
|
|
|
echo "========================================================================"
|
|
|
|
|
2020-04-26 21:44:03 +02:00
|
|
|
echo "TEST --help option prints help text"
|
|
|
|
./bisq-cli --help
|