@@ -10,7 +10,7 @@ import (
10
10
appflags "github.com/dydxprotocol/v4-chain/protocol/app/flags"
11
11
"github.com/dydxprotocol/v4-chain/protocol/daemons/bridge/client"
12
12
d_constants "github.com/dydxprotocol/v4-chain/protocol/daemons/constants"
13
- "github.com/dydxprotocol/v4-chain/protocol/daemons/flags"
13
+ daemonflags "github.com/dydxprotocol/v4-chain/protocol/daemons/flags"
14
14
"github.com/dydxprotocol/v4-chain/protocol/mocks"
15
15
"github.com/dydxprotocol/v4-chain/protocol/testutil/appoptions"
16
16
"github.com/dydxprotocol/v4-chain/protocol/testutil/constants"
@@ -21,18 +21,38 @@ import (
21
21
"github.com/stretchr/testify/require"
22
22
)
23
23
24
+ func TestStart_EthRpcEndpointNotSet (t * testing.T ) {
25
+ errorMsg := "flag bridge-daemon-eth-rpc-endpoint is not set"
26
+
27
+ require .EqualError (
28
+ t ,
29
+ client .Start (
30
+ grpc .Ctx ,
31
+ daemonflags .GetDefaultDaemonFlags (),
32
+ appflags .GetFlagValuesFromOptions (appoptions .GetDefaultTestAppOptions ("" , nil )),
33
+ log .NewNopLogger (),
34
+ & mocks.GrpcClient {},
35
+ ),
36
+ errorMsg ,
37
+ )
38
+ }
39
+
24
40
func TestStart_TcpConnectionFails (t * testing.T ) {
25
41
errorMsg := "Failed to create connection"
26
42
27
43
// Mock the gRPC client to return an error when creating a TCP connection.
28
44
mockGrpcClient := & mocks.GrpcClient {}
29
45
mockGrpcClient .On ("NewTcpConnection" , grpc .Ctx , d_constants .DefaultGrpcEndpoint ).Return (nil , errors .New (errorMsg ))
30
46
47
+ // Override default daemon flags with a non-empty EthRpcEndpoint.
48
+ daemonFlagsWithEthRpcEndpoint := daemonflags .GetDefaultDaemonFlags ()
49
+ daemonFlagsWithEthRpcEndpoint .Bridge .EthRpcEndpoint = "http://localhost:8545"
50
+
31
51
require .EqualError (
32
52
t ,
33
53
client .Start (
34
54
grpc .Ctx ,
35
- flags . GetDefaultDaemonFlags () ,
55
+ daemonFlagsWithEthRpcEndpoint ,
36
56
appflags .GetFlagValuesFromOptions (appoptions .GetDefaultTestAppOptions ("" , nil )),
37
57
log .NewNopLogger (),
38
58
mockGrpcClient ,
@@ -56,11 +76,15 @@ func TestStart_UnixSocketConnectionFails(t *testing.T) {
56
76
mockGrpcClient .On ("NewGrpcConnection" , grpc .Ctx , grpc .SocketPath ).Return (nil , errors .New (errorMsg ))
57
77
mockGrpcClient .On ("CloseConnection" , grpc .GrpcConn ).Return (nil )
58
78
79
+ // Override default daemon flags with a non-empty EthRpcEndpoint.
80
+ daemonFlagsWithEthRpcEndpoint := daemonflags .GetDefaultDaemonFlags ()
81
+ daemonFlagsWithEthRpcEndpoint .Bridge .EthRpcEndpoint = "http://localhost:8545"
82
+
59
83
require .EqualError (
60
84
t ,
61
85
client .Start (
62
86
grpc .Ctx ,
63
- flags . GetDefaultDaemonFlags () ,
87
+ daemonFlagsWithEthRpcEndpoint ,
64
88
appflags .GetFlagValuesFromOptions (appoptions .GetDefaultTestAppOptions ("" , nil )),
65
89
log .NewNopLogger (),
66
90
mockGrpcClient ,
0 commit comments