-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy paththorgo_test.go
63 lines (49 loc) · 1.54 KB
/
thorgo_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
53
54
55
56
57
58
59
60
61
62
63
package thorgo
import (
"testing"
"github.com/darrenvechain/thorgo/internal/testcontainer"
"github.com/darrenvechain/thorgo/solo"
"github.com/darrenvechain/thorgo/thorest"
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/assert"
)
var thor *Thor
func TestMain(t *testing.M) {
clt, cancel := testcontainer.NewSolo()
defer cancel()
thor = NewFromClient(clt)
t.Run()
}
func TestFromClient(t *testing.T) {
thor := NewFromClient(thor.Client)
assert.NotNil(t, thor)
tag, err := thor.Client.ChainTag()
assert.NoError(t, err)
assert.Equal(t, solo.ChainTag(), tag)
}
func TestBlock(t *testing.T) {
block, err := thor.Blocks.ByNumber(0)
assert.NoError(t, err)
assert.NotNil(t, block)
}
func TestGetAccount(t *testing.T) {
soloAccount := common.HexToAddress("0xf077b491b355E64048cE21E3A6Fc4751eEeA77fa")
acc, err := thor.Account(soloAccount).Get()
assert.NoError(t, err, "Account.httpGet should not return an error")
assert.NotNil(t, acc, "Account.httpGet should return an account")
assert.Greater(t, acc.Balance.ToInt().Uint64(), uint64(0))
assert.Greater(t, acc.Energy.ToInt().Uint64(), uint64(0))
assert.False(t, acc.HasCode)
}
func TestTransfers(t *testing.T) {
criteria := make([]thorest.TransferCriteria, 0)
transfers, err := thor.Transfers(criteria, new(thorest.LogFilters))
assert.NoError(t, err)
assert.NotNil(t, transfers)
}
func TestEvents(t *testing.T) {
criteria := make([]thorest.EventCriteria, 0)
events, err := thor.Events(criteria, new(thorest.LogFilters))
assert.NoError(t, err)
assert.NotNil(t, events)
}