Skip to content

Commit 8953985

Browse files
author
Naohiro Yoshida
committed
fix test
1 parent dc01af3 commit 8953985

File tree

4 files changed

+28
-24
lines changed

4 files changed

+28
-24
lines changed

e2e/contracts/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ deploy:
77
.PHONY:test
88
test:
99
npx hardhat run ./scripts/send.js --network bsc_local2
10-
sleep 60
10+
sleep 10
1111
../testrly tx relay ibc01 --home ../.testrly
12-
sleep 20
12+
sleep 10
1313
npx hardhat run ./scripts/recv.js --network bsc_local1
14-
sleep 20
14+
sleep 10
1515
../testrly query unrelayed-packets ibc01 --home ../.testrly | grep '{"src":\[\],"dst":\[\]}'
1616
../testrly tx relay-acknowledgements ibc01 --home ../.testrly
17-
sleep 20
17+
sleep 10
1818
../testrly query unrelayed-acknowledgements ibc01 --home ../.testrly | grep '{"src":\[\],"dst":\[\]}'

e2e/contracts/scripts/recv.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ const util = require("./util");
33
async function main() {
44
const accounts = await hre.ethers.getSigners();
55
const bob = accounts[1]
6-
76
try {
87

8+
const token= await util.readContract("ERC20Token");
9+
const baseDenom = token.target.toLowerCase();
910
const transfer = await util.readContract("ICS20Transfer");
10-
const bobAmount = await transfer.balanceOf(bob, `transfer/channel-0/simple_erc_20_token_for_test`)
11+
const bobAmount = await transfer.balanceOf(bob, `transfer/${util.config.channel}/${baseDenom}`)
1112
console.log("received = ", bobAmount.toString())
12-
if (parseInt(bobAmount.toString(), 10) !== 20) {
13+
if (parseInt(bobAmount.toString(), 10) !== util.config.amount) {
1314
throw new Error("bob amount error");
1415
}
1516

e2e/contracts/scripts/send.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,36 @@ async function main() {
44
const accounts = await hre.ethers.getSigners();
55
const alice = accounts[0].address;
66
const bob = accounts[1].address;
7-
8-
const channel = "channel-0";
9-
const timeoutHeight = [
10-
[BigInt(1), BigInt(10000000)],
11-
BigInt(0)
12-
];
13-
const sendingAmount = 20
14-
7+
const timeoutHeight = [[1, 10000000],0];
158
try {
169
const token = await util.readContract("ERC20Token");
10+
const transfer = await util.readContract("ICS20Transfer");
11+
1712
const before= await token.balanceOf(alice)
1813
console.log("before = ", before.toString())
19-
const transfer = await util.readContract("ICS20Transfer");
14+
15+
const escrowBefore= await token.balanceOf(transfer.target)
16+
console.log("escrow before = ", escrowBefore.toString())
2017

2118
// Deposit and SendTransfer
22-
await token.approve(transfer.target, sendingAmount, { from: alice }).then(tx => tx.wait());
23-
const depositResult = await transfer.depositSendTransfer(channel, token.target, sendingAmount, bob, timeoutHeight, {
19+
await token.approve(transfer.target, util.config.amount, { from: alice }).then(tx => tx.wait());
20+
const depositResult = await transfer.depositSendTransfer(util.config.channel, token.target, util.config.amount, bob, timeoutHeight, {
2421
from: alice
2522
})
2623
const depositReceipt = await depositResult.wait()
27-
console.log("deposit success", depositReceipt.hash);
24+
console.log("depositSendTransfer success", depositReceipt.hash);
2825

2926
// Check reduced amount
3027
const after= await token.balanceOf(alice)
3128
console.log("after = ", after.toString())
32-
if (parseInt(after.toString(), 10) !== Number(before) - sendingAmount) {
29+
if (parseInt(after.toString(), 10) !== Number(before) - util.config.amount) {
3330
throw new Error("alice amount error");
3431
}
3532

3633
// Check escrow balance
37-
const escrowAmount = await token.balanceOf(transfer.target)
38-
console.log("escrow = ", escrowAmount.toString())
39-
if (parseInt(escrowAmount.toString(), 10) !== sendingAmount) {
34+
const escrowAfter= await token.balanceOf(transfer.target)
35+
console.log("escrow after = ", escrowAfter.toString())
36+
if (parseInt(escrowAfter.toString(), 10) !== Number(escrowBefore) + util.config.amount) {
4037
throw new Error("escrow amount error");
4138
}
4239

e2e/contracts/scripts/util.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ async function readContract(contractName) {
77
return await hre.ethers.getContractAt(contractName, address);
88
}
99

10+
const config = {
11+
channel:"channel-0",
12+
amount: 20
13+
}
14+
1015
module.exports = {
11-
readContract
16+
readContract,
17+
config
1218
};

0 commit comments

Comments
 (0)