11from crypto .transactions .builder .transfer_builder import TransferBuilder
2+ from crypto .utils .unit_converter import UnitConverter
23
34def test_it_should_sign_it_with_a_passphrase (passphrase , load_transaction_fixture ):
45 fixture = load_transaction_fixture ('transfer' )
@@ -19,11 +20,29 @@ def test_it_should_sign_it_with_a_passphrase(passphrase, load_transaction_fixtur
1920 assert builder .transaction .data ['network' ] == fixture ['data' ]['network' ]
2021 assert builder .transaction .data ['gasLimit' ] == fixture ['data' ]['gasLimit' ]
2122 assert builder .transaction .data ['recipientAddress' ] == fixture ['data' ]['recipientAddress' ]
22- assert builder .transaction .data ['value' ] == fixture ['data' ]['value' ]
23+ assert builder .transaction .data ['value' ] == int ( fixture ['data' ]['value' ])
2324 assert builder .transaction .data ['v' ] == fixture ['data' ]['v' ]
2425 assert builder .transaction .data ['r' ] == fixture ['data' ]['r' ]
2526 assert builder .transaction .data ['s' ] == fixture ['data' ]['s' ]
2627
2728 assert builder .transaction .serialize ().hex () == fixture ['serialized' ]
2829 assert builder .transaction .data ['id' ] == fixture ['data' ]['id' ]
2930 assert builder .verify ()
31+
32+ def test_it_should_handle_unit_converter (passphrase , address ):
33+ builder = (
34+ TransferBuilder ()
35+ .gas_price (UnitConverter .parse_units (5 , 'gwei' ))
36+ .nonce ('1' )
37+ .gas_limit (UnitConverter .parse_units (0.1 , 'gwei' ))
38+ .recipient_address (address )
39+ .value (UnitConverter .parse_units (10 , 'ark' ))
40+ .sign (passphrase )
41+ )
42+
43+ assert builder .transaction .data ['gasPrice' ] == 5000000000
44+ assert builder .transaction .data ['nonce' ] == '1'
45+ assert builder .transaction .data ['gasLimit' ] == 100000000
46+ assert builder .transaction .data ['value' ] == 10000000000000000000
47+
48+ assert builder .verify ()
0 commit comments