add test for approve, deposit, depositEther with returnTransaction
MODIFY
src/helpers/index.ts
src/helpers/index.ts
export * from "./do_nothing";
export * from "./contract_write_result";
\ No newline at end of file
-export * from "./abi_helper";
\ No newline at end of file

RENAME
src/helpers/abi_helper.ts
src/utils/abi_manager.ts
import { service } from "../services";
-import { resolve, promiseResolve } from "../utils";
+import { resolve, promiseResolve } from ".";
type T_ABI_CACHE = {
[networkName: string]: {

MODIFY
src/utils/index.ts
src/utils/index.ts
@@ -13,3 +13,4 @@ export * from "./set_proof_api_url";
export * from "./resolve";
export * from "./promise_resolve";
export * from "./bridge_client";
+export * from "./abi_manager";
\ No newline at end of file

MODIFY
src/utils/web3_side_chain_client.ts
src/utils/web3_side_chain_client.ts
import { getWeb3Client } from "../constant";
-import { IBaseClientConfig, IPOSClientConfig } from "../interfaces";
+import { IBaseClientConfig } from "../interfaces";
import { BaseWeb3Client } from "../abstracts";
-import { ABIManager } from "../helpers";
+import { ABIManager } from "../utils";
import { Logger } from "./logger";
export class Web3SideChainClient<T_CONFIG> {

MODIFY
test/specs/erc20.spec.ts
test/specs/erc20.spec.ts
import { erc20, from, posClient, to } from "./client";
import { expect } from 'chai'
+import { ABIManager } from '@maticnetwork/maticjs'
import BN from "bn.js";
@@ -7,8 +8,13 @@ describe('ERC20', () => {
let erc20Child = posClient.erc20(erc20.child);
let erc20Parent = posClient.erc20(erc20.parent, true);
+
+ const abiManager = new ABIManager("testnet", "mumbai");
before(() => {
- return posClient.init();
+ return Promise.all([
+ posClient.init(),
+ abiManager.init()
+ ]);
});
it('get balance child', async () => {
@@ -97,6 +103,35 @@ describe('ERC20', () => {
// expect(isExited).to.be.an('boolean').equal(true);
// })
+ it('withdrawstart return tx', async () => {
+ const result = await erc20Child.withdrawStart('10', {
+ returnTransaction: true
+ });
+
+ expect(result['to'].toLowerCase()).equal(erc20.child.toLowerCase());
+ expect(result).to.have.property('data')
+
+ });
+
+ it('approve return tx', async () => {
+ const result = await erc20Parent.approve('10', {
+ returnTransaction: true
+ });
+
+ expect(result['to'].toLowerCase()).equal(erc20.parent.toLowerCase());
+ expect(result).to.have.property('data')
+
+ });
+
+ it('deposit return tx', async () => {
+ const result = await erc20Parent.deposit(10, from, {
+ returnTransaction: true
+ });
+
+ const rootChainManager = await abiManager.getConfig("Main.POSContracts.RootChainManagerProxy")
+ expect(result['to'].toLowerCase()).equal(rootChainManager.toLowerCase());
+ });
+
it('child transfer', async () => {
const oldBalance = await erc20Child.getBalance(to);
console.log('oldBalance', oldBalance);

MODIFY
test/specs/pos_client.spec.ts
test/specs/pos_client.spec.ts
import { erc721, from, posClient } from "./client";
import { expect } from 'chai'
+import { ABIManager } from '@maticnetwork/maticjs'
+describe('POS Client', () => {
-describe('POS Bridge', () => {
-
+ const abiManager = new ABIManager("testnet", "mumbai");
before(() => {
- return posClient.init();
+ return Promise.all([
+ posClient.init(),
+ abiManager.init()
+ ]);
});
it('depositEther return transaction', async () => {
@@ -13,7 +17,8 @@ describe('POS Bridge', () => {
const result = await posClient.depositEther(amount, from, {
returnTransaction: true
});
- console.log('tokensCount', result);
-
+ const rootChainManager = await abiManager.getConfig("Main.POSContracts.RootChainManagerProxy")
+ expect(result['to'].toLowerCase()).equal(rootChainManager.toLowerCase());
+ expect(result['value']).equal('0x64')
})
});
\ No newline at end of file

add test for approve, deposit, depositEther with returnTransaction