@@ -314,6 +314,56 @@ public async Task ExecuteTransaction_07_WhenAll_Success()
314
314
Assert . True ( hashes [ 1 ] . TransactionHash . Length == 66 ) ;
315
315
}
316
316
317
+ [ Fact ( Timeout = 120000 ) ]
318
+ public async Task SwitchNetwork_Success ( )
319
+ {
320
+ var smartWallet = await SmartWallet . Create ( personalWallet : await PrivateKeyWallet . Generate ( this . Client ) , chainId : 11155111 ) ;
321
+ var addy1 = await smartWallet . GetAddress ( ) ;
322
+ await smartWallet . SwitchNetwork ( 421614 ) ;
323
+ var addy2 = await smartWallet . GetAddress ( ) ;
324
+ Assert . Equal ( addy1 , addy2 ) ;
325
+ }
326
+
327
+ [ Fact ( Timeout = 120000 ) ]
328
+ public async Task SwitchNetwork_WithCustomFactory_ToZk_Success ( )
329
+ {
330
+ var smartWallet = await SmartWallet . Create ( personalWallet : await PrivateKeyWallet . Generate ( this . Client ) , chainId : 11155111 , factoryAddress : "0xc5A43D081Dc10316EE640504Ea1cBc74666F3874" ) ;
331
+ var addy1 = await smartWallet . GetAddress ( ) ;
332
+ await smartWallet . SwitchNetwork ( 300 ) ;
333
+ var addy2 = await smartWallet . GetAddress ( ) ;
334
+ Assert . NotEqual ( addy1 , addy2 ) ;
335
+ }
336
+
337
+ [ Fact ( Timeout = 120000 ) ]
338
+ public async Task SwitchNetwork_WithCustomFactory_FromZk_Success ( )
339
+ {
340
+ var smartWallet = await SmartWallet . Create ( personalWallet : await PrivateKeyWallet . Generate ( this . Client ) , chainId : 300 , factoryAddress : "0xc5A43D081Dc10316EE640504Ea1cBc74666F3874" ) ;
341
+ var addy1 = await smartWallet . GetAddress ( ) ;
342
+ await smartWallet . SwitchNetwork ( 11155111 ) ;
343
+ var addy2 = await smartWallet . GetAddress ( ) ;
344
+ Assert . NotEqual ( addy1 , addy2 ) ;
345
+ }
346
+
347
+ [ Fact ( Timeout = 120000 ) ]
348
+ public async Task SwitchNetwork_ZkToNonZkSuccess ( )
349
+ {
350
+ var smartWallet = await SmartWallet . Create ( personalWallet : await PrivateKeyWallet . Generate ( this . Client ) , chainId : 300 ) ;
351
+ var addy1 = await smartWallet . GetAddress ( ) ;
352
+ await smartWallet . SwitchNetwork ( 421614 ) ;
353
+ var addy2 = await smartWallet . GetAddress ( ) ;
354
+ Assert . NotEqual ( addy1 , addy2 ) ;
355
+ }
356
+
357
+ [ Fact ( Timeout = 120000 ) ]
358
+ public async Task SwitchNetwork_NonZkToZk_Success ( )
359
+ {
360
+ var smartWallet = await SmartWallet . Create ( personalWallet : await PrivateKeyWallet . Generate ( this . Client ) , chainId : 421614 ) ;
361
+ var addy1 = await smartWallet . GetAddress ( ) ;
362
+ await smartWallet . SwitchNetwork ( 300 ) ;
363
+ var addy2 = await smartWallet . GetAddress ( ) ;
364
+ Assert . NotEqual ( addy1 , addy2 ) ;
365
+ }
366
+
317
367
[ Fact ( Timeout = 120000 ) ]
318
368
public async Task MultiChainTransaction_Success ( )
319
369
{
@@ -322,13 +372,15 @@ public async Task MultiChainTransaction_Success()
322
372
323
373
var smartWallet = await SmartWallet . Create ( personalWallet : await PrivateKeyWallet . Generate ( this . Client ) , chainId : chainId1 , gasless : true ) ;
324
374
325
- var address1 = await smartWallet . GetAddress ( ) ;
326
- var receipt1 = await smartWallet . ExecuteTransaction ( new ThirdwebTransactionInput ( chainId1 ) { To = address1 , } ) ;
375
+ var randomAddy = await ( await PrivateKeyWallet . Generate ( this . Client ) ) . GetAddress ( ) ;
376
+
377
+ var receipt1 = await smartWallet . ExecuteTransaction ( new ThirdwebTransactionInput ( chainId1 ) { To = randomAddy , } ) ;
327
378
var nonce1 = await smartWallet . GetTransactionCount ( chainId : chainId1 , blocktag : "latest" ) ;
379
+ var address1 = await smartWallet . GetAddress ( ) ;
328
380
329
- var address2 = await smartWallet . GetAddress ( ) ;
330
- var receipt2 = await smartWallet . ExecuteTransaction ( new ThirdwebTransactionInput ( chainId2 ) { To = address2 , } ) ;
381
+ var receipt2 = await smartWallet . ExecuteTransaction ( new ThirdwebTransactionInput ( chainId2 ) { To = randomAddy , } ) ;
331
382
var nonce2 = await smartWallet . GetTransactionCount ( chainId : chainId2 , blocktag : "latest" ) ;
383
+ var address2 = await smartWallet . GetAddress ( ) ;
332
384
333
385
Assert . NotNull ( address1 ) ;
334
386
Assert . NotNull ( address2 ) ;
0 commit comments