-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelper_test.go
52 lines (44 loc) · 1.12 KB
/
helper_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package vsys
import (
"os"
"strconv"
"testing"
"time"
"github.com/stretchr/testify/require"
)
var (
AVG_BLOCK_DELAY = os.Getenv("GO_VSYS_AVG_BLOCK_DELAY")
HOST = os.Getenv("GO_VSYS_HOST")
SEED = os.Getenv("GO_VSYS_SEED")
SUPERNODE_ADDR = os.Getenv("GO_VSYS_SUPERNODE_ADDR")
)
var (
avgBlockDelay time.Duration
testApi = NewNodeAPI(HOST)
testCh = NewChain(testApi, TEST_NET)
testWal *Wallet
testAcnt0 *Account
testAcnt1 *Account
testAcnt2 *Account
)
func init() {
abdVal, _ := strconv.Atoi(AVG_BLOCK_DELAY)
avgBlockDelay = time.Duration(abdVal) * time.Second
testWal, _ = NewWalletFromSeedStr(SEED)
testAcnt0, _ = testWal.GetAccount(testCh, 0)
testAcnt1, _ = testWal.GetAccount(testCh, 1)
testAcnt2, _ = testWal.GetAccount(testCh, 2)
}
func waitForBlock() {
time.Sleep(avgBlockDelay)
}
func assertTxStatus(t *testing.T, txId, status string) {
tx, err := testApi.GetTxInfo(txId)
if err != nil {
t.Log(err)
}
require.Equal(t, status, tx.GetTxGeneral().Status.Str())
}
func assertTxSuccess(t *testing.T, txId string) {
assertTxStatus(t, txId, "Success")
}