-
Notifications
You must be signed in to change notification settings - Fork 4
/
aptos_test.go
79 lines (72 loc) · 1.81 KB
/
aptos_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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package chain_selectors
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func Test_AptosYmlAreValid(t *testing.T) {
tests := []struct {
name string
chainSelector uint64
chainsId uint64
expectErr bool
}{
{
name: "aptos-mainnet",
chainSelector: 124615329519749607,
chainsId: 1,
expectErr: false,
},
{
name: "aptos-testnet",
chainSelector: 6302590918974934319,
chainsId: 2,
expectErr: false,
},
{
name: "non-existing",
chainSelector: 81923186267,
chainsId: 471,
expectErr: true,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
name, err1 := AptosNameFromChainId(test.chainsId)
if test.expectErr {
require.Error(t, err1)
return
}
require.NoError(t, err1)
assert.Equal(t, test.name, name)
})
}
}
func Test_AptosChainSelectors(t *testing.T) {
for selector, chainId := range aptosChainIdBySelector {
family, err := GetSelectorFamily(selector)
require.NoError(t, err,
"selector %v should be returned as aptos family, but received %v",
selector, err)
require.NotEmpty(t, family)
require.Equal(t, FamilyAptos, family)
id, err := AptosChainIdFromSelector(selector)
require.Nil(t, err)
require.Equal(t, chainId, id)
}
}
func Test_AptosGetChainDetailsByChainIDAndFamily(t *testing.T) {
for k, v := range aptosSelectorsMap {
details, err := GetChainDetailsByChainIDAndFamily(fmt.Sprint(k), FamilyAptos)
assert.NoError(t, err)
assert.Equal(t, v, details)
}
}
func Test_AptosGetChainIDByChainSelector(t *testing.T) {
for k, v := range aptosSelectorsMap {
chainID, err := GetChainIDFromSelector(v.ChainSelector)
assert.NoError(t, err)
assert.Equal(t, chainID, fmt.Sprintf("%v", k))
}
}