This commit is contained in:
Do Kwon 2019-08-09 12:06:32 +09:00
commit 4aaa2a8cef
2 changed files with 9 additions and 5 deletions

View File

@ -4,6 +4,7 @@ import (
"encoding/json"
"log"
"net/url"
"os"
"strconv"
"strings"
@ -17,6 +18,7 @@ import (
var aminoCdc = amino.NewCodec()
func init() {
log.SetOutput(os.Stdout)
ctypes.RegisterAmino(aminoCdc)
}
@ -77,7 +79,7 @@ func (app SantaApp) ListenNewBLock(isTest bool) {
if blockEvent.Block.Height%triggerInterval == 0 {
txHash, err := app.SendTx(blockEvent.Block.ChainID)
if err != nil {
log.Fatal("[Fail] to send tx", err)
log.Printf("[Fail] to send tx: %s", err.Error())
}
log.Printf("[Success] Height: %d,\tTxHash: %s\n", blockEvent.Block.Height, txHash)

View File

@ -1,15 +1,17 @@
package utils
import (
"os"
"bytes"
"log"
"os"
"strings"
"time"
"testing"
"github.com/stretchr/testify/require"
)
func TestWebsocketListen(t *testing.T) {
app := setupWithPlentyBalanceAccount(t)
@ -18,11 +20,11 @@ func TestWebsocketListen(t *testing.T) {
var logBuf bytes.Buffer
log.SetOutput(&logBuf)
defer log.SetOutput(os.Stderr)
defer log.SetOutput(os.Stdout)
app.TriggerInterval = "1"
app.ListenNewBLock(true)
result := logBuf.String()
require.True(t, strings.Contains(result, "[Success]"))
}
}