-
Notifications
You must be signed in to change notification settings - Fork 20
/
blocks_test.go
42 lines (33 loc) · 993 Bytes
/
blocks_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
package overflow
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestGetBlock(t *testing.T) {
t.Run("Should get latest block", func(t *testing.T) {
g, err := OverflowTesting()
require.NoError(t, err)
require.NotNil(t, g)
block, err := g.GetLatestBlock(context.Background())
assert.Nil(t, err)
assert.GreaterOrEqual(t, block.Height, uint64(0))
})
t.Run("Should get block by height", func(t *testing.T) {
g, err := OverflowTesting()
require.NoError(t, err)
block, err := g.GetBlockAtHeight(context.Background(), 0)
assert.Nil(t, err)
assert.Equal(t, uint64(0), block.Height)
})
t.Run("Should get block by ID", func(t *testing.T) {
g, err := OverflowTesting()
require.NoError(t, err)
block, err := g.GetBlockAtHeight(context.Background(), 0)
assert.Nil(t, err)
block, err = g.GetBlockById(context.Background(), block.ID.String())
assert.Nil(t, err)
assert.NotNil(t, block)
})
}