@@ -6,6 +6,7 @@ const { getDomain } = require('../helpers/eip712');
66const { ERC4337Helper } = require ( '../helpers/erc4337' ) ;
77const { NonNativeSigner, P256SigningKey, RSASHA256SigningKey, MultiERC7913SigningKey } = require ( '../helpers/signers' ) ;
88const { PackedUserOperation } = require ( '../helpers/eip712-types' ) ;
9+ const { MAX_UINT64 } = require ( '../helpers/constants' ) ;
910
1011const { shouldBehaveLikeAccountCore, shouldBehaveLikeAccountHolder } = require ( './Account.behavior' ) ;
1112const { shouldBehaveLikeERC1271 } = require ( '../utils/cryptography/ERC1271.behavior' ) ;
@@ -292,5 +293,20 @@ describe('AccountMultiSignerWeighted', function () {
292293 . withArgs ( signer1 )
293294 . to . not . emit ( this . mock , 'ERC7913SignerWeightChanged' ) ;
294295 } ) ;
296+
297+ it ( 'should revert if total weight to overflow (_setSignerWeights)' , async function ( ) {
298+ await expect ( this . mock . $_setSignerWeights ( [ signer1 , signer2 , signer3 ] , [ 1n , 1n , MAX_UINT64 - 1n ] ) )
299+ . to . be . revertedWithCustomError ( this . mock , 'SafeCastOverflowedUintDowncast' )
300+ . withArgs ( 64 , MAX_UINT64 + 1n ) ;
301+ } ) ;
302+
303+ it ( 'should revert if total weight to overflow (_addSigner)' , async function ( ) {
304+ await this . mock . $_setSignerWeights ( [ signer1 , signer2 , signer3 ] , [ 1n , 1n , MAX_UINT64 - 2n ] ) ;
305+ await expect ( this . mock . totalWeight ( ) ) . to . eventually . equal ( MAX_UINT64 ) ;
306+
307+ await expect ( this . mock . $_addSigners ( [ signer4 ] ) )
308+ . to . be . revertedWithCustomError ( this . mock , 'SafeCastOverflowedUintDowncast' )
309+ . withArgs ( 64 , MAX_UINT64 + 1n ) ;
310+ } ) ;
295311 } ) ;
296312} ) ;
0 commit comments