Skip to content

Commit

Permalink
(fix) Fix the tests by renaming things that aren't tests not to start…
Browse files Browse the repository at this point in the history
… with "test"
  • Loading branch information
rrw-zilliqa committed Jul 29, 2024
1 parent bf2067e commit a093acd
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 44 deletions.
19 changes: 19 additions & 0 deletions docs/zilbridge.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,22 @@ forge script script/zq-testnet/setZilBridgeRouting.s.sol --rpc-url https://dev-a

Now you can send a `transfer()` request and see if it works .. you'll need to redeploy the test token contracts and rerun routing setup (from both sides!) to fix the bridge when the bugs are sorted.

When you're done, you'll need to redeploy the rest of the tokens, so that the bridged ZRC2 has the right token manager set, then set up routing again:

```
cd scilla-contracts
pnpm i
export TOKEN_MANAGER_ADDRESS=(value of zq_lockAndReleaseOrNativeTokenManager)
# NOW EDIT scripts/deploy.ts for the address of the Zilliqa testnet token manager.
npx hardhat run scripts/deploy.ts --network zq_testnet
```

Remember to update `testnet_config.sol`, then:

```
forge script script/zq-testnet/deployZRC2ERC20.s.sol --rpc-url https://dev-api.zilliqa.com --broadcast --legacy
forge script script/bsc-testnet/setZilBridgeRouting.s.sol --rpc-url https://bsc-testnet.bnbchain.org --broadcast
forge script script/zq-testnet/setZilBridgeRouting.s.sol --rpc-url https://dev-api.zilliqa.com --broadcast --legacy
```

And you can now get testing again.
6 changes: 3 additions & 3 deletions scilla-contracts/scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ async function main() {
}
let tokenContract = await hre.deployScillaContract("SwitcheoTokenZRC2", "Bridged-XTST", "XTST",
account.address, 3, 0, zqTestnetTokenManager);
console.log(`zq_bridged_erc20 = ${tokenContract.address}`);
console.log(` address public constant zqBridgedERC20Address = address(0x00${tokenContract.address})`);

let nativeBridgedContract = await hre.deployScillaContract("SwitcheoTokenZRC2", "Bridged-BNB", "eBNB",
account.address, 18, 0, zqTestnetTokenManager);
console.log(`zq_bridged_bnb = ${nativeBridgedContract.address}`);
console.log(` address public constant zqBridgedBNBAddress = address(0x00${nativeBridgedContract.address})`);

let local = await hre.deployScillaContract("FungibleToken", account.address, "zq_native Test", "ZTST", 3, 1_000_000_000);
console.log(`zq_zrc2 = ${local.address}`);
console.log(` address public constant zqZRC2Address = address(0x00${local.address})`);
}

// We recommend this pattern to be able to use async/await everywhere
Expand Down
35 changes: 4 additions & 31 deletions smart-contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ Deterministic deployer not available, simple CREATE was used

### Zilliqa Testnet

See `script/configTestnet.s.sol` for up to date information.

- `ChainId`: 33101
- `ChainGateway`: `0x7370e69565BB2313C4dA12F9062C282513919230`
- `ValidatorManager`: `0x782F8afa1bA3137a214D49840688215a8A379fA8`
Expand All @@ -302,44 +304,15 @@ Deterministic deployer not available, simple CREATE was used

Deterministic deployer not available, simple CREATE was used

Zilliqa testnet tokens:

```
TokenContract: 0x839901f1e39De75301667C6bBbF7fB556Ea2510E
NativeBridgedContract: 0x06852e68A3c24917cfA4C2dbDaE4B308C69aDA5e
Locally generated fungible token: 0x155F0f76b660290F2F00Bb5674b80eDC208bF2e6
```


### BSC Testnet

See `script/configTestnet.s.sol` for up to date information.

- `ChainId`: 97
- `ChainGateway`: `0xa9A14C90e53EdCD89dFd201A3bF94D867f8098fE`
- `ValidatorManager`: `0xCc1CB36d981ae2907cea385F615e879434D20B1C`
- `MintAndBurnTokenManager`: `0xA6D73210AF20a59832F264fbD991D2abf28401d0`
- `BridgedTestToken`: `0x5190e8b4Bbe8C3a732BAdB600b57fD42ACbB9F4B`

ZilBridge ChainID 6, bridging to ZilBridge chain ID 18.

```
Owner: 0x29543Acb166B6044B67979B858e743701C9bd1df
ECCD: 0xd77a160f954AbF8154f80EA53378ACa55bcAD548
CCM: 0x0EDb0830a5a28E60Bc28BCce3f4e1EC23b5E5783 (can't apparently be verified)
CCMProxy: 0xE19738378c75cf2b3D704472bE81d7e036F4Ee04
LockProxy: 0x5B51e17837fc8F01b3C3ef29E882981e9414C159
extendCCM: 0x32ffa2C4c670A0fd0e94CF6457ac2FA7Ef007d55
zilbridge tokenmanager: 0x36b8A9cd6Bf9bfA5984093005cf81CAfB1Bf06F7
```
ZilBridge test tokens:
```
ERC20: 0x59A23d0957B63BC6c5682F211eE731513EECBB98
BridgedZRC2FromZilliqa: 0x0d27244Ec509e7cbBde6d5c82DdD0e9F34873bF2
BridgedZIL: 0x33aC4ae9c514213a51D529114523Dd168c1d3b73
```


4 changes: 2 additions & 2 deletions smart-contracts/test/zilbridge/MockLockProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ contract MockLockProxy {
}


function testing_transferIn(
function mock_transferIn(
address _assetHash,
uint256 _amount,
uint256 _callAmount
Expand Down Expand Up @@ -225,7 +225,7 @@ contract MockLockProxy {
}

/// @dev transfers funds from this contract to the _toAddress
function testing_transferOut(
function mock_transferOut(
address _toAddress,
address _assetHash,
uint256 _amount
Expand Down
4 changes: 2 additions & 2 deletions smart-contracts/test/zilbridge/TestingLockProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1886,11 +1886,11 @@ contract TestingLockProxy is ReentrancyGuard {
return (codehash != accountHash && codehash != 0x0);
}

function testing_transferIn(address assetHash, uint256 amount, uint callAmount) public payable {
function mock_transferIn(address assetHash, uint256 amount, uint callAmount) public payable {
_transferIn(assetHash, amount, callAmount);
}

function testing_transferOut(address toAddress, address assetHash, uint amount) public {
function mock_transferOut(address toAddress, address assetHash, uint amount) public {
_transferOut(toAddress, assetHash, amount);
}
}
12 changes: 6 additions & 6 deletions smart-contracts/test/zilbridge/ZilBridgeTokenBridge.compat.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ contract ZilBridgeTokenBridgeCompatibilityTest is ZilBridgeTokenBridgeCompatibil
// Transfer it synthetically to the lock proxy at the source end.
startHoax(sourceUser);
nativelyOnSource.approve(address(lockProxy), amount);
lockProxy.testing_transferIn(address(nativelyOnSource), amount, amount);
lockProxy.mock_transferIn(address(nativelyOnSource), amount, amount);

// Use the mock lock proxy to simulate transferring that to the remote user.
mockRemoteLockProxy.testing_transferOut(remoteUser, address(remoteNativelyOnSource), amount);
mockRemoteLockProxy.mock_transferOut(remoteUser, address(remoteNativelyOnSource), amount);

assertEq(remoteNativelyOnSource.balanceOf(remoteUser), amount);
assertEq(nativelyOnSource.balanceOf(sourceUser), 0);
Expand All @@ -192,8 +192,8 @@ contract ZilBridgeTokenBridgeCompatibilityTest is ZilBridgeTokenBridgeCompatibil

uint256 sourceBalance = sourceUser.balance;
uint256 lockBalance = address(lockProxy).balance;
lockProxy.testing_transferIn{value: originalTokenSupply}(address(0), amount, amount);
mockRemoteLockProxy.testing_transferOut(remoteUser, address(remoteBridgedGasToken), amount);
lockProxy.mock_transferIn{value: originalTokenSupply}(address(0), amount, amount);
mockRemoteLockProxy.mock_transferOut(remoteUser, address(remoteBridgedGasToken), amount);

assertEq(remoteBridgedGasToken.balanceOf(remoteUser), amount);
assertLe(sourceUser.balance, sourceBalance - amount);
Expand All @@ -210,8 +210,8 @@ contract ZilBridgeTokenBridgeCompatibilityTest is ZilBridgeTokenBridgeCompatibil
// Transfer it synthetically to the lock proxy at the remote
startHoax(remoteUser);
nativelyOnRemote.approve(address(mockRemoteLockProxy), amount);
mockRemoteLockProxy.testing_transferIn(address(nativelyOnRemote), amount, amount);
lockProxy.testing_transferOut(sourceUser, address(sourceNativelyOnRemote), amount);
mockRemoteLockProxy.mock_transferIn(address(nativelyOnRemote), amount, amount);
lockProxy.mock_transferOut(sourceUser, address(sourceNativelyOnRemote), amount);

assertEq(sourceNativelyOnRemote.balanceOf(sourceUser), amount);
assertEq(nativelyOnRemote.balanceOf(remoteUser), 0);
Expand Down

0 comments on commit a093acd

Please sign in to comment.