forked from omni-network/omni
-
Notifications
You must be signed in to change notification settings - Fork 0
/
abi_internal_test.go
53 lines (40 loc) · 1.14 KB
/
abi_internal_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 xchain
import (
"encoding/hex"
"testing"
"github.com/omni-network/omni/lib/tutil"
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/require"
)
//go:generate go test . -golden -clean
func TestEncodeMsg(t *testing.T) {
t.Parallel()
msg := Msg{
MsgID: MsgID{
StreamID: StreamID{
SourceChainID: 1,
DestChainID: 2,
},
StreamOffset: 100,
},
SourceMsgSender: common.HexToAddress("0xcbbc5Da52ea2728279560Dca8f4ec08d5F829985"),
DestAddress: common.HexToAddress("0x9CC971e84FE5d09d0967f15AE05dfd553C5A1FA6"),
Data: common.Hex2Bytes("d09de08a"),
DestGasLimit: 250_000,
TxHash: common.Hash{},
}
packed, err := encodeMsg(msg)
require.NoError(t, err)
tutil.RequireGoldenBytes(t, []byte(hex.EncodeToString(packed)))
}
func TestEncodeHeader(t *testing.T) {
t.Parallel()
header := BlockHeader{
SourceChainID: 1,
BlockHeight: 100,
BlockHash: common.HexToHash("0x412d62a6a3115ab5a0e0cae9d63082ff8dfb002a98cc889d06dc986a9461586b"),
}
packed, err := encodeHeader(header)
require.NoError(t, err)
tutil.RequireGoldenBytes(t, []byte(hex.EncodeToString(packed)))
}