@@ -260,6 +260,38 @@ describe("WalletAddress", () => {
260260 ) ;
261261 } ) ;
262262
263+ describe ( "#setKey" , ( ) => {
264+ it ( "should set the key successfully" , ( ) => {
265+ key = ethers . Wallet . createRandom ( ) ;
266+ const newAddress = new WalletAddress ( VALID_ADDRESS_MODEL , undefined ) ;
267+ expect ( ( ) => {
268+ newAddress . setKey ( key ) ;
269+ } ) . not . toThrow ( Error ) ;
270+ } ) ;
271+ it ( "should not set the key successfully" , ( ) => {
272+ key = ethers . Wallet . createRandom ( ) ;
273+ const newAddress = new WalletAddress ( VALID_ADDRESS_MODEL , key ) ;
274+ expect ( ( ) => {
275+ newAddress . setKey ( key ) ;
276+ } ) . toThrow ( Error ) ;
277+ } ) ;
278+ } ) ;
279+
280+ describe ( "#export" , ( ) => {
281+ it ( "should get the private key if it is set" , ( ) => {
282+ key = ethers . Wallet . createRandom ( ) ;
283+ const newAddress = new WalletAddress ( VALID_ADDRESS_MODEL , key ) ;
284+ expect ( newAddress . export ( ) ) . toEqual ( key . privateKey ) ;
285+ } ) ;
286+
287+ it ( "should not get the private key if not set" , ( ) => {
288+ const newAddress = new WalletAddress ( VALID_ADDRESS_MODEL , undefined ) ;
289+ expect ( ( ) => {
290+ newAddress . export ( ) ;
291+ } ) . toThrow ( Error ) ;
292+ } ) ;
293+ } ) ;
294+
263295 describe ( "#stakingOperation" , ( ) => {
264296 key = ethers . Wallet . createRandom ( ) ;
265297 const newAddress = newAddressModel ( "" , randomUUID ( ) , Coinbase . networks . EthereumHolesky ) ;
@@ -1071,23 +1103,6 @@ describe("WalletAddress", () => {
10711103 ) . rejects . toThrow ( Error ) ;
10721104 } ) ;
10731105 } ) ;
1074-
1075- describe ( "#setKey" , ( ) => {
1076- it ( "should set the key successfully" , ( ) => {
1077- key = ethers . Wallet . createRandom ( ) ;
1078- const newAddress = new WalletAddress ( VALID_ADDRESS_MODEL , undefined ) ;
1079- expect ( ( ) => {
1080- newAddress . setKey ( key ) ;
1081- } ) . not . toThrow ( Error ) ;
1082- } ) ;
1083- it ( "should not set the key successfully" , ( ) => {
1084- key = ethers . Wallet . createRandom ( ) ;
1085- const newAddress = new WalletAddress ( VALID_ADDRESS_MODEL , key ) ;
1086- expect ( ( ) => {
1087- newAddress . setKey ( key ) ;
1088- } ) . toThrow ( Error ) ;
1089- } ) ;
1090- } ) ;
10911106 } ) ;
10921107
10931108 describe ( "#createPayloadSignature" , ( ) => {
0 commit comments