-
Notifications
You must be signed in to change notification settings - Fork 32
/
contract_test.go
51 lines (41 loc) · 1.25 KB
/
contract_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
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 contractConfigFixture() config.ContractConfig {
return config.ContractConfig{
Address: mocks.MockAddress().String(),
StartBlock: gofakeit.Uint64(),
RefreshRate: gofakeit.Uint64(),
}
}
func (c ConfigSuite) TestAddress() {
contractConfig := contractConfigFixture()
contractConfig.Address = ""
ok, err := contractConfig.IsValid()
False(c.T(), ok)
ErrorIs(c.T(), err, config.ErrRequiredField)
}
func (c ConfigSuite) TestRefreshRate() {
contractConfig := contractConfigFixture()
contractConfig.Address = ""
ok, err := contractConfig.IsValid()
False(c.T(), ok)
ErrorIs(c.T(), err, config.ErrRequiredField)
}
func (c ConfigSuite) TestContractConfigDuplicateAddress() {
contractConfigA := contractConfigFixture()
contractConfigB := contractConfigFixture()
// manually set these to the same id
contractConfigB.Address = contractConfigA.Address
contractConfigs := config.ContractConfigs{
contractConfigA,
contractConfigB,
}
ok, err := contractConfigs.IsValid()
False(c.T(), ok)
ErrorIs(c.T(), err, config.ErrDuplicateAddress)
}