add test for isWithdrawExited
MODIFY
src/pos/erc20.ts
src/pos/erc20.ts
@@ -184,16 +184,16 @@ export class ERC20 extends POSToken {
/**
* check if exit has been completed for a transaction hash
*
- * @param {string} txHash
+ * @param {string} burnTxHash
* @returns
* @memberof ERC20
*/
- isWithdrawExited(txHash: string) {
- if (!txHash) {
+ isWithdrawExited(burnTxHash: string) {
+ if (!burnTxHash) {
throw new Error(`txHash not provided`);
}
return this.exitUtil.getExitHash(
- txHash, Log_Event_Signature.Erc20Transfer
+ burnTxHash, Log_Event_Signature.Erc20Transfer
).then(exitHash => {
return this.rootChainManager.isExitProcessed(
exitHash

MODIFY
src/pos/pos_token.ts
src/pos/pos_token.ts
import { BaseToken, Web3SideChainClient, promiseResolve } from "../utils";
-import { IBaseClientConfig, IContractInitParam, IPOSClientConfig } from "../interfaces";
-import { RootChainManager } from "./root_chain_manager";
-import { ExitUtil } from "./exit_util";
+import { IContractInitParam, IPOSClientConfig } from "../interfaces";
import { IPOSContracts } from "../interfaces";
export class POSToken extends BaseToken<IPOSClientConfig> {
@@ -17,15 +15,11 @@ export class POSToken extends BaseToken<IPOSClientConfig> {
}
get rootChainManager() {
- const contracts = this.getPOSContracts();
- console.log("contracts", contracts);
- return contracts.rootChainManager;
+ return this.getPOSContracts().rootChainManager;
}
get exitUtil() {
- const contracts = this.getPOSContracts();
- console.log("contracts", contracts);
- return contracts.exitUtil;
+ return this.getPOSContracts().exitUtil;
}

MODIFY
test/debug.js
test/debug.js
-const { PlasmaClient, POSClient, use, Web3SideChainClient } = require("@maticnetwork/maticjs");
+const { setProofApi, POSClient, use } = require("@maticnetwork/maticjs");
const { Web3ClientPlugin } = require("@maticnetwork/maticjs-web3");
const HDWalletProvider = require("@truffle/hdwallet-provider");
@@ -33,7 +33,7 @@ const execute = async () => {
await client.init();
console.log("init called");
- const mumbaiERC720Token = client.erc20(mumbaiERC20);
+ const mumbaiERC20Token = client.erc20(mumbaiERC20);
const goerliERC20Token = client.erc20(goerliERC20, true);
// return console.log(await goerliERC20Token.getAllowance(from));
@@ -50,7 +50,8 @@ const execute = async () => {
// return console.log("tokens", tokens);
// const tx = await goerliERC720Token.safeDeposit(104, from);
- const tx = await mumbaiERC720Token.withdrawStart(10);
+ // setProofApi("https://apis.matic.network")
+ const tx = await goerliERC20Token.withdrawExit('0xd6f7f4c6052611761946519076de28fbd091693af974e7d4abc1b17fd7926fd7');
console.log("txHash", await tx.getTransactionHash());
console.log("txReceipt", await tx.getReceipt());

MODIFY
test/package.json
test/package.json
"install:lib:debug": "npm run install:lib && npm run debug",
"un:lib": "npm un @maticnetwork/maticjs",
"test": "dotenv cross-env NODE_ENV=test karma start karma.conf.js",
+ "test:all": "cross-env NODE_ENV=test_all npm run test",
"test:mocha": "cross-env-file -p ./config.json cross-env NODE_ENV=test mochapack --webpack-config ./webpack.config.test.js --colors ./specs/index.ts"
},
"author": "",

MODIFY
test/specs/erc20.spec.ts
test/specs/erc20.spec.ts
@@ -6,12 +6,13 @@ describe('ERC20', () => {
let erc20Child = posClient.erc20(erc20.child);
let erc20Parent = posClient.erc20(erc20.parent, true);
-
before(() => {
return posClient.init();
});
it('get balance child', async () => {
+ console.log('process.env.test_all', process.env.test_all);
+
const balance = await erc20Child.getBalance(from);
console.log('balance', balance);
expect(balance).to.be.an('string');
@@ -36,8 +37,9 @@ describe('ERC20', () => {
expect(isCheckPointed).to.be.an('boolean').equal(true);
})
- // it('isWithdrawExited', async () => {
- // const isExited = await erc20Parent.isWithdrawExited('0xd6f7f4c6052611761946519076de28fbd091693af974e7d4abc1b17fd7926fd7');
- // expect(isExited).to.be.an('boolean').equal(true);
- // })
+ it('isWithdrawExited', async () => {
+ const exitTxHash = '0x95844235073da694e311dc90476c861e187c36f86a863a950534c9ac2b7c1a48';
+ const isExited = await erc20Parent.isWithdrawExited('0xd6f7f4c6052611761946519076de28fbd091693af974e7d4abc1b17fd7926fd7');
+ expect(isExited).to.be.an('boolean').equal(true);
+ })
});
\ No newline at end of file

add test for isWithdrawExited