-
Notifications
You must be signed in to change notification settings - Fork 37
/
tokenid_test.go
48 lines (45 loc) · 1.03 KB
/
tokenid_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
package ens
import (
"testing"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/stretchr/testify/require"
)
func TestDeriveTokenId(t *testing.T) {
tests := []struct {
name string
expected string
input string
err string
}{
{
name: "Valid ENS domain",
expected: "79233663829379634837589865448569342784712482819484549289560981379859480642508",
input: "vitalik.eth",
},
{
name: "Invalid ENS domain",
expected: "",
input: "foo.bar",
err: "unregistered name",
},
{
name: "Blank ENS domain",
expected: "",
input: "",
err: "empty domain",
},
}
client, err := ethclient.Dial("https://mainnet.infura.io/v3/831a5442dc2e4536a9f8dee4ea1707a6")
require.NoError(t, err)
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
actual, err := DeriveTokenID(client, test.input)
if test.err != "" {
require.EqualError(t, err, test.err)
} else {
require.NoError(t, err)
require.Equal(t, test.expected, actual)
}
})
}
}