@@ -1676,6 +1676,70 @@ casttest!(block_number_hash, |_prj, cmd| {
1676
1676
assert_eq!( s. trim( ) . parse:: <u64 >( ) . unwrap( ) , 1 , "{s}" )
1677
1677
} ) ;
1678
1678
1679
+ // Tests that `cast --disable-block-gas-limit` commands are working correctly for BSC
1680
+ // <https://github.com/foundry-rs/foundry/pull/9996>
1681
+ // Equivalent transaction on Binance Smart Chain Testnet:
1682
+ // <https://testnet.bscscan.com/tx/0x0db4f279fc4d47dca1e6ace180f45f50c5bf12e2b968f210c217f57031e02744>
1683
+ casttest ! ( run_disable_block_gas_limit_check, |_prj, cmd| {
1684
+ let bsc_testnet_rpc_url = next_rpc_endpoint( NamedChain :: BinanceSmartChainTestnet ) ;
1685
+
1686
+ let latest_block_json: serde_json:: Value = serde_json:: from_str(
1687
+ & cmd. args( [ "block" , "--rpc-url" , bsc_testnet_rpc_url. as_str( ) , "--json" ] )
1688
+ . assert_success( )
1689
+ . get_output( )
1690
+ . stdout_lossy( ) ,
1691
+ )
1692
+ . expect( "Failed to parse latest block" ) ;
1693
+
1694
+ let latest_excessive_gas_limit_tx =
1695
+ latest_block_json[ "transactions" ] . as_array( ) . and_then( |txs| {
1696
+ txs. iter( )
1697
+ . find( |tx| tx. get( "gas" ) . and_then( |gas| gas. as_str( ) ) == Some ( "0x7fffffffffffffff" ) )
1698
+ } ) ;
1699
+
1700
+ match latest_excessive_gas_limit_tx {
1701
+ Some ( tx) => {
1702
+ let tx_hash =
1703
+ tx. get( "hash" ) . and_then( |h| h. as_str( ) ) . expect( "Transaction missing hash" ) ;
1704
+
1705
+ // If --disable-block-gas-limit is not provided, the transaction should fail as the gas
1706
+ // limit exceeds the block gas limit.
1707
+ cmd. cast_fuse( )
1708
+ . args( [ "run" , "-v" , tx_hash, "--quick" , "--rpc-url" , bsc_testnet_rpc_url. as_str( ) ] )
1709
+ . assert_failure( )
1710
+ . stderr_eq( str ![ [ r#"
1711
+ Error: EVM error; transaction validation error: caller gas limit exceeds the block gas limit
1712
+
1713
+ "# ] ] ) ;
1714
+
1715
+ // If --disable-block-gas-limit is provided, the transaction should succeed
1716
+ // despite the gas limit exceeding the block gas limit.
1717
+ cmd. cast_fuse( )
1718
+ . args( [
1719
+ "run" ,
1720
+ "-v" ,
1721
+ tx_hash,
1722
+ "--quick" ,
1723
+ "--rpc-url" ,
1724
+ bsc_testnet_rpc_url. as_str( ) ,
1725
+ "--disable-block-gas-limit" ,
1726
+ ] )
1727
+ . assert_success( )
1728
+ . stdout_eq( str ![ [ r#"
1729
+ ...
1730
+ Transaction successfully executed.
1731
+ [GAS]
1732
+
1733
+ "# ] ] ) ;
1734
+ }
1735
+ None => {
1736
+ eprintln!(
1737
+ "Skipping test: No transaction with gas = 0x7fffffffffffffff found in the latest block."
1738
+ ) ;
1739
+ }
1740
+ }
1741
+ } ) ;
1742
+
1679
1743
casttest ! ( send_eip7702, async |_prj, cmd| {
1680
1744
let ( _api, handle) =
1681
1745
anvil:: spawn( NodeConfig :: test( ) . with_hardfork( Some ( EthereumHardfork :: PragueEOF . into( ) ) ) )
0 commit comments