package tron2

import (
	"fmt"
	"testing"

	"github.com/spf13/viper"
)

func TestIsOk(t *testing.T) {
	isOK, err := IsTransactionSucc("9be120a380642f0e3d8e3816ea123f17c0852d7b7db09a552aec0b9d06053c8a")
	if err != nil {
		t.Fatal(err)
	}

	if isOK {
		t.Fatal("error ")
	}
}

func TestIsOk2(t *testing.T) {
	isOK, err := IsTransactionSucc("a44bd961fda4caa40fc05f6d34368c26f0c92a2bdf2de52b44df35c4ea23f47b")
	if err != nil {
		t.Fatal(err)
	}

	if !isOK {
		t.Fatal("error ")
	}
}

func TestGetAmountByHash(t *testing.T) {
	amount, err := GetTrc20BalanceByHash("c5dc8a1fc54d25571736a02d1a6aec97938be9bfed492b9df5621174ddfe25f3")
	if err != nil {
		t.Fatal(err)
	}

	fmt.Println(amount)
}

func TestGetTxHistory(t *testing.T) {
	viper.Set("tron.apiHost", "api.trongrid.io")
	viper.Set("contractaddr", "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t")

	txInfoList, _, err := GetTxHistoryByAddr("TMc1dKkWLsTreEY4zAHutf22fwBRnT8888", "", 10)
	if err != nil {
		t.Fatal(err)
	}

	fmt.Println(txInfoList)
}
