@@ -29,52 +29,45 @@ class TestMsgEthereumUniswaptxERC20(common.KeepKeyTest):
2929
3030 def setUp (self ):
3131 super (TestMsgEthereumUniswaptxERC20 , self ).setUp ()
32- # Every test in this file approves or spends against the ETH/FOX pool,
33- # whose contract is NOT in the token table. Approving an unknown token
34- # contract does not complete on the emulator: the device never returns,
35- # so these tests HANG instead of failing, and CI kills the whole run on
36- # its no-output timeout -- taking every later test with it.
37- #
38- # This is a firmware-side limitation, not a gap in the tests. It is
39- # gated here rather than deleted so the coverage returns automatically
40- # once the firmware completes this path. Known-token approves
41- # (test_msg_ethereum_erc20_approve) run here and pass; on real hardware
42- # this path is exercised by the app.
43- if self .client .features .firmware_variant [0 :8 ] == "Emulator" :
44- self .skipTest (
45- "Uniswap liquidity against an unknown token contract does not "
46- "complete on the emulator" )
47-
32+ # Canonical 7.15 routes unknown token contracts through explicitly
33+ # authorized raw review. Exercise that path instead of an emulator skip.
34+ self .requires_firmware ("7.15.0" )
35+
4836 def test_sign_uni_approve_liquidity_ETH (self ):
4937 self .requires_fullFeature ()
5038 self .requires_firmware ("7.1.0" )
5139 self .setup_mnemonic_nopin_nopassphrase ()
40+ self .client .apply_policy ("AdvancedMode" , 1 )
5241
53- # Approval tx for the ETH/FOX pool
54- sig_v , sig_r , sig_s = self .client .ethereum_sign_tx (
55- n = [2147483692 ,2147483708 ,2147483648 ,0 ,0 ],
56- nonce = 0xf ,
57- gas_price = 0x2980872680 ,
58- gas_limit = 0xbd0e ,
59- value = 0x0 ,
60- to = binascii .unhexlify ('470e8de2ebaef52014a47cb5e6af86884947f08c' ), # fox pool
61- address_type = 0 ,
62- chain_id = 1 ,
63- # The data below is generally broken into 32-byte chunks except for the function selector (4 bytes_ and
64- # keccak signatures (4 bytes)
65- data = binascii .unhexlify ('095ea7b3' + # approve
66- '0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d' + # uniswap v2: router 2 contract address
67- 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' ) # approve amount
42+ # Unlimited approval is deliberately disabled on canonical 7.15.
43+ # This legacy vector must be refused, not skipped or signed.
44+ with self .assertRaises (CallException ) as caught :
45+ self .client .ethereum_sign_tx (
46+ n = [2147483692 ,2147483708 ,2147483648 ,0 ,0 ],
47+ nonce = 0xf ,
48+ gas_price = 0x2980872680 ,
49+ gas_limit = 0xbd0e ,
50+ value = 0x0 ,
51+ to = binascii .unhexlify ('470e8de2ebaef52014a47cb5e6af86884947f08c' ), # fox pool
52+ address_type = 0 ,
53+ chain_id = 1 ,
54+ # The data below is generally broken into 32-byte chunks except for the function selector (4 bytes_ and
55+ # keccak signatures (4 bytes)
56+ data = binascii .unhexlify ('095ea7b3' + # approve
57+ '0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d' + # uniswap v2: router 2 contract address
58+ 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' ) # approve amount
59+
60+ )
61+ self .assertEqual (caught .exception .args [0 ],
62+ proto_types .Failure_ActionCancelled )
63+ self .assertIn ("Unlimited ERC20 approval is disabled" ,
64+ str (caught .exception ))
6865
69- )
70- self .assertEqual (sig_v , 38 )
71- self .assertEqual (binascii .hexlify (sig_r ), '7f7a5ce501371a01ead394d2186385742d5fbdc3d85da98249d2a05043ac6d5a' )
72- self .assertEqual (binascii .hexlify (sig_s ), '329954b284ed1df9a6242820e793b9719c0c6c21cae5f90190ce61c7f73c731e' )
73-
7466 def test_sign_uni_add_liquidity_ETH (self ):
7567 self .requires_fullFeature ()
7668 self .requires_firmware ("7.1.0" )
7769 self .setup_mnemonic_nopin_nopassphrase ()
70+ self .client .apply_policy ("AdvancedMode" , 1 )
7871
7972 # Add liquidity to ETH/FOX pool
8073 sig_v , sig_r , sig_s = self .client .ethereum_sign_tx (
@@ -86,7 +79,7 @@ def test_sign_uni_add_liquidity_ETH(self):
8679 to = binascii .unhexlify ('7a250d5630B4cF539739dF2C5dAcb4c659F2488D' ), # UNISWAP router
8780 address_type = 0 ,
8881 chain_id = 1 ,
89- # The data below is generally broken into 32-byte chunks except for the function selector (4 bytes_ and
82+ # The data below is generally broken into 32-byte chunks except for the function selector (4 bytes_ and
9083 # keccak signatures (4 bytes)
9184 data = binascii .unhexlify ('f305d719' + # addLiquidityETH
9285 '000000000000000000000000c770eefad204b5180df6a14ee197d99d808ee52d' + # FOX token
@@ -95,15 +88,16 @@ def test_sign_uni_add_liquidity_ETH(self):
9588 '0000000000000000000000000000000000000000000000000000fb98b65aba40' + # min amount of eth token
9689 '0000000000000000000000003f2329C9ADFbcCd9A84f52c906E936A42dA18CB8' + # eth address (self)
9790 '00000000000000000000000000000000000000000000000000000178a9380e5f' ) # deadline
98- )
91+ )
9992 self .assertEqual (sig_v , 37 )
100- self .assertEqual (binascii .hexlify (sig_r ), '8547542bc74c0dcc6ca8b02a79e0dccd336856d8c48376289a2a697d864a5892' )
101- self .assertEqual (binascii .hexlify (sig_s ), '0a8eec6856aef8caa234240b06862976f8e238e8b24f5c989279507dd7e51ccd' )
93+ self .assertEqual (binascii .hexlify (sig_r ). decode ( "ascii" ) , '8547542bc74c0dcc6ca8b02a79e0dccd336856d8c48376289a2a697d864a5892' )
94+ self .assertEqual (binascii .hexlify (sig_s ). decode ( "ascii" ) , '0a8eec6856aef8caa234240b06862976f8e238e8b24f5c989279507dd7e51ccd' )
10295
10396 def test_sign_uni_remove_liquidity_ETH (self ):
10497 self .requires_fullFeature ()
10598 self .requires_firmware ("7.1.0" )
10699 self .setup_mnemonic_nopin_nopassphrase ()
100+ self .client .apply_policy ("AdvancedMode" , 1 )
107101
108102 # remove liquidity from the ETH/FOX pool
109103 sig_v , sig_r , sig_s = self .client .ethereum_sign_tx (
@@ -115,7 +109,7 @@ def test_sign_uni_remove_liquidity_ETH(self):
115109 to = binascii .unhexlify ('7a250d5630B4cF539739dF2C5dAcb4c659F2488D' ), # UNISWAP router
116110 address_type = 0 ,
117111 chain_id = 1 ,
118- # The data below is generally broken into 32-byte chunks except for the function selector (4 bytes_ and
112+ # The data below is generally broken into 32-byte chunks except for the function selector (4 bytes_ and
119113 # keccak signatures (4 bytes)
120114 data = binascii .unhexlify ('02751cec' + # addLiquidityETH
121115 '000000000000000000000000c770eefad204b5180df6a14ee197d99d808ee52d' + # FOX token
@@ -124,10 +118,10 @@ def test_sign_uni_remove_liquidity_ETH(self):
124118 '0000000000000000000000000000000000000000000000000000fb04c77f3e94' + # min amount of eth token
125119 '0000000000000000000000005028d647b74f12903e6d5f3969f8f624e6a9a93d' + # to address (not self)
126120 '00000000000000000000000000000000000000000000000000000178b2062f3d' ) # deadline
127- )
121+ )
128122 self .assertEqual (sig_v , 37 )
129- self .assertEqual (binascii .hexlify (sig_r ), '7143f0d8e5505a8cfb1df55e9c5d7433eba33a61959137c08cc5c088ec12ab5d' )
130- self .assertEqual (binascii .hexlify (sig_s ), '20b456d6c13295f5abb6109d7ade2c5d5fc395963b1e45d92e6dc8c33749c517' )
123+ self .assertEqual (binascii .hexlify (sig_r ). decode ( "ascii" ) , '7143f0d8e5505a8cfb1df55e9c5d7433eba33a61959137c08cc5c088ec12ab5d' )
124+ self .assertEqual (binascii .hexlify (sig_s ). decode ( "ascii" ) , '20b456d6c13295f5abb6109d7ade2c5d5fc395963b1e45d92e6dc8c33749c517' )
131125
132126if __name__ == '__main__' :
133127 unittest .main ()
0 commit comments