Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 30 additions & 23 deletions src/feeRouter.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,49 @@ import {
import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';

import { nitroTestnodeL1, nitroTestnodeL2 } from './chains';
import { getNitroTestnodePrivateKeyAccounts } from './testHelpers';
import { getNitroTestnodePrivateKeyAccounts, PrivateKeyAccountWithPrivateKey } from './testHelpers';
import { feeRouterDeployChildToParentRewardRouter } from './feeRouterDeployChildToParentRewardRouter';
import { feeRouterDeployRewardDistributor } from './feeRouterDeployRewardDistributor';
import { getAnvilTestStack, isAnvilTestMode } from './integrationTestHelpers/injectedMode';

const testnodeAccounts = getNitroTestnodePrivateKeyAccounts();
const deployer = testnodeAccounts.deployer;
const env = isAnvilTestMode() ? getAnvilTestStack() : undefined;
const randomAccount = privateKeyToAccount(generatePrivateKey());
const randomAccount2 = privateKeyToAccount(generatePrivateKey());

const nitroTestnodeL1Client = createPublicClient({
chain: nitroTestnodeL1,
transport: http(nitroTestnodeL1.rpcUrls.default.http[0]),
let deployer: PrivateKeyAccountWithPrivateKey;
if (env) {
deployer = env.l2.accounts.deployer;
} else {
deployer = getNitroTestnodePrivateKeyAccounts().deployer;
}

const l1Client = createPublicClient({
chain: env ? env.l1.chain : nitroTestnodeL1,
transport: http(),
});

const nitroTestnodeL2Client = createPublicClient({
chain: nitroTestnodeL2,
transport: http(nitroTestnodeL2.rpcUrls.default.http[0]),
const l2Client = createPublicClient({
chain: env ? env.l2.chain : nitroTestnodeL2,
transport: http(),
});
const nitroTestnodeL2WalletClient = createWalletClient({
chain: nitroTestnodeL2,
transport: http(nitroTestnodeL2.rpcUrls.default.http[0]),

const l2WalletClient = createWalletClient({
chain: env ? env.l2.chain : nitroTestnodeL2,
transport: http(),
account: deployer,
});

describe('Fee routing tests', () => {
it(`successfully deploys and configures an ArbChildToParentRewardRouter`, async () => {
const childToParentRewardRouterDeploymentTransactionHash =
await feeRouterDeployChildToParentRewardRouter({
parentChainPublicClient: nitroTestnodeL1Client,
orbitChainWalletClient: nitroTestnodeL2WalletClient,
parentChainPublicClient: l1Client,
orbitChainWalletClient: l2WalletClient,
parentChainTargetAddress: randomAccount.address,
});

const childToParentRewardRouterDeploymentTransactionReceipt =
await nitroTestnodeL2Client.waitForTransactionReceipt({
await l2Client.waitForTransactionReceipt({
hash: childToParentRewardRouterDeploymentTransactionHash,
});

Expand All @@ -59,7 +67,7 @@ describe('Fee routing tests', () => {
);

// reading the parentChainTarget
const parentChainTarget = await nitroTestnodeL2Client.readContract({
const parentChainTarget = await l2Client.readContract({
address: childToParentRewardRouterAddress,
abi: parseAbi(['function parentChainTarget() view returns (address)']),
functionName: 'parentChainTarget',
Expand All @@ -80,14 +88,13 @@ describe('Fee routing tests', () => {
},
];
const rewardDistributorDeploymentTransactionHash = await feeRouterDeployRewardDistributor({
orbitChainWalletClient: nitroTestnodeL2WalletClient,
orbitChainWalletClient: l2WalletClient,
recipients,
});

const rewardDistributorDeploymentTransactionReceipt =
await nitroTestnodeL2Client.waitForTransactionReceipt({
hash: rewardDistributorDeploymentTransactionHash,
});
const rewardDistributorDeploymentTransactionReceipt = await l2Client.waitForTransactionReceipt({
hash: rewardDistributorDeploymentTransactionHash,
});

expect(rewardDistributorDeploymentTransactionReceipt).to.have.property('contractAddress');

Expand Down Expand Up @@ -117,13 +124,13 @@ describe('Fee routing tests', () => {
const recipientWeights = keccak256(encodePacked(['uint256', 'uint256'], [9000n, 1000n]));

// reading the currentRecipientGroup and currentRecipientWeights
const currentRecipientGroup = await nitroTestnodeL2Client.readContract({
const currentRecipientGroup = await l2Client.readContract({
address: rewardDistributorAddress,
abi: parseAbi(['function currentRecipientGroup() view returns (bytes32)']),
functionName: 'currentRecipientGroup',
});

const currentRecipientWeights = await nitroTestnodeL2Client.readContract({
const currentRecipientWeights = await l2Client.readContract({
address: rewardDistributorAddress,
abi: parseAbi(['function currentRecipientWeights() view returns (bytes32)']),
functionName: 'currentRecipientWeights',
Expand Down
1 change: 1 addition & 0 deletions vitest.integration.anvil.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default mergeConfig(
'./src/upgradeExecutor.integration.test.ts',
'./src/decorators/arbOwnerPublicActionsUpgradeExecutor.integration.test.ts',
'./src/createTokenBridge.integration.test.ts',
'./src/feeRouter.integration.test.ts',
],
fileParallelism: false,
},
Expand Down
Loading