Files
nigiri/cli/cmd/faucet_test.go
Francis 88fca5db00 Add faucet command (#93)
* added faucet command

* chopsticks ports imported from env

* changed order of assignments

* test: sleep after start nigiri

* sleep after each strat and each stop

* small changes on faucet

* added check for txId

* json err control

* correcting json err control

* small fixes

* fixes on faucet command

* http.StatusOK

* try with 0.0.0.0 interface

* try with 127.0.0.1 interface

* fixes in travis

Co-authored-by: Marco Argentieri <3596602+tiero@users.noreply.github.com>
2020-09-11 19:13:43 +01:00

82 lines
1.8 KiB
Go

package cmd
import (
"testing"
"github.com/vulpemventures/nigiri/cli/constants"
)
const (
btcAddress = "mpSGWQvbAiRt2UNLST1CdWUufoPVsVwLyK"
liquidAddress = "CTEsqL1x9ooWWG9HBaHUpvS2DGJJ4haYdkTQPKj9U8CCdwT5vcudhbYUT8oQwwoS11aYtdznobfgT8rj"
)
func TestFaucetBitcoinServices(t *testing.T) {
if testing.Short() {
t.Skip("skipping testing in short mode")
}
testStart(t, bitcoin)
if err := testCommand("faucet", btcAddress, bitcoin); err != nil {
t.Fatal(err)
}
testDelete(t)
}
func TestFaucetLiquidServices(t *testing.T) {
if testing.Short() {
t.Skip("skipping testing in short mode")
}
testStart(t, liquid)
if err := testCommand("faucet", liquidAddress, liquid); err != nil {
t.Fatal(err)
}
testDelete(t)
}
func TestFaucetShouldFail(t *testing.T) {
if testing.Short() {
t.Skip("skipping testing in short mode")
}
expectedError := constants.ErrNigiriNotRunning.Error()
err := testCommand("faucet", btcAddress, bitcoin)
if err == nil {
t.Fatal("Should return error when Nigiri is stopped")
}
if err.Error() != expectedError {
t.Fatalf("Expected error: %s, got: %s", expectedError, err)
}
err = testCommand("faucet", liquidAddress, liquid)
if err == nil {
t.Fatal("Should return error when Nigiri is stopped")
}
if err.Error() != expectedError {
t.Fatalf("Expected error: %s, got: %s", expectedError, err)
}
}
func TestStartBitcoinAndFaucetNigiriServicesShouldFail(t *testing.T) {
if testing.Short() {
t.Skip("skipping testing in short mode")
}
testStart(t, bitcoin)
expectedError := constants.ErrNigiriLiquidNotEnabled.Error()
err := testCommand("faucet", liquidAddress, liquid)
if err == nil {
t.Fatal("Should return error when trying logging liquid services if not running")
}
if err.Error() != expectedError {
t.Fatalf("Expected error: %s, got: %s", expectedError, err)
}
testDelete(t)
}