diff --git a/e2e/Makefile b/e2e/Makefile index 489e370..33aaf36 100644 --- a/e2e/Makefile +++ b/e2e/Makefile @@ -20,7 +20,6 @@ relayer: ./testrly tx update-clients ibc01 --home .testrly ./testrly tx connection ibc01 --home .testrly ./testrly tx channel ibc01 --home .testrly - nohup ./testrly service start ibc01 --home .testrly > testrly.log & .PHONY:test test: diff --git a/e2e/contracts/Makefile b/e2e/contracts/Makefile index 06ed839..35119e8 100644 --- a/e2e/contracts/Makefile +++ b/e2e/contracts/Makefile @@ -7,3 +7,9 @@ deploy: .PHONY:test test: npx truffle exec apps/send.js --network bsc_local2 + sleep 60 + ../testrly tx relay ibc01 --home ../.testrly + npx truffle exec apps/recv.js --network bsc_local + ../testrly query unrelayed-packets ibc01 --home ../.testrly | grep '{"src":null,"dst":null}' + ../testrly tx relay-acknowledgements ibc01 --home ../.testrly + ../testrly query unrelayed-acknowledgements ibc01 --home ../.testrly | grep '{"src":null,"dst":null}' diff --git a/e2e/contracts/apps/recv.js b/e2e/contracts/apps/recv.js new file mode 100644 index 0000000..bbb2050 --- /dev/null +++ b/e2e/contracts/apps/recv.js @@ -0,0 +1,20 @@ +const ICS20Bank = artifacts.require("ICS20Bank"); + +module.exports = async (callback) => { + const accounts = await web3.eth.getAccounts(); + const bob = accounts[1] + + try { + + const bank = await ICS20Bank.deployed() + const bobAmount = await bank.balanceOf(bob, `transfer/channel-0/simple`) + console.log("received = ", bobAmount.toString()) + if (parseInt(bobAmount.toString(), 10) !== 20) { + return callback("bob amount error"); + } + callback() + + }catch (e) { + callback(e); + } +}; diff --git a/e2e/contracts/apps/send.js b/e2e/contracts/apps/send.js index fa9cebb..80c350b 100644 --- a/e2e/contracts/apps/send.js +++ b/e2e/contracts/apps/send.js @@ -1,25 +1,20 @@ const ICS20TransferBank = artifacts.require("ICS20TransferBank"); const ICS20Bank = artifacts.require("ICS20Bank"); -const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)) - module.exports = async (callback) => { const accounts = await web3.eth.getAccounts(); const alice = accounts[0]; const bob = accounts[1]; - const mintAmount = 100; - const sendAmount = 50; const port = "transfer"; const channel = "channel-0"; const timeoutHeight = 0; + const mintAmount = 100; + const sendingAmount = 20 try { // Mint const bank = await ICS20Bank.deployed() - const initialAliceAmount = await bank.balanceOf(alice, "simple") - console.log("before = ", initialAliceAmount.toString()) - const mintResult = await bank.mint(alice, "simple", mintAmount, { from: alice }); @@ -27,20 +22,26 @@ module.exports = async (callback) => { // Send to counterparty chain const transfer = await ICS20TransferBank.deployed() - const transferResult = await transfer.sendTransfer("simple", sendAmount, bob, port, channel, timeoutHeight, { + const transferResult = await transfer.sendTransfer("simple", sendingAmount, bob, port, channel, timeoutHeight, { from: alice, }); console.log("send success", transferResult.tx); - await sleep(10000) - + // Check reduced amount const aliceAmount = await bank.balanceOf(alice, "simple") console.log("after = ", aliceAmount.toString()) - if (parseInt(aliceAmount.toString(), 10) !== parseInt(initialAliceAmount.toString(), 10) + 50) { - callback("amount error"); - } else { - callback() + if (parseInt(aliceAmount.toString(), 10) !== mintAmount - sendingAmount) { + return callback("alice amount error"); + } + + // Check escrow balance + const escrowAmount = await bank.balanceOf(transfer.address, "simple") + console.log("escrow = ", escrowAmount.toString()) + if (parseInt(escrowAmount.toString(), 10) !== sendingAmount) { + return callback("escrow amount error"); } + // Wait for chain B receive the packet + callback() }catch (e) { callback(e);