Skip to content

Commit 5382a31

Browse files
committed
test: fix and enable upgrade executor tests
1 parent 325cc67 commit 5382a31

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

src/integrationTestHelpers/anvilHarness.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import { ethers } from 'ethers';
2121

2222
import TestWETH9 from '@arbitrum/token-bridge-contracts/build/contracts/contracts/tokenbridge/test/TestWETH9.sol/TestWETH9.json';
2323

24+
import { arbOwnerPrepareTransactionRequest } from '../arbOwnerPrepareTransactionRequest';
25+
import { arbOwnerReadContract } from '../arbOwnerReadContract';
2426
import { registerCustomParentChain } from '../chains';
2527
import {
2628
rollupCreatorABI,
@@ -175,6 +177,42 @@ async function getNitroTestnodeStyleValidators(
175177
return validators;
176178
}
177179

180+
async function ensureChainOwner(params: {
181+
publicClient: PublicClient<Transport, Chain>;
182+
chainOwner: PrivateKeyAccountWithPrivateKey;
183+
newChainOwner: Address;
184+
}) {
185+
const { publicClient, chainOwner, newChainOwner } = params;
186+
187+
const isAlreadyChainOwner = await arbOwnerReadContract(publicClient, {
188+
functionName: 'isChainOwner',
189+
args: [newChainOwner],
190+
});
191+
192+
if (isAlreadyChainOwner) {
193+
return;
194+
}
195+
196+
const transactionRequest = await arbOwnerPrepareTransactionRequest(publicClient, {
197+
functionName: 'addChainOwner',
198+
args: [newChainOwner],
199+
upgradeExecutor: false,
200+
account: chainOwner.address,
201+
});
202+
203+
const transactionHash = await publicClient.sendRawTransaction({
204+
serializedTransaction: await chainOwner.signTransaction(transactionRequest),
205+
});
206+
207+
const receipt = await publicClient.waitForTransactionReceipt({
208+
hash: transactionHash,
209+
});
210+
211+
if (receipt.status !== 'success') {
212+
throw new Error(`Failed to add chain owner ${newChainOwner}`);
213+
}
214+
}
215+
178216
export function dehydrateAnvilTestStack(env: AnvilTestStack): InjectedAnvilTestStack {
179217
return {
180218
...env,
@@ -714,6 +752,12 @@ export async function setupAnvilTestStack(): Promise<AnvilTestStack> {
714752
},
715753
},
716754
});
755+
756+
await ensureChainOwner({
757+
publicClient: l3Client,
758+
chainOwner: harnessDeployer,
759+
newChainOwner: tokenBridgeContracts.orbitChainContracts.upgradeExecutor,
760+
});
717761
console.log('L3 token bridge contracts deployed on L2\n');
718762

719763
initializedEnv = {

vitest.integration.anvil.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default mergeConfig(
2525
'./src/actions/sequencerInbox.integration.test.ts',
2626
'./src/decorators/arbOwnerPublicActions.integration.test.ts',
2727
'./src/upgradeExecutor.integration.test.ts',
28-
'./src/decorators/arbOwnerPublicActions.integration.test.ts',
28+
'./src/decorators/arbOwnerPublicActionsUpgradeExecutor.integration.test.ts',
2929
],
3030
fileParallelism: false,
3131
},

0 commit comments

Comments
 (0)