upd: PoS testcases
MODIFY
examples/package.json
examples/package.json
"license": "ISC",
"dependencies": {
"@maticnetwork/maticjs": "^3.4.0",
- "@maticnetwork/maticjs-web3": "^0.8.0",
+ "@maticnetwork/maticjs-web3": "^1.0.4",
"@truffle/hdwallet-provider": "^1.5.1-alpha.1",
"dotenv": "^10.0.0"
}

MODIFY
package.json
package.json
"test": "cd test && npm run install:lib:test",
"debug": "npm run build:pack && cd test && npm run install:lib:debug",
"testrpc": "ganache-cli --mnemonic 'clock radar mass judge dismiss just intact mind resemble fringe diary casino' --gasLimit 13000000",
- "install:example": "cd examples && npm i ../maticnetwork-maticjs-3.0.0-beta.2.tgz --no-save"
+ "install:example": "cd examples && npm i ../maticnetwork-maticjs-3.5.0.tgz --no-save"
},
"repository": {
"type": "git",

MODIFY
test/config.js
test/config.js
@@ -16,8 +16,8 @@ module.exports = {
},
pos: {
parent: {
- erc20: '0x3f152b63ec5ca5831061b2dccfb29a874c317502',
- // erc20: '0x655f2166b0709cd575202630952d71e2bb0d61af',
+ // erc20: '0x3f152b63ec5ca5831061b2dccfb29a874c317502',
+ erc20: '0x655f2166b0709cd575202630952d71e2bb0d61af',
erc721: '0x16f7ef3774c59264c46e5063b1111bcfd6e7a72f',
// erc721: '0x5a08d01e07714146747950CE07BB0f741445D1b8',
erc1155: '0x2e3Ef7931F2d0e4a7da3dea950FF3F19269d9063',
@@ -25,8 +25,8 @@ module.exports = {
},
child: {
erc721: '0xbD88C3A7c0e242156a46Fbdf87141Aa6D0c0c649',
- // erc20: '0xfe4F5145f6e09952a5ba9e956ED0C25e3Fa4c7F1',
- erc20: '0xA0D9f8282cD48d22Fd875E43Be32793124f8eD47',
+ erc20: '0xfe4F5145f6e09952a5ba9e956ED0C25e3Fa4c7F1',
+ // erc20: '0xA0D9f8282cD48d22Fd875E43Be32793124f8eD47',
weth: '0x714550C2C1Ea08688607D86ed8EeF4f5E4F22323',
erc1155: '0xA07e45A987F19E25176c877d98388878622623FA',
},

MODIFY
test/specs/hermez/erc20.spec.ts
test/specs/hermez/erc20.spec.ts
@@ -180,7 +180,7 @@ describe('ERC20', () => {
// APPROVE
it('approve parent return tx', async () => {
- const result = await erc20Parent.approve('10', {
+ const result = await erc20Parent.approve('10000', {
returnTransaction: true
});

MODIFY
test/specs/pos/erc1155.spec.ts
test/specs/pos/erc1155.spec.ts
@@ -67,7 +67,7 @@ describe('ERC1155', () => {
it('deposit return tx', async () => {
const tx = await erc1155Parent.deposit({
- amount: 10,
+ amount: 1,
tokenId: 123,
userAddress: from
}, {

MODIFY
test/specs/pos/erc20.spec.ts
test/specs/pos/erc20.spec.ts
@@ -55,8 +55,8 @@ describe('ERC20', () => {
expect(isExited).to.be.an('boolean').equal(true);
})
- it('child transfer returnTransaction with erp1159', async () => {
- const amount = 10;
+ it('child transfer returnTransaction with eip1159', async () => {
+ const amount = 1;
try {
const result = await erc20Child.transfer(amount, to, {
maxFeePerGas: 10,
@@ -74,7 +74,7 @@ describe('ERC20', () => {
});
it('child transfer returnTransaction', async () => {
- const amount = 10;
+ const amount = 1;
const result = await erc20Child.transfer(amount, to, {
returnTransaction: true
});
@@ -86,8 +86,8 @@ describe('ERC20', () => {
expect(result['chainId']).to.be.an('number');
});
- it('parent transfer returnTransaction with erp1159', async () => {
- const amount = 10;
+ it('parent transfer returnTransaction with eip1159', async () => {
+ const amount = 1;
const result = await erc20Parent.transfer(amount, to, {
maxFeePerGas: 20,
maxPriorityFeePerGas: 20,
@@ -109,7 +109,7 @@ describe('ERC20', () => {
it('withdrawstart return tx', async () => {
- const result = await erc20Child.withdrawStart('10', {
+ const result = await erc20Child.withdrawStart('1', {
returnTransaction: true
});
@@ -119,7 +119,7 @@ describe('ERC20', () => {
});
it('approve parent return tx', async () => {
- const result = await erc20Parent.approve('10', {
+ const result = await erc20Parent.approve('1', {
returnTransaction: true
});
@@ -130,7 +130,7 @@ describe('ERC20', () => {
it('approve parent return tx with spender address', async () => {
const spenderAddress = await erc20Parent.getPredicateAddress();
- const result = await erc20Parent.approve('10', {
+ const result = await erc20Parent.approve('1', {
spenderAddress: spenderAddress,
returnTransaction: true
});
@@ -142,7 +142,7 @@ describe('ERC20', () => {
it('approve child return tx without spender address', async () => {
try {
- const result = await erc20Child.approve('10');
+ const result = await erc20Child.approve('1');
expect(result['to'].toLowerCase()).equal(erc20.child.toLowerCase());
expect(result).to.have.property('data');
} catch (error) {
@@ -155,7 +155,7 @@ describe('ERC20', () => {
});
it('deposit return tx', async () => {
- const result = await erc20Parent.deposit(10, from, {
+ const result = await erc20Parent.deposit(1, from, {
returnTransaction: true
});
@@ -227,7 +227,7 @@ describe('ERC20', () => {
it('child transfer', async () => {
const oldBalance = await erc20Child.getBalance(to);
console.log('oldBalance', oldBalance);
- const amount = 10000000;
+ const amount = 1;
let result = await erc20Child.transfer(amount, to);
let txHash = await result.getTransactionHash();
expect(txHash).to.be.an('string');
@@ -285,7 +285,7 @@ describe('ERC20', () => {
});
it('deposit', async () => {
- const result = await erc20Parent.deposit('10', from);
+ const result = await erc20Parent.deposit('1', from);
const txHash = await result.getTransactionHash();
expect(txHash).to.be.an('string');

MODIFY
test/specs/pos/erc721.spec.ts
test/specs/pos/erc721.spec.ts
@@ -56,14 +56,14 @@ describe('ERC721', () => {
it('transfer return tx', async () => {
const allTokensFrom = await erc721Child.getAllTokens(from);
const targetToken = allTokensFrom[0];
-
-
-
+ if (targetToken) {
const result = await erc721Child.transfer(targetToken, from, to, {
returnTransaction: true
});
// console.log(result);
expect(result['to'].toLowerCase()).equal(erc721.child.toLowerCase());
+ }
+
})
it('approve return tx', async () => {
@@ -83,36 +83,45 @@ describe('ERC721', () => {
it('deposit return tx', async () => {
const allTokens = await erc721Parent.getAllTokens(from);
+ if (allTokens && allTokens[0]) {
const tx = await erc721Parent.deposit(allTokens[0], from, {
returnTransaction: true
});
const rootChainManager = await abiManager.getConfig("Main.POSContracts.RootChainManagerProxy")
expect(tx['to'].toLowerCase()).equal(rootChainManager.toLowerCase());
+ }
})
it('depositMany return tx', async () => {
const allTokens = await erc721Parent.getAllTokens(from);
+ if (allTokens && allTokens.length) {
const tx = await erc721Parent.depositMany(allTokens, from, {
returnTransaction: true
});
const rootChainManager = await abiManager.getConfig("Main.POSContracts.RootChainManagerProxy")
expect(tx['to'].toLowerCase()).equal(rootChainManager.toLowerCase());
+ }
+
})
it('withdrawStart return tx', async () => {
const allTokens = await erc721Child.getAllTokens(from);
+ if (allTokens && allTokens.length) {
const result = await erc721Child.withdrawStart(allTokens[0], {
returnTransaction: true
});
expect(result['to'].toLowerCase()).equal(erc721.child.toLowerCase());
+ }
})
it('withdrawStartWithMetaData return tx', async () => {
const allTokens = await erc721Child.getAllTokens(from);
+ if (allTokens && allTokens.length) {
const result = await erc721Child.withdrawStartWithMetaData(allTokens[0], {
returnTransaction: true
});
expect(result['to'].toLowerCase()).equal(erc721.child.toLowerCase());
+ }
})
it('transfer write', async () => {
@@ -122,6 +131,7 @@ describe('ERC721', () => {
// console.log('allTokensTo', allTokensTo);
const targetToken = allTokensFrom[0];
+ if (targetToken) {
let result = await erc721Child.transfer(targetToken, from, to);
let txHash = await result.getTransactionHash();
@@ -159,6 +169,7 @@ describe('ERC721', () => {
expect(newFromCount).equal(allTokensFrom.length);
expect(newToCount).equal(allTokensTo.length);
+ }
})
@@ -166,9 +177,12 @@ describe('ERC721', () => {
it('approve', async () => {
const allTokens = await erc721Parent.getAllTokens(from);
+ if (allTokens && allTokens[0]) {
const result = await erc721Parent.approve(allTokens[0], {
returnTransaction: true
});
expect(result['to'].toLowerCase()).equal(erc721.parent.toLowerCase());
+ }
+
})
});

upd: PoS testcases