Skip to content

Commit

Permalink
fix integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
douglance committed Oct 18, 2023
1 parent 6ce0a4d commit 8fe045e
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 20 deletions.
8 changes: 4 additions & 4 deletions scripts/testSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
ParentChain as L1Network,
ChildChain as L2Network,
getParentChain as getL1Network,
getChain as getL2Network,
getChildChain as getL2Network,
addCustomNetwork,
} from '../src/lib/dataEntities/networks'
import { Signer } from 'ethers'
Expand Down Expand Up @@ -171,8 +171,8 @@ export const setupNetworks = async (
}

addCustomNetwork({
customL1Network: l1Network,
customChainNetwork: l2Network,
customParentChain: l1Network,
customChildChain: l2Network,
})

// also register the weth gateway
Expand Down Expand Up @@ -245,7 +245,7 @@ export const testSetup = async (): Promise<{
}
addCustomNetwork({
customParentChain: l1Network,
customChain: l2Network,
customChildChain: l2Network,
})
setL1Network = l1Network
setL2Network = l2Network
Expand Down
28 changes: 16 additions & 12 deletions src/lib/dataEntities/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,10 +397,10 @@ export const getEthBridgeInformation = async (

export const addCustomNetwork = ({
customParentChain,
customChain,
customChildChain,
}: {
customParentChain?: ParentChain
customChain: ChildChain
customChildChain: ChildChain
}): void => {
if (customParentChain) {
if (parentChains[customParentChain.chainID]) {
Expand All @@ -416,24 +416,28 @@ export const addCustomNetwork = ({
}
}

if (childChains[customChain.chainID])
throw new ArbSdkError(`Network ${customChain.chainID} already included`)
else if (!customChain.isCustom) {
if (childChains[customChildChain.chainID])
throw new ArbSdkError(
`Custom network ${customChain.chainID} must have isCustom flag set to true`
`Network ${customChildChain.chainID} already included`
)
else if (!customChildChain.isCustom) {
throw new ArbSdkError(
`Custom network ${customChildChain.chainID} must have isCustom flag set to true`
)
}

childChains[customChain.chainID] = customChain
childChains[customChildChain.chainID] = customChildChain

const parentChainPartnerChain = parentChains[customChain.partnerChainID]
const parentChainPartnerChain = parentChains[customChildChain.partnerChainID]
if (!parentChainPartnerChain)
throw new ArbSdkError(
`Network ${customChain.chainID}'s partner network, ${customChain.partnerChainID}, not recognized`
`Network ${customChildChain.chainID}'s partner network, ${customChildChain.partnerChainID}, not recognized`
)

if (!parentChainPartnerChain.partnerChainIDs.includes(customChain.chainID)) {
parentChainPartnerChain.partnerChainIDs.push(customChain.chainID)
if (
!parentChainPartnerChain.partnerChainIDs.includes(customChildChain.chainID)
) {
parentChainPartnerChain.partnerChainIDs.push(customChildChain.chainID)
}
}

Expand Down Expand Up @@ -495,7 +499,7 @@ export const addDefaultLocalNetwork = (): {

addCustomNetwork({
customParentChain: defaultLocalParentChain,
customChain: defaultLocalChain,
customChildChain: defaultLocalChain,
})

return {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/inbox/inbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class InboxTools {
this.parentChain = parentChains[childChain.partnerChainID]
if (!this.parentChain)
throw new ArbSdkError(
`ParentChainNetwork not found for chain id: ${childChain.partnerChainID}.`
`ParentChain not found for chain id: ${childChain.partnerChainID}.`
)
}

Expand Down
2 changes: 1 addition & 1 deletion tests/fork/inbox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { InboxTools } from '../../src'
import { ethers, network } from 'hardhat'
import { hexZeroPad } from '@ethersproject/bytes'
import {
ChainNetwork as L2Network,
ChildChain as L2Network,
getChildChain as getL2Network,
} from '../../src/lib/dataEntities/networks'
import { solidityKeccak256 } from 'ethers/lib/utils'
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/sendL2msg.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { BigNumber, ethers, Signer } from 'ethers'
import { InboxTools } from '../../src/lib/inbox/inbox'
import {
getChildChain as getL2Network,
ChainNetwork as L2Network,
ChildChain as L2Network,
} from '../../src/lib/dataEntities/networks'
import { testSetup } from '../../scripts/testSetup'
import { greeter } from './helper/greeter'
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/testHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
L1ToL2MessageStatus,
L2ToL1MessageStatus,
} from '../../src'
import { ChainNetwork as L2Network } from '../../src/lib/dataEntities/networks'
import { ChildChain as L2Network } from '../../src/lib/dataEntities/networks'
import { GasOverrides } from '../../src/lib/message/L1ToL2MessageGasEstimator'
import { ArbSdkError } from '../../src/lib/dataEntities/errors'
import { ERC20 } from '../../src/lib/abi/ERC20'
Expand Down

0 comments on commit 8fe045e

Please sign in to comment.