From a2b6042a771f8fe0bcd683ea25d5433964605cea Mon Sep 17 00:00:00 2001 From: Simon Dosch Date: Thu, 9 Nov 2023 11:42:04 +0100 Subject: [PATCH] fix token assignment --- .gitignore | 1 + contracts/root/depositManager/DepositManager.sol | 2 +- test/helpers/utils.js | 5 +++-- test/integration/root/DepositManagerUpdate.test.js | 8 ++++++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 12942d270..9febdea32 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ test-blockchain/data *.log .DS_Store +.vscode *.env coverage/ diff --git a/contracts/root/depositManager/DepositManager.sol b/contracts/root/depositManager/DepositManager.sol index 7067691f1..4abb411f5 100644 --- a/contracts/root/depositManager/DepositManager.sol +++ b/contracts/root/depositManager/DepositManager.sol @@ -171,7 +171,7 @@ contract DepositManager is DepositManagerStorage, IDepositManager, ERC721Holder } // new: bridge POL as MATIC, child chain behaviour does not change else if (_token == registry.contractMap(keccak256("pol"))) { - _token == registry.contractMap(keccak256("matic")); + _token = registry.contractMap(keccak256("matic")); } deposits[_depositId] = DepositBlock(keccak256(abi.encodePacked(_user, _token, _amountOrToken)), now); diff --git a/test/helpers/utils.js b/test/helpers/utils.js index 78129beaf..2d2d28e6c 100644 --- a/test/helpers/utils.js +++ b/test/helpers/utils.js @@ -252,7 +252,7 @@ export async function depositOnRoot( const NewDepositBlockEvent = logs.find( log => log.event === 'NewDepositBlock' ) - return NewDepositBlockEvent.args.depositBlockId + return NewDepositBlockEvent } export async function deposit( @@ -265,13 +265,14 @@ export async function deposit( ) { let depositBlockId if (options.rootDeposit) { - depositBlockId = await depositOnRoot( + const newDepositBlockEvent = await depositOnRoot( depositManager, rootContract, user, amountOrToken, options ) + depositBlockId = newDepositBlockEvent.args.depositBlockId } else { depositBlockId = '0x' + crypto.randomBytes(32).toString('hex') } diff --git a/test/integration/root/DepositManagerUpdate.test.js b/test/integration/root/DepositManagerUpdate.test.js index d69583d11..4b2c30ee3 100644 --- a/test/integration/root/DepositManagerUpdate.test.js +++ b/test/integration/root/DepositManagerUpdate.test.js @@ -102,14 +102,18 @@ contract('DepositManager Update @skip-on-coverage', async function(accounts) { const bob = '0x' + crypto.randomBytes(20).toString('hex') // using the utils function more granularly here so we can call fireDepositFromMainToMatic with the correct token address - const depositBlockId = await utils.depositOnRoot( + const newDepositBlockEvent = await utils.depositOnRoot( depositManager, pol, bob, amount, { rootDeposit: true, erc20: true } ) - await utils.fireDepositFromMainToMatic(childContracts.childChain, '0xa', bob, e20.rootERC20.address, amount, depositBlockId) + + // token has been changed to MATIC + assert.strictEqual(newDepositBlockEvent.args.token, e20.rootERC20.address) + + await utils.fireDepositFromMainToMatic(childContracts.childChain, '0xa', bob, e20.rootERC20.address, amount, newDepositBlockEvent.args.depositBlockId) // deposit on child chain is technically still in MATIC utils.assertBigNumberEquality(await e20.childToken.balanceOf(bob), amount)