@@ -5,26 +5,30 @@ import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
55import { nitroTestnodeL2 } from '../chains' ;
66import { arbAggregatorActions } from './arbAggregatorActions' ;
77import { getNitroTestnodePrivateKeyAccounts } from '../testHelpers' ;
8+ import { getAnvilTestStack , isAnvilTestMode } from '../integrationTestHelpers/injectedMode' ;
89
9- const testnodeAccounts = getNitroTestnodePrivateKeyAccounts ( ) ;
10- const l2RollupOwner = testnodeAccounts . l2RollupOwner ;
11- const randomAccount = privateKeyToAccount ( generatePrivateKey ( ) ) ;
10+ const env = isAnvilTestMode ( ) ? getAnvilTestStack ( ) : undefined ;
1211
13- const nitroTestnodeL2Client = createPublicClient ( {
14- chain : nitroTestnodeL2 ,
12+ const l2Client = createPublicClient ( {
13+ chain : env ? env . l2 . chain : nitroTestnodeL2 ,
1514 transport : http ( ) ,
1615} ) . extend ( arbAggregatorActions ) ;
1716
17+ const l2RollupOwner = env
18+ ? env . l2 . accounts . deployer
19+ : getNitroTestnodePrivateKeyAccounts ( ) . l2RollupOwner ;
20+ const randomAccount = privateKeyToAccount ( generatePrivateKey ( ) ) ;
21+
1822describe ( 'ArgAggregator decorator tests' , ( ) => {
1923 it ( 'successfully fetches the batch posters and the fee collectors' , async ( ) => {
20- const batchPosters = await nitroTestnodeL2Client . arbAggregatorReadContract ( {
24+ const batchPosters = await l2Client . arbAggregatorReadContract ( {
2125 functionName : 'getBatchPosters' ,
2226 } ) ;
2327
2428 expect ( batchPosters ) . toHaveLength ( 2 ) ;
2529 expect ( batchPosters [ 0 ] ) . toEqual ( '0xA4b000000000000000000073657175656e636572' ) ;
2630
27- const batchPosterFeeCollector = await nitroTestnodeL2Client . arbAggregatorReadContract ( {
31+ const batchPosterFeeCollector = await l2Client . arbAggregatorReadContract ( {
2832 functionName : 'getFeeCollector' ,
2933 args : [ batchPosters [ 0 ] ] ,
3034 } ) ;
@@ -34,25 +38,26 @@ describe('ArgAggregator decorator tests', () => {
3438
3539 it ( 'succesfully updates the fee collector of a batch poster' , async ( ) => {
3640 // Get the batch posters
37- const batchPosters = await nitroTestnodeL2Client . arbAggregatorReadContract ( {
41+ const batchPosters = await l2Client . arbAggregatorReadContract ( {
3842 functionName : 'getBatchPosters' ,
3943 } ) ;
4044
4145 // Set the fee collector of the batch poster to the random address
42- const setFeeCollectorTransactionRequest =
43- await nitroTestnodeL2Client . arbAggregatorPrepareTransactionRequest ( {
46+ const setFeeCollectorTransactionRequest = await l2Client . arbAggregatorPrepareTransactionRequest (
47+ {
4448 functionName : 'setFeeCollector' ,
4549 args : [ batchPosters [ 1 ] , randomAccount . address ] ,
4650 upgradeExecutor : false ,
4751 account : l2RollupOwner . address ,
48- } ) ;
49- const txHash = await nitroTestnodeL2Client . sendRawTransaction ( {
52+ } ,
53+ ) ;
54+ const txHash = await l2Client . sendRawTransaction ( {
5055 serializedTransaction : await l2RollupOwner . signTransaction ( setFeeCollectorTransactionRequest ) ,
5156 } ) ;
52- await nitroTestnodeL2Client . waitForTransactionReceipt ( { hash : txHash } ) ;
57+ await l2Client . waitForTransactionReceipt ( { hash : txHash } ) ;
5358
5459 // Check the fee collector has changed
55- const batchPosterFeeCollector = await nitroTestnodeL2Client . arbAggregatorReadContract ( {
60+ const batchPosterFeeCollector = await l2Client . arbAggregatorReadContract ( {
5661 functionName : 'getFeeCollector' ,
5762 args : [ batchPosters [ 1 ] ] ,
5863 } ) ;
0 commit comments