forked from hukkin/cosmosvanity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
53 lines (44 loc) · 1.74 KB
/
main_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
package main
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestGenerateWallet(t *testing.T) {
w := generateWallet()
require.Equal(t, w.Address[:7], "cosmos1", "Incorrect bech32 prefix")
require.Equal(t, len(w.Address), 45, "Incorrect privkey length")
require.Equal(t, len(w.Pubkey), 33, "Incorrect pubkey length")
require.Equal(t, len(w.Privkey), 32, "Incorrect privkey length")
}
func TestStartsWith(t *testing.T) {
m := matcher{StartsWith: "aaaa"}
require.True(t, m.Match("cosmos1aaaaqztg6eu45nlljp0wp947juded46aln83kr"))
require.False(t, m.Match("cosmos1aaa9qztg6eu45nlljp0wp947juded46aln83kr"))
}
func TestEndsWith(t *testing.T) {
m := matcher{EndsWith: "8888"}
require.True(t, m.Match("cosmos14sy657pp6tgclhgqnl3dkwzwu3ewt4cf3f8888"))
require.False(t, m.Match("cosmos14sy657pp6tgclhgqnl3dkwzwu3ewt4cf3ff888"))
}
func TestContains(t *testing.T) {
m := matcher{Contains: "k2k2k"}
require.True(t, m.Match("cosmos1s6rlmknaj3swdd7hua6s852sk2k2k409a3z9f9"))
require.False(t, m.Match("cosmos14sy657pp6tgclhgqnl3dkwzwu3ewt4cf3ff888"))
}
func TestLetters(t *testing.T) {
m := matcher{Letters: 38}
require.True(t, m.Match("cosmos1gcjsgsglhacarlumkjzywedykkvkuvrzqlnlxd"))
require.False(t, m.Match("cosmos1gcjsgsglhacarlumkjzywedykkvkuvrzqlnlx8"))
}
func TestDigits(t *testing.T) {
m := matcher{Digits: 26}
require.True(t, m.Match("cosmos1j666m3qz66t786s48t540536465p56zrve5893"))
require.False(t, m.Match("cosmos1j666m3qz66t786s48t540536465p56zrve589z"))
}
func TestFindMatchingWalletConcurrent(t *testing.T) {
goroutineCount := 5
lastChars := "zz"
m := matcher{EndsWith: lastChars}
w := findMatchingWalletConcurrent(m, goroutineCount)
require.Equal(t, w.Address[len(w.Address)-len(lastChars):], lastChars, "Incorrect address suffix")
}