-
Notifications
You must be signed in to change notification settings - Fork 594
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tweaks on incoming integration tests
- Loading branch information
1 parent
2572a79
commit c665d9d
Showing
9 changed files
with
188 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,40 @@ | ||
const ethers = require('ethers'); | ||
const { assert } = require('../../contracts/common'); | ||
const { ensureBalance } = require('../utils/balances'); | ||
|
||
function itCanPerformERC20Transfers({ ctx }) { | ||
const SNXAmount = ethers.utils.parseEther('10000'); | ||
function itBehavesLikeAnERC20({ ctx }) { | ||
describe('erc20 functionality', () => { | ||
let user; | ||
let Synthetix; | ||
|
||
let user; | ||
let Synthetix; | ||
let userBalance; | ||
|
||
before('target contracts and users', () => { | ||
({ Synthetix } = ctx.contracts); | ||
before('target contracts and users', () => { | ||
({ Synthetix } = ctx.contracts); | ||
|
||
user = ctx.user; | ||
}); | ||
user = ctx.user; | ||
}); | ||
|
||
before('ensure the user has SNX', async () => { | ||
await ensureBalance({ ctx, symbol: 'SNX', user, balance: SNXAmount }); | ||
}); | ||
before('record user balance', async () => { | ||
userBalance = await Synthetix.balanceOf(user.address); | ||
}); | ||
|
||
describe('when the owner transfers SNX to the user', () => { | ||
const amountToTransfer = ethers.utils.parseEther('1'); | ||
|
||
before('transfer', async () => { | ||
Synthetix = Synthetix.connect(ctx.owner); | ||
|
||
const tx = await Synthetix.transfer(user.address, amountToTransfer); | ||
await tx.wait(); | ||
}); | ||
|
||
it('receives the expected amount of SNX', async () => { | ||
assert.bnEqual(await Synthetix.balanceOf(user.address), SNXAmount); | ||
it('increases the users balance', async () => { | ||
assert.bnEqual(await Synthetix.balanceOf(user.address), userBalance.add(amountToTransfer)); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
module.exports = { | ||
itCanPerformERC20Transfers, | ||
itBehavesLikeAnERC20, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
const ethers = require('ethers'); | ||
const { assert } = require('../../contracts/common'); | ||
const { ensureBalance } = require('../utils/balances'); | ||
const { ignoreMinimumStakeTime } = require('../utils/stakeTime'); | ||
|
||
function itCanMintAndBurn({ ctx }) { | ||
describe('staking', () => { | ||
const SNXAmount = ethers.utils.parseEther('1'); | ||
const sUSDamount = ethers.utils.parseEther('1'); | ||
|
||
let user; | ||
let Synthetix, SynthsUSD; | ||
let balancesUSD; | ||
|
||
before('target contracts and users', () => { | ||
({ Synthetix, SynthsUSD } = ctx.contracts); | ||
|
||
user = ctx.user; | ||
}); | ||
|
||
before('ensure the user has SNX', async () => { | ||
await ensureBalance({ ctx, symbol: 'SNX', user, balance: SNXAmount }); | ||
}); | ||
|
||
describe('when the user issues sUSD', () => { | ||
before('record balances', async () => { | ||
balancesUSD = await SynthsUSD.balanceOf(user.address); | ||
}); | ||
|
||
before('perform the issuance', async () => { | ||
Synthetix = Synthetix.connect(user); | ||
|
||
const tx = await Synthetix.issueSynths(sUSDamount); | ||
await tx.wait(); | ||
}); | ||
|
||
it('issues the expected amount of sUSD', async () => { | ||
assert.bnEqual(await SynthsUSD.balanceOf(user.address), balancesUSD.add(sUSDamount)); | ||
}); | ||
}); | ||
|
||
describe('when the user burns sUSD', () => { | ||
ignoreMinimumStakeTime({ ctx }); | ||
|
||
before('record values', async () => { | ||
balancesUSD = await SynthsUSD.balanceOf(user.address); | ||
}); | ||
|
||
before('burn the sUSD', async () => { | ||
Synthetix = Synthetix.connect(user); | ||
|
||
const tx = await Synthetix.burnSynths(sUSDamount); | ||
await tx.wait(); | ||
}); | ||
|
||
it('burnt the expected amount of sUSD', async () => { | ||
assert.bnEqual(await SynthsUSD.balanceOf(user.address), balancesUSD.sub(sUSDamount)); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
module.exports = { | ||
itCanMintAndBurn, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const { bootstrapL1 } = require('../utils/bootstrap'); | ||
const { itCanExchange } = require('../behaviors/exchange.behavior'); | ||
const { itCanMintAndBurn } = require('../behaviors/stake.behavior'); | ||
const { itBehavesLikeAnERC20 } = require('../behaviors/erc20.behavior'); | ||
|
||
describe('Synthetix integration tests (L1)', () => { | ||
const ctx = this; | ||
bootstrapL1({ ctx }); | ||
|
||
itCanExchange({ ctx }); | ||
itCanMintAndBurn({ ctx }); | ||
itBehavesLikeAnERC20({ ctx }); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const { bootstrapL2 } = require('../utils/bootstrap'); | ||
const { itCanExchange } = require('../behaviors/exchange.behavior'); | ||
const { itCanMintAndBurn } = require('../behaviors/stake.behavior'); | ||
const { itBehavesLikeAnERC20 } = require('../behaviors/erc20.behavior'); | ||
|
||
describe('Synthetix integration tests (L2)', () => { | ||
const ctx = this; | ||
bootstrapL2({ ctx }); | ||
|
||
itCanExchange({ ctx }); | ||
itCanMintAndBurn({ ctx }); | ||
itBehavesLikeAnERC20({ ctx }); | ||
}); |
Oops, something went wrong.