@@ -5,58 +5,67 @@ import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
55import { nitroTestnodeL2 } from '../chains' ;
66import { arbOwnerPublicActions } from './arbOwnerPublicActions' ;
77import { getNitroTestnodePrivateKeyAccounts } from '../testHelpers' ;
8+ import { getAnvilTestStack , isAnvilTestMode } from '../integrationTestHelpers/injectedMode' ;
9+ import { PrivateKeyAccount } from 'viem/accounts' ;
810
9- // l2 owner private key
10- const devPrivateKey = getNitroTestnodePrivateKeyAccounts ( ) . l2RollupOwner . privateKey ;
11+ const env = isAnvilTestMode ( ) ? getAnvilTestStack ( ) : undefined ;
1112
12- const owner = privateKeyToAccount ( devPrivateKey ) ;
1313const randomAccount = privateKeyToAccount ( generatePrivateKey ( ) ) ;
1414
15- const client = createPublicClient ( {
16- chain : nitroTestnodeL2 ,
15+ let l2RollupOwner : PrivateKeyAccount ;
16+
17+ if ( env ) {
18+ l2RollupOwner = env . l2 . accounts . rollupOwner ;
19+ } else {
20+ const devPrivateKey = getNitroTestnodePrivateKeyAccounts ( ) . l2RollupOwner . privateKey ;
21+ l2RollupOwner = privateKeyToAccount ( devPrivateKey ) ;
22+ }
23+
24+ const l2Client = createPublicClient ( {
25+ chain : env ? env . l2 . chain : nitroTestnodeL2 ,
1726 transport : http ( ) ,
1827} ) . extend ( arbOwnerPublicActions ) ;
1928
2029it ( 'successfully fetches network fee receiver' , async ( ) => {
21- const result = await client . arbOwnerReadContract ( {
30+ const result = await l2Client . arbOwnerReadContract ( {
2231 functionName : 'getNetworkFeeAccount' ,
2332 } ) ;
2433
25- expect ( result ) . toEqual ( owner . address ) ;
34+ expect ( result ) . toEqual ( l2RollupOwner . address ) ;
2635} ) ;
2736
2837it ( 'succesfully fetches chain owners' , async ( ) => {
29- const result = await client . arbOwnerReadContract ( {
38+ const result = await l2Client . arbOwnerReadContract ( {
3039 functionName : 'getAllChainOwners' ,
3140 } ) ;
3241
33- expect ( result ) . toContain ( owner . address ) ;
42+ expect ( result ) . toContain ( l2RollupOwner . address ) ;
3443} ) ;
3544
3645it ( 'succesfully adds chain owner' , async ( ) => {
37- const isOwnerInitially = await client . arbOwnerReadContract ( {
46+ const isOwnerInitially = await l2Client . arbOwnerReadContract ( {
3847 functionName : 'isChainOwner' ,
3948 args : [ randomAccount . address ] ,
4049 } ) ;
4150
4251 // assert account is not already an owner
4352 expect ( isOwnerInitially ) . toEqual ( false ) ;
4453
45- const transactionRequest = await client . arbOwnerPrepareTransactionRequest ( {
54+ const transactionRequest = await l2Client . arbOwnerPrepareTransactionRequest ( {
4655 functionName : 'addChainOwner' ,
4756 args : [ randomAccount . address ] ,
4857 upgradeExecutor : false ,
49- account : owner . address ,
58+ account : l2RollupOwner . address ,
5059 } ) ;
5160
5261 // submit tx to add chain owner
53- const txHash = await client . sendRawTransaction ( {
54- serializedTransaction : await owner . signTransaction ( transactionRequest ) ,
62+ const txHash = await l2Client . sendRawTransaction ( {
63+ serializedTransaction : await l2RollupOwner . signTransaction ( transactionRequest ) ,
5564 } ) ;
5665
57- await client . waitForTransactionReceipt ( { hash : txHash } ) ;
66+ await l2Client . waitForTransactionReceipt ( { hash : txHash } ) ;
5867
59- const isOwner = await client . arbOwnerReadContract ( {
68+ const isOwner = await l2Client . arbOwnerReadContract ( {
6069 functionName : 'isChainOwner' ,
6170 args : [ randomAccount . address ] ,
6271 } ) ;
@@ -66,29 +75,29 @@ it('succesfully adds chain owner', async () => {
6675} ) ;
6776
6877it ( 'succesfully removes chain owner' , async ( ) => {
69- const isOwnerInitially = await client . arbOwnerReadContract ( {
78+ const isOwnerInitially = await l2Client . arbOwnerReadContract ( {
7079 functionName : 'isChainOwner' ,
7180 args : [ randomAccount . address ] ,
7281 } ) ;
7382
7483 // assert account is an owner
7584 expect ( isOwnerInitially ) . toEqual ( true ) ;
7685
77- const transactionRequest = await client . arbOwnerPrepareTransactionRequest ( {
86+ const transactionRequest = await l2Client . arbOwnerPrepareTransactionRequest ( {
7887 functionName : 'removeChainOwner' ,
7988 args : [ randomAccount . address ] ,
8089 upgradeExecutor : false ,
81- account : owner . address ,
90+ account : l2RollupOwner . address ,
8291 } ) ;
8392
8493 // submit tx to remove chain owner
85- const txHash = await client . sendRawTransaction ( {
86- serializedTransaction : await owner . signTransaction ( transactionRequest ) ,
94+ const txHash = await l2Client . sendRawTransaction ( {
95+ serializedTransaction : await l2RollupOwner . signTransaction ( transactionRequest ) ,
8796 } ) ;
8897
89- await client . waitForTransactionReceipt ( { hash : txHash } ) ;
98+ await l2Client . waitForTransactionReceipt ( { hash : txHash } ) ;
9099
91- const isOwner = await client . arbOwnerReadContract ( {
100+ const isOwner = await l2Client . arbOwnerReadContract ( {
92101 functionName : 'isChainOwner' ,
93102 args : [ randomAccount . address ] ,
94103 } ) ;
@@ -98,28 +107,28 @@ it('succesfully removes chain owner', async () => {
98107} ) ;
99108
100109it ( 'succesfully updates infra fee receiver' , async ( ) => {
101- const initialInfraFeeReceiver = await client . arbOwnerReadContract ( {
110+ const initialInfraFeeReceiver = await l2Client . arbOwnerReadContract ( {
102111 functionName : 'getInfraFeeAccount' ,
103112 } ) ;
104113
105114 // assert account is not already infra fee receiver
106115 expect ( initialInfraFeeReceiver ) . not . toEqual ( randomAccount . address ) ;
107116
108- const transactionRequest = await client . arbOwnerPrepareTransactionRequest ( {
117+ const transactionRequest = await l2Client . arbOwnerPrepareTransactionRequest ( {
109118 functionName : 'setInfraFeeAccount' ,
110119 args : [ randomAccount . address ] ,
111120 upgradeExecutor : false ,
112- account : owner . address ,
121+ account : l2RollupOwner . address ,
113122 } ) ;
114123
115124 // submit tx to update infra fee receiver
116- const txHash = await client . sendRawTransaction ( {
117- serializedTransaction : await owner . signTransaction ( transactionRequest ) ,
125+ const txHash = await l2Client . sendRawTransaction ( {
126+ serializedTransaction : await l2RollupOwner . signTransaction ( transactionRequest ) ,
118127 } ) ;
119128
120- await client . waitForTransactionReceipt ( { hash : txHash } ) ;
129+ await l2Client . waitForTransactionReceipt ( { hash : txHash } ) ;
121130
122- const infraFeeReceiver = await client . arbOwnerReadContract ( {
131+ const infraFeeReceiver = await l2Client . arbOwnerReadContract ( {
123132 functionName : 'getInfraFeeAccount' ,
124133 } ) ;
125134
0 commit comments