@@ -672,4 +672,58 @@ describe('EthLikeCoin', function () {
672672 transaction . halfSigned ?. should . have . property ( 'recipients' ) ;
673673 } ) ;
674674 } ) ;
675+
676+ describe ( 'Common parameter handling' , function ( ) {
677+ it ( 'should handle plain object common parameter for BASE chain' , function ( ) {
678+ const baseCoin = bitgo . coin ( 'baseeth' ) as EthLikeCoin ;
679+
680+ const plainCommon = { chain : 8453 , hardfork : 'london' } ;
681+
682+ const txBuilder = ( baseCoin as any ) . getTransactionBuilder ( plainCommon ) ;
683+ txBuilder . should . be . an . instanceof ( EthLikeTransactionBuilder ) ;
684+ } ) ;
685+
686+ it ( 'should handle plain object common parameter with chainId property' , function ( ) {
687+ const baseCoin = bitgo . coin ( 'baseeth' ) as EthLikeCoin ;
688+
689+ const plainCommon = { chainId : 8453 , hardfork : 'london' } ;
690+
691+ const txBuilder = ( baseCoin as any ) . getTransactionBuilder ( plainCommon ) ;
692+ txBuilder . should . be . an . instanceof ( EthLikeTransactionBuilder ) ;
693+ } ) ;
694+
695+ it ( 'should handle EthereumCommon instance' , function ( ) {
696+ const baseCoin = bitgo . coin ( 'baseeth' ) as EthLikeCoin ;
697+
698+ const txBuilder = ( baseCoin as any ) . getTransactionBuilder ( baseChainCommon ) ;
699+ txBuilder . should . be . an . instanceof ( EthLikeTransactionBuilder ) ;
700+ } ) ;
701+
702+ it ( 'should require common parameter and throw error when undefined' , function ( ) {
703+ const baseCoin = bitgo . coin ( 'baseeth' ) as EthLikeCoin ;
704+
705+ ( ( ) => {
706+ ( baseCoin as any ) . getTransactionBuilder ( undefined ) ;
707+ } ) . should . throw ( 'Common must be provided for EthLikeTransactionBuilder' ) ;
708+ } ) ;
709+
710+ it ( 'should convert plain object common to EthereumCommon with working gteHardfork method' , function ( ) {
711+ const baseCoin = bitgo . coin ( 'baseeth' ) as EthLikeCoin ;
712+
713+ const plainCommon = { chain : 8453 , hardfork : 'london' } ;
714+
715+ const txBuilder = ( baseCoin as any ) . getTransactionBuilder ( plainCommon ) ;
716+ txBuilder . should . be . an . instanceof ( EthLikeTransactionBuilder ) ;
717+
718+ const common = ( txBuilder as any ) . _common ;
719+ common . should . not . be . undefined ;
720+
721+ common . should . have . property ( 'gteHardfork' ) ;
722+ ( typeof common . gteHardfork ) . should . equal ( 'function' ) ;
723+
724+ const result = common . gteHardfork ( 'homestead' ) ;
725+ ( typeof result ) . should . equal ( 'boolean' ) ;
726+ result . should . equal ( true ) ;
727+ } ) ;
728+ } ) ;
675729} ) ;
0 commit comments