Skip to content

Commit

Permalink
Create Escrow.test.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Jun 12, 2024
1 parent f170cdf commit 59620a3
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions contracts/tests/test/Escrow.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const { expect } = require('chai');
const { web3 } = require('@openzeppelin/test-helpers');
const { BN } = web3.utils;

const Escrow = artifacts.require('Escrow');
const AdvancedToken = artifacts.require('AdvancedToken');

contract('Escrow', ([owner, user1, user2]) => {
let escrow;
let token;

beforeEach(async () => {
token = await AdvancedToken.new({ from: owner });
escrow = await Escrow.new({ from: owner });
});

it('should allow escrow creation', async () => {
await escrow.createEscrow(user1, user2, 100, 300, { from: owner });
expect(await escrow.getEscrowCount()).to.be.bignumber.equal(new BN('1'));
});

it('should allow escrow release', async () => {
await escrow.createEscrow(user1, user2, 100, 300, { from: owner });
await escrow.releaseEscrow(1, { from: user1 });
expect(await token.balanceOf(user2)).to.be.bignumber.equal(new BN('100'));
});

it('should allow escrow refund', async () => {
await escrow.createEscrow(user1, user2, 100, 300, { from: owner });
await escrow.refundEscrow(1, { from: user1 });
expect(await token.balanceOf(user1)).to.be.bignumber.equal(new BN('100'));
});
});

0 comments on commit 59620a3

Please # to comment.