@@ -393,6 +393,76 @@ def test_sign_transaction(capsys: Any):
393393 )
394394
395395
396+ def test_estimate_gas (capsys : Any ):
397+ return_code = main (
398+ [
399+ "tx" ,
400+ "new" ,
401+ "--pem" ,
402+ str (testdata_path / "alice.pem" ),
403+ "--receiver" ,
404+ "erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx" ,
405+ "--proxy" ,
406+ "https://devnet-gateway.multiversx.com" ,
407+ "--value" ,
408+ "1000000000000" ,
409+ ]
410+ )
411+ assert return_code == 0
412+
413+ tx = _read_stdout (capsys )
414+ tx_json = json .loads (tx )["emittedTransaction" ]
415+ assert tx_json ["gasLimit" ] == 50000
416+
417+
418+ def test_estimate_gas_for_guarded_tx (capsys : Any ):
419+ return_code = main (
420+ [
421+ "tx" ,
422+ "new" ,
423+ "--pem" ,
424+ str (testdata_path / "alice.pem" ),
425+ "--receiver" ,
426+ "erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx" ,
427+ "--proxy" ,
428+ "https://devnet-gateway.multiversx.com" ,
429+ "--value" ,
430+ "1000000000000" ,
431+ "--guardian" ,
432+ "erd1cqqxak4wun7508e0yj9ng843r6hv4mzd0hhpjpsejkpn9wa9yq8sj7u2u5" ,
433+ ]
434+ )
435+ assert return_code == 0
436+
437+ tx = _read_stdout (capsys )
438+ tx_json = json .loads (tx )["emittedTransaction" ]
439+ assert tx_json ["gasLimit" ] == 100000
440+
441+
442+ def test_estimate_gas_with_multiplier (capsys : Any ):
443+ return_code = main (
444+ [
445+ "tx" ,
446+ "new" ,
447+ "--pem" ,
448+ str (testdata_path / "alice.pem" ),
449+ "--receiver" ,
450+ "erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx" ,
451+ "--proxy" ,
452+ "https://devnet-gateway.multiversx.com" ,
453+ "--gas-limit-multiplier" ,
454+ "1.5" ,
455+ "--value" ,
456+ "1000000000000" ,
457+ ]
458+ )
459+ assert return_code == 0
460+
461+ tx = _read_stdout (capsys )
462+ tx_json = json .loads (tx )["emittedTransaction" ]
463+ assert tx_json ["gasLimit" ] == 75000
464+
465+
396466def _read_stdout (capsys : Any ) -> str :
397467 stdout : str = capsys .readouterr ().out .strip ()
398468 return stdout
0 commit comments