@@ -17,9 +17,8 @@ def setUpClass(cls):
17
17
super ().setUpClass ()
18
18
cls .mainnet_gnosis_protocol_api = GnosisProtocolAPI (EthereumNetwork .MAINNET )
19
19
cls .goerli_gnosis_protocol_api = GnosisProtocolAPI (EthereumNetwork .GOERLI )
20
- cls .gno_token_address = "0x6810e776880C02933D47DB1b9fc05908e5386b96"
21
- cls .weth_token_address = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
22
- cls .rinkeby_dai_address = "0x5592EC0cfb4dbc12D3aB100b257153436a1f0FEa"
20
+ cls .mainnet_gno_token_address = "0x6810e776880C02933D47DB1b9fc05908e5386b96"
21
+ cls .goerli_cow_token_address = "0x3430d04E42a722c5Ae52C5Bffbf1F230C2677600"
23
22
24
23
def test_api_is_available (self ):
25
24
random_owner = Account .create ().address
@@ -36,7 +35,10 @@ def test_api_is_available(self):
36
35
def test_get_estimated_amount (self ):
37
36
gnosis_protocol_api = GnosisProtocolAPI (EthereumNetwork .MAINNET )
38
37
response = gnosis_protocol_api .get_estimated_amount (
39
- self .gno_token_address , self .gno_token_address , OrderKind .SELL , 1
38
+ self .mainnet_gno_token_address ,
39
+ self .mainnet_gno_token_address ,
40
+ OrderKind .SELL ,
41
+ 1 ,
40
42
)
41
43
self .assertDictEqual (
42
44
response ,
@@ -48,26 +50,29 @@ def test_get_estimated_amount(self):
48
50
49
51
response = gnosis_protocol_api .get_estimated_amount (
50
52
"0x6820e776880c02933d47db1b9fc05908e5386b96" ,
51
- self .gno_token_address ,
53
+ self .mainnet_gno_token_address ,
52
54
OrderKind .SELL ,
53
55
1 ,
54
56
)
55
57
self .assertIn ("errorType" , response )
56
58
self .assertIn ("description" , response )
57
59
58
60
response = gnosis_protocol_api .get_estimated_amount (
59
- self .gno_token_address , self .weth_token_address , OrderKind .SELL , int (1e18 )
61
+ self .mainnet_gno_token_address ,
62
+ self .mainnet_gnosis_protocol_api .weth_address ,
63
+ OrderKind .SELL ,
64
+ int (1e18 ),
60
65
)
61
66
amount = int (response ["amount" ]) / 1e18
62
67
self .assertGreater (amount , 0 )
63
68
self .assertLess (amount , 1 )
64
69
65
70
def test_get_fee (self ):
66
71
order = Order (
67
- sellToken = self .gno_token_address ,
68
- buyToken = self .gno_token_address ,
72
+ sellToken = self .mainnet_gno_token_address ,
73
+ buyToken = self .mainnet_gno_token_address ,
69
74
receiver = NULL_ADDRESS ,
70
- sellAmount = 1 ,
75
+ sellAmount = int ( 1e18 ) ,
71
76
buyAmount = 1 ,
72
77
validTo = int (time ()) + 3600 ,
73
78
appData = Web3 .keccak (text = "hola" ),
@@ -77,7 +82,18 @@ def test_get_fee(self):
77
82
sellTokenBalance = "erc20" ,
78
83
buyTokenBalance = "erc20" ,
79
84
)
80
- self .assertGreaterEqual (self .goerli_gnosis_protocol_api .get_fee (order ), 0 )
85
+ from_address = Account .create ().address
86
+ self .assertEqual (
87
+ self .mainnet_gnosis_protocol_api .get_fee (order , from_address ),
88
+ {
89
+ "errorType" : "SameBuyAndSellToken" ,
90
+ "description" : "Buy token is the same as the sell token." ,
91
+ },
92
+ )
93
+ order .buyToken = self .mainnet_gnosis_protocol_api .weth_address
94
+ self .assertGreaterEqual (
95
+ self .mainnet_gnosis_protocol_api .get_fee (order , from_address ), 0
96
+ )
81
97
82
98
def test_get_trades (self ):
83
99
mainnet_order_ui = "0x65F1206182C77A040ED41D507B59C622FA94AB5E71CCA567202CFF3909F3D5C4DBE338E45276630FD8237149DD47EE027AF26F9C619723D0"
@@ -101,8 +117,8 @@ def test_get_trades(self):
101
117
102
118
def test_place_order (self ):
103
119
order = Order (
104
- sellToken = self .gno_token_address ,
105
- buyToken = self .gno_token_address ,
120
+ sellToken = self .mainnet_gno_token_address ,
121
+ buyToken = self .mainnet_gno_token_address ,
106
122
receiver = NULL_ADDRESS ,
107
123
sellAmount = 1 ,
108
124
buyAmount = 1 ,
@@ -129,7 +145,7 @@ def test_place_order(self):
129
145
)
130
146
131
147
order .sellToken = self .goerli_gnosis_protocol_api .weth_address
132
- order .buyToken = self .rinkeby_dai_address
148
+ order .buyToken = self .goerli_cow_token_address
133
149
order_id = self .goerli_gnosis_protocol_api .place_order (
134
150
order , Account ().create ().key
135
151
)
0 commit comments