-
Notifications
You must be signed in to change notification settings - Fork 32
/
config_test.go
52 lines (47 loc) · 1.27 KB
/
config_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
package config_test
import (
"github.com/Flaque/filet"
"github.com/brianvoe/gofakeit/v6"
. "github.com/stretchr/testify/assert"
etherMocks "github.com/synapsecns/sanguine/ethergo/mocks"
"github.com/synapsecns/sanguine/services/scribe/config"
)
func (c ConfigSuite) TestConfigEncodeDecode() {
// generate an example config
chainID := gofakeit.Uint32()
testConfig := config.Config{
Chains: config.ChainConfigs{
config.ChainConfig{
ChainID: chainID,
Contracts: config.ContractConfigs{
config.ContractConfig{
Address: etherMocks.MockAddress().String(),
StartBlock: gofakeit.Uint64(),
},
config.ContractConfig{
Address: etherMocks.MockAddress().String(),
StartBlock: gofakeit.Uint64(),
},
},
},
config.ChainConfig{
ChainID: chainID + 1,
Contracts: config.ContractConfigs{
config.ContractConfig{
Address: etherMocks.MockAddress().String(),
StartBlock: gofakeit.Uint64(),
},
},
},
},
RPCURL: gofakeit.URL(),
}
encodedConfig, err := testConfig.Encode()
Nil(c.T(), err)
file := filet.TmpFile(c.T(), "", string(encodedConfig))
decodedConfig, err := config.DecodeConfig(file.Name())
Nil(c.T(), err)
ok, err := decodedConfig.IsValid()
True(c.T(), ok)
Nil(c.T(), err)
}