-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathchain_test.go
45 lines (38 loc) · 1.05 KB
/
chain_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
package config_test
import (
"github.com/brianvoe/gofakeit/v6"
. "github.com/stretchr/testify/assert"
"github.com/synapsecns/sanguine/ethergo/mocks"
"github.com/synapsecns/sanguine/services/scribe/config"
)
func chainConfigFixture() config.ChainConfig {
return config.ChainConfig{
ChainID: gofakeit.Uint32(),
Contracts: config.ContractConfigs{
config.ContractConfig{
Address: mocks.MockAddress().String(),
StartBlock: gofakeit.Uint64(),
},
},
}
}
func (c ConfigSuite) TestChainID() {
chainConfig := chainConfigFixture()
chainConfig.ChainID = 0
ok, err := chainConfig.IsValid()
False(c.T(), ok)
ErrorIs(c.T(), err, config.ErrInvalidChainID)
}
func (c ConfigSuite) TestChainConfigsDuplicateChainID() {
chainConfigA := chainConfigFixture()
chainConfigB := chainConfigFixture()
// manually set these to the same id
chainConfigB.ChainID = chainConfigA.ChainID
chainConfigs := config.ChainConfigs{
chainConfigA,
chainConfigB,
}
ok, err := chainConfigs.IsValid()
False(c.T(), ok)
ErrorIs(c.T(), err, config.ErrDuplicateChainID)
}