-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmessage_test.go
56 lines (47 loc) · 1.21 KB
/
message_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
package sequence_test
import (
"testing"
"github.com/0xsequence/go-sequence"
"github.com/stretchr/testify/assert"
)
func TestIsEIP191Message(t *testing.T) {
t.Run("EIP191", func(t *testing.T) {
// EIP191 message
msg := []byte("\x19Ethereum Signed Message:\n5hello")
ok := sequence.IsEIP191Message(msg)
if !ok {
t.Error("expected EIP191 message")
}
})
t.Run("non-EIP191", func(t *testing.T) {
// non-EIP191 message
msg := []byte("hello")
ok := sequence.IsEIP191Message(msg)
if ok {
t.Error("expected non-EIP191 message")
}
})
t.Run("empty-EIP191", func(t *testing.T) {
// non-EIP191 message
msg := []byte("")
ok := sequence.IsEIP191Message(msg)
if ok {
t.Error("expected non-EIP191 message")
}
})
}
func TestMessageToEIP191(t *testing.T) {
t.Run("EIP191_none", func(t *testing.T) {
// EIP191 message
msg := []byte("hello")
expectedEIP191 := []byte("\x19Ethereum Signed Message:\n5hello")
eip191 := sequence.MessageToEIP191(msg)
assert.Equal(t, eip191, expectedEIP191)
})
t.Run("EIP191_already", func(t *testing.T) {
// EIP191 message
msg := []byte("\x19Ethereum Signed Message:\n5hello")
eip191 := sequence.MessageToEIP191(msg)
assert.Equal(t, msg, eip191)
})
}