You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function tokens(n) {
return web3.utils.toWei(n, 'ether')
}
contract('EthSwap', ([deployer, investor]) => {
let token, ethSwap
before(async () => {
token = await Token.new()
ethSwap = await EthSwap.new(token.address)
// Transfer all token to EthSwap (1 Million)
await token.transfer(ethSwap.address, tokens('1000000'))
})
})
describe('Token deployment', async () => {
it('contract has a name', async () => {
let token = await Token.new()
const name = await token.name()
assert.equal(name, 'DApp Token')
})
})
describe('EthSwap deployment', async () => {
it('contract has a name', async () => {
let ethSwap = await EthSwap.new()
const name = await ethSwap.name()
assert.equal(name, 'EthSwap Instant Exchange')
})
})
describe('buyTokens()', async () => {
let result
before(async () => {
// Purchase tokens before each example
result = await EthSwap.buyTokens({ from: investor, value: web3.utils.toWei('1', 'ether') })
})
})
it('Allows user to instantly purchase tokens from ethSwap for a fixed price', async () => {
// Check investor token balance after purchase
let investorBalance = await token.balanceOf(investor)
assert.equal(investorBalance.toString(), tokens('100'))
I can't figure this out I have been trying for hours now.
[{
"resource": "/c:/Users/Robert Threadgill/Test Project/starter_kit/test/EthSwap.test.js",
"owner": "eslint",
"severity": 8,
"message": "Parsing error: Unexpected token, expected ","\n\n 96 | assert.equal(event.amount.toString(), tokens('100').toString())\n 97 | assert.equal(event.rate.toString(), '100'\n> 98 | })\n | ^\n 99 | })\n 100 | \n 101 | })",
"source": "eslint",
"startLineNumber": 98,
"startColumn": 5,
"endLineNumber": 98,
"endColumn": 5
}]C:\Users\Robert Threadgill\Test Project\starter_kit\test\EthSwap.test.js
const { assert } = require('chai')
const Token = artifacts.require('Token')
const EthSwap = artifacts.require('EthSwap')
require('chai')
.use(require('chai-as-promised'))
.should()
function tokens(n) {
return web3.utils.toWei(n, 'ether')
}
contract('EthSwap', ([deployer, investor]) => {
let token, ethSwap
before(async () => {
token = await Token.new()
ethSwap = await EthSwap.new(token.address)
// Transfer all token to EthSwap (1 Million)
await token.transfer(ethSwap.address, tokens('1000000'))
})
})
describe('Token deployment', async () => {
it('contract has a name', async () => {
let token = await Token.new()
const name = await token.name()
assert.equal(name, 'DApp Token')
})
})
describe('EthSwap deployment', async () => {
it('contract has a name', async () => {
let ethSwap = await EthSwap.new()
const name = await ethSwap.name()
assert.equal(name, 'EthSwap Instant Exchange')
})
})
describe('buyTokens()', async () => {
let result
})
it('Allows user to instantly purchase tokens from ethSwap for a fixed price', async () => {
// Check investor token balance after purchase
let investorBalance = await token.balanceOf(investor)
assert.equal(investorBalance.toString(), tokens('100'))
describe('sellTokens()', async () => {
let result
before(async () => {
// Investor must approve tokens before the purchase
await token.approve(ethSwap.address, ('100'), { from: investor })
// Investor sell tokens
results = await ethSwap.sellTokens(tokens('100'), { from: investor })
})
})
})
The text was updated successfully, but these errors were encountered: