Skip to content

Commit

Permalink
fix: timestamp in seconds instead of ms
Browse files Browse the repository at this point in the history
  • Loading branch information
0xrs committed Mar 15, 2021
1 parent 693995f commit 03797f4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ npx hardhat test
===================Deploying Contracts, Setting Up=====================
Maker Address: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
Taker Address: 0x70997970C51812dc3A010C7d01b50e0d17dc79C8
Initial balance of ERC20 F1 for User1: 100000
Initial balance of ERC20 F1 for User2: 100000
Initial balance of ERC20 F2 for User1: 100000
Initial balance of ERC20 F2 for User2: 100000
Initial balance of ERC20 F1 for User1: 1000
Initial balance of ERC20 F1 for User2: 1000
Initial balance of ERC20 F2 for User1: 1000
Initial balance of ERC20 F2 for User2: 1000
Initial owner of ERC721 NFT1 ID1: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
Initial owner of ERC721 NFT2 ID2: 0x70997970C51812dc3A010C7d01b50e0d17dc79C8
Initial balance of ERC1155 NFT1 ID1 for User1: 10
Expand All @@ -53,12 +53,12 @@ Initial balance of ERC1155 NFT2 ID2 for User2: 10
Do a transaction of basket of assets of different types
✓ Should fail if transaction is made by maker (126ms)
✓ Should succeed if transaction is made by taker (304ms)
Final balance of ERC20 F1 for User1: 99750
Final balance of ERC20 F1 for User2: 100250
Final balance of ERC20 F2 for User1: 100750
Final balance of ERC20 F2 for User2: 99250
✓ Should fail if transaction is made by maker (134ms)
✓ Should succeed if transaction is made by taker (295ms)
Final balance of ERC20 F1 for User1: 750
Final balance of ERC20 F1 for User2: 1250
Final balance of ERC20 F2 for User1: 1750
Final balance of ERC20 F2 for User2: 250
Final owner of ERC721 NFT1 ID1: 0x70997970C51812dc3A010C7d01b50e0d17dc79C8
Final owner of ERC721 NFT2 ID2: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
Final balance of ERC1155 NFT1 ID1 for User1: 6
Expand All @@ -69,7 +69,7 @@ Final balance of ERC1155 NFT2 ID1 for User1: 10
Final balance of ERC1155 NFT2 ID2 for User1: 2
Final balance of ERC1155 NFT2 ID1 for User2: 0
Final balance of ERC1155 NFT2 ID2 for User2: 8
✓ User balances should have updated values after swap (316ms)
✓ User balances should have updated values after swap (307ms)
3 passing (5s)
Expand Down
14 changes: 7 additions & 7 deletions test/swap-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ before(async() => {

[owner, addr1, ...addrs] = await web3.eth.getAccounts();
[owner_e, addr1_e, ...addrs_e] = await ethers.getSigners();
const initial_mint = web3.utils.toWei('100000', 'ether');
const initial_mint = web3.utils.toWei('1000', 'ether');
const MetaExchange = await ethers.getContractFactory("MetaExchange");
metaExchange = await MetaExchange.deploy();
await metaExchange.deployed();
Expand Down Expand Up @@ -130,7 +130,7 @@ describe("Do a transaction of basket of assets of different types", function() {
let takerErc1155Ids = [2];
let takerErc1155Amounts = [2];

let expiration = new Date().getTime() + 60000;
let expiration = Math.floor(Date.now() / 1000) + 1000;
let nonce = 1;

let makerArgs = [makerAddress, makerErc20Addresses,
Expand Down Expand Up @@ -186,7 +186,7 @@ describe("Do a transaction of basket of assets of different types", function() {
let takerErc1155Ids = [2];
let takerErc1155Amounts = [2];

let expiration = new Date().getTime() + 60000;
let expiration = Math.floor(Date.now() / 1000) + 1000;
let nonce = 1;

let makerArgs = [makerAddress, makerErc20Addresses,
Expand Down Expand Up @@ -225,10 +225,10 @@ describe("Do a transaction of basket of assets of different types", function() {
})

it("User balances should have updated values after swap", async() => {
expect(web3.utils.fromWei((await f1.balanceOf(owner)).toString())).to.equal('99750');
expect(web3.utils.fromWei((await f1.balanceOf(addr1)).toString())).to.equal('100250');
expect(web3.utils.fromWei((await f2.balanceOf(owner)).toString())).to.equal('100750');
expect(web3.utils.fromWei((await f2.balanceOf(addr1)).toString())).to.equal('99250');
expect(web3.utils.fromWei((await f1.balanceOf(owner)).toString())).to.equal('750');
expect(web3.utils.fromWei((await f1.balanceOf(addr1)).toString())).to.equal('1250');
expect(web3.utils.fromWei((await f2.balanceOf(owner)).toString())).to.equal('1750');
expect(web3.utils.fromWei((await f2.balanceOf(addr1)).toString())).to.equal('250');

expect(await nf1.ownerOf(1)).to.equal(addr1);
expect(await nf2.ownerOf(2)).to.equal(owner);
Expand Down

0 comments on commit 03797f4

Please sign in to comment.