Skip to content

Commit

Permalink
refactor unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
sirarthurmoney committed Dec 9, 2023
1 parent 0c04461 commit 11bdf49
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,11 @@ describe('task: getDefaultConfig', () => {
const sendUln302 = await contractFactory({ contractName: 'SendUln302', eid: localEid })
const receiveUln302 = await contractFactory({ contractName: 'ReceiveUln302', eid: localEid })

// verify defaultSendLibrary & defaultReceiveLibrary
expect(defaultConfig.defaultSendLibrary).toEqual(sendUln302.contract.address)
expect(defaultConfig.defaultReceiveLibrary).toEqual(receiveUln302.contract.address)

// verify sendUln
expect(defaultConfig.sendExecutorConfig.maxMessageSize).toEqual(defaultExecutorConfig.maxMessageSize)
expect(defaultConfig.sendExecutorConfig.executor).toEqual(defaultExecutorConfig.executor)
expect(defaultConfig.sendUlnConfig.confirmations.toString()).toEqual(
defaultUlnConfig.confirmations.toString()
)
expect(defaultConfig.sendUlnConfig.optionalDVNThreshold).toEqual(defaultUlnConfig.optionalDVNThreshold)
expect(defaultConfig.sendUlnConfig.requiredDVNs).toEqual(defaultUlnConfig.requiredDVNs)
expect(defaultConfig.sendUlnConfig.optionalDVNs).toEqual(defaultUlnConfig.optionalDVNs)

// verify receiveUln
expect(defaultConfig.receiveUlnConfig.confirmations.toString()).toEqual(
defaultUlnConfig.confirmations.toString()
)
expect(defaultConfig.receiveUlnConfig.optionalDVNThreshold).toEqual(
defaultUlnConfig.optionalDVNThreshold
)
expect(defaultConfig.receiveUlnConfig.requiredDVNs).toEqual(defaultUlnConfig.requiredDVNs)
expect(defaultConfig.receiveUlnConfig.optionalDVNs).toEqual(defaultUlnConfig.optionalDVNs)
expect(defaultConfig.sendExecutorConfig).toEqual(defaultExecutorConfig)
expect(defaultConfig.sendUlnConfig).toEqual(defaultUlnConfig)
expect(defaultConfig.receiveUlnConfig).toEqual(defaultUlnConfig)
}
}
})
Expand Down
31 changes: 5 additions & 26 deletions packages/ua-utils-evm-hardhat-test/test/task/getOAppConfig.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { describe } from 'mocha'
import { defaultExecutorConfig, defaultUlnConfig, setupDefaultEndpoint } from '../__utils__/endpoint'
import { createContractFactory, getEidForNetworkName } from '@layerzerolabs/utils-evm-hardhat'
import hre from 'hardhat'
import { expect, assert } from 'chai'
import { AddressZero } from '@ethersproject/constants'

describe('task: getOAppConfig', () => {
Expand All @@ -18,7 +16,6 @@ describe('task: getOAppConfig', () => {
addresses: addresses.toString(),
})
const contractFactory = createContractFactory()

for (const localNetwork of networks) {
const localEid = getEidForNetworkName(localNetwork)
for (const remoteNetwork of networks) {
Expand All @@ -28,29 +25,11 @@ describe('task: getOAppConfig', () => {
const sendUln302 = await contractFactory({ contractName: 'SendUln302', eid: localEid })
const receiveUln302 = await contractFactory({ contractName: 'ReceiveUln302', eid: localEid })

// verify defaultSendLibrary & defaultReceiveLibrary
expect(defaultConfig.defaultSendLibrary).to.eql(sendUln302.contract.address)
expect(defaultConfig.defaultReceiveLibrary).to.eql(receiveUln302.contract.address)

// verify sendUln
expect(defaultConfig.sendExecutorConfig.maxMessageSize).to.eql(defaultExecutorConfig.maxMessageSize)
expect(defaultConfig.sendExecutorConfig.executor).to.eql(defaultExecutorConfig.executor)
expect(defaultConfig.sendUlnConfig.confirmations.toString()).to.eql(
defaultUlnConfig.confirmations.toString()
)
expect(defaultConfig.sendUlnConfig.optionalDVNThreshold).to.eql(defaultUlnConfig.optionalDVNThreshold)
expect(defaultConfig.sendUlnConfig.requiredDVNs).to.eql(defaultUlnConfig.requiredDVNs)
expect(defaultConfig.sendUlnConfig.optionalDVNs).to.eql(defaultUlnConfig.optionalDVNs)

// verify receiveUln
expect(defaultConfig.receiveUlnConfig.confirmations.toString()).to.eql(
defaultUlnConfig.confirmations.toString()
)
expect(defaultConfig.receiveUlnConfig.optionalDVNThreshold).to.eql(
defaultUlnConfig.optionalDVNThreshold
)
expect(defaultConfig.receiveUlnConfig.requiredDVNs).to.eql(defaultUlnConfig.requiredDVNs)
expect(defaultConfig.receiveUlnConfig.optionalDVNs).to.eql(defaultUlnConfig.optionalDVNs)
expect(defaultConfig.defaultSendLibrary).toEqual(sendUln302.contract.address)
expect(defaultConfig.defaultReceiveLibrary).toEqual(receiveUln302.contract.address)
expect(defaultConfig.sendExecutorConfig).toEqual(defaultExecutorConfig)
expect(defaultConfig.sendUlnConfig).toEqual(defaultUlnConfig)
expect(defaultConfig.receiveUlnConfig).toEqual(defaultUlnConfig)
}
}
})
Expand Down

0 comments on commit 11bdf49

Please sign in to comment.