Skip to content

Commit

Permalink
test: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
envin3 committed Nov 19, 2024
1 parent 644bc28 commit 1841659
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 17 deletions.
4 changes: 2 additions & 2 deletions solidity/test/forge/Adapter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ contract AdapterTest is Test, Helper {
ERC20 erc20 = ERC20(new ERC20Test(name, symbol, supply));
(XERC20 xerc20, , ) = _setupXERC20(
address(0),
address(erc20),
bytes32(abi.encode(erc20)),
string.concat("p", name),
string.concat("p", symbol),
local,
Expand All @@ -42,7 +42,7 @@ contract AdapterTest is Test, Helper {
PAM pam = new PAM();
adapter = new Adapter(
address(xerc20),
address(erc20),
bytes32(abi.encode(erc20)),
notNative,
address(feesManager),
address(pam)
Expand Down
6 changes: 3 additions & 3 deletions solidity/test/forge/DeployHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ contract DeployHelper {
/// chains.
function _setupXERC20(
address factory_,
address erc20,
bytes32 erc20,
string memory name,
string memory symbol,
bool local,
Expand All @@ -40,11 +40,11 @@ contract DeployHelper {
)
);

bool isNative = erc20 == address(0);
bool isNative = address(uint160(uint256(erc20))) == address(0);
XERC20Lockbox lockbox;
if (local) {
lockbox = XERC20Lockbox(
factory.deployLockbox(address(xerc20), erc20, isNative)
factory.deployLockbox(address(xerc20), address(uint160(uint256(erc20))), isNative)
);
}

Expand Down
4 changes: 2 additions & 2 deletions solidity/test/forge/Helper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ abstract contract Helper is Test, DeployHelper {
function _setupChain(
uint256 chain,
address owner_,
address erc20,
bytes32 erc20,
bool local,
bool freezingEnabled
)
Expand Down Expand Up @@ -104,7 +104,7 @@ abstract contract Helper is Test, DeployHelper {
feesManager = new FeesManager(securityCouncil);
adapter = new Adapter(
address(xerc20),
address(erc20),
erc20,
notNative,
address(feesManager),
address(pam)
Expand Down
4 changes: 2 additions & 2 deletions solidity/test/forge/Integration.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ contract IntegrationTest is Test, Helper {
(xerc20_A, lockbox_A, adapter_A, feesManager_A, pam_A) = _setupChain(
CHAIN_A,
owner_A,
address(erc20),
erc20Bytes,
LOCAL,
freezingEnabled
);

(xerc20_B, lockbox_B, adapter_B, feesManager_B, pam_B) = _setupChain(
CHAIN_B,
owner_B,
address(erc20),
erc20Bytes,
NOT_LOCAL,
freezingEnabled
);
Expand Down
2 changes: 1 addition & 1 deletion solidity/test/forge/PAM.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ contract PAMTest is Test, Helper {
(, , adapter, , ) = _setupChain(
originChainId,
owner,
address(erc20),
bytes32(abi.encode(address(erc20))),
true,
false
);
Expand Down
5 changes: 3 additions & 2 deletions solidity/test/hardhat/Adapter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const deployERC1820 = () => setCode(ERC1820, ERC1820BYTES)
const PAM = await deploy(hre, 'PAM', [])
const adapter = await deploy(hre, 'Adapter', [
pTokenV2.target,
erc20.target,
erc20Bytes,
_isNative,
feesManager,
PAM,
Expand Down Expand Up @@ -153,7 +153,8 @@ const deployERC1820 = () => setCode(ERC1820, ERC1820BYTES)
value: amount,
},
)
} else {
}
else {
await erc20.connect(user).approve(adapter, amount)
tx = adapter.swap(
erc20.target,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const {
} = require('@pnetwork/event-attestator')
const { expect } = require('chai')
const hre = require('hardhat')
const { zeroPadValue } = require('ethers')

const Operation = require('../utils/Operation.js')
const { decodeSwapEvent } = require('../utils/decode-swap-event.js')
Expand Down Expand Up @@ -81,19 +82,17 @@ conditionalDescribe(
const rpc = hre.config.networks.bscFork.url
const blockToForkFrom = 43336397 // 2024-10-22 09:25
await helpers.reset(rpc, blockToForkFrom)

user = await hre.ethers.getImpersonatedSigner(
'0x816a99530B0f272Bb6ba4913b8952249f8d2E21b',
)

await helpers.setBalance(user.address, oneEth)
ptoken = await hre.ethers.getContractAt(PTokenAbi, ADDRESS_PTOKEN)
proxyAdminOwner = await hre.ethers.getImpersonatedSigner(
ADDRESS_PTOKEN_PROXY_ADMIN_OWNER,
)
adapterBsc = await deploy(hre, 'Adapter', [
ptoken.target,
ADDRESS_ERC20_TOKEN,
zeroPadValue(ADDRESS_ERC20_TOKEN, 32),
isNative,
feesManagerBsc,
pamBsc,
Expand Down Expand Up @@ -176,7 +175,6 @@ conditionalDescribe(
const rpc = hre.config.networks.ethFork.url
const blockToForkFrom = 20369499 // 2024-07-23 15:22
await helpers.reset(rpc, blockToForkFrom)

erc20 = await hre.ethers.getContractAt(Erc20Abi, ADDRESS_ERC20_TOKEN)

const name = `p${await erc20.name()}`
Expand Down Expand Up @@ -204,7 +202,7 @@ conditionalDescribe(

adapterEth = await deploy(hre, 'Adapter', [
xerc20.target,
ADDRESS_ERC20_TOKEN,
zeroPadValue(ADDRESS_ERC20_TOKEN, 32),
isNative,
feesManagerEth,
pamEth,
Expand Down

0 comments on commit 1841659

Please sign in to comment.