Skip to content
This repository has been archived by the owner on May 22, 2023. It is now read-only.

Commit

Permalink
Deploying contracts from dedicated accounts to test more realistic sc…
Browse files Browse the repository at this point in the history
…enario
  • Loading branch information
dimpar committed Dec 18, 2020
1 parent 9bee62e commit 0e2e07c
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions solidity/test/LPRewardsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,28 @@ describe.only("LPRewards", () => {
let rewardDistribution
let staker1
let staker2
let keepTokenContractOwner
let wrappedTokenContractOwner
let lpRewardsContractOwner

before(async () => {
rewardDistribution = accounts[5]
staker1 = accounts[1]
staker2 = accounts[2]
keepToken = await KeepToken.new()
keepTokenContractOwner = accounts[3]
wrappedTokenContractOwner = accounts[4]
lpRewardsContractOwner = accounts[5]
rewardDistribution = accounts[6]

keepToken = await KeepToken.new({from: keepTokenContractOwner})
// This is a "Pair" Uniswap Token which is created here:
// https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2Factory.sol#L23
//
// There are 3 addresses for the following pairs:
// - KEEP/ETH (https://info.uniswap.org/pair/0xe6f19dab7d43317344282f803f8e8d240708174a)
// - TBTC/ETH (https://info.uniswap.org/pair/0x854056fd40c1b52037166285b2e54fee774d33f6)
// - KEEP/TBTC (https://info.uniswap.org/pair/0x38c8ffee49f286f25d25bad919ff7552e5daf081)
wrappedToken = await WrappedToken.new()
lpRewards = await LPRewards.new(keepToken.address, wrappedToken.address)
wrappedToken = await WrappedToken.new({from: wrappedTokenContractOwner})
lpRewards = await LPRewards.new(keepToken.address, wrappedToken.address, {from: lpRewardsContractOwner})
})

beforeEach(async () => {
Expand All @@ -51,7 +58,7 @@ describe.only("LPRewards", () => {

const rewards = web3.utils.toBN(1000042).mul(tokenDecimalMultiplier)

await keepToken.approveAndCall(lpRewards.address, rewards, "0x0")
await keepToken.approveAndCall(lpRewards.address, rewards, "0x0", {from: keepTokenContractOwner})

const finalBalance = await keepToken.balanceOf(lpRewards.address)
expect(finalBalance).to.eq.BN(rewards.add(initialBalance))
Expand Down Expand Up @@ -134,7 +141,7 @@ describe.only("LPRewards", () => {
wrappedTokenStakerBallance
)

await lpRewards.setRewardDistribution(rewardDistribution)
await lpRewards.setRewardDistribution(rewardDistribution, {from: lpRewardsContractOwner})
await lpRewards.notifyRewardAmount(keepRewards, {
from: rewardDistribution,
})
Expand Down Expand Up @@ -185,7 +192,7 @@ describe.only("LPRewards", () => {
wrappedTokenStakerBallance
)

await lpRewards.setRewardDistribution(rewardDistribution)
await lpRewards.setRewardDistribution(rewardDistribution, {from: lpRewardsContractOwner})
await lpRewards.notifyRewardAmount(keepAllocated, {
from: rewardDistribution,
})
Expand Down Expand Up @@ -220,7 +227,7 @@ describe.only("LPRewards", () => {
}

async function fundKEEPReward(address, amount) {
await keepToken.approveAndCall(address, amount, "0x0")
await keepToken.approveAndCall(address, amount, "0x0", {from: keepTokenContractOwner})
}

async function timeIncreaseTo(seconds) {
Expand Down

0 comments on commit 0e2e07c

Please sign in to comment.