Skip to content

Commit

Permalink
test: Onchain pools tests (pancakeswap#721)
Browse files Browse the repository at this point in the history
  • Loading branch information
RabbitDoge authored Mar 23, 2021
1 parent f0cd3ab commit 2000df1
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 192 deletions.
22 changes: 22 additions & 0 deletions src/__tests__/config/pools.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import pools from 'config/constants/pools'
import { getSouschefContract } from 'utils/contractHelpers'

// Pool 0 is special (cake pool)
// Pool 78 is a broken pool, not used, and break the tests
const idsToRemove = [0, 78]
const poolsToTest = pools.filter((pool) => !idsToRemove.includes(pool.sousId))

describe('Config pools', () => {
it.each(pools.map((pool) => pool.sousId))('Pool #%d has an unique sousId', (sousId) => {
Expand All @@ -12,4 +18,20 @@ describe('Config pools', () => {
expect(duplicates).toHaveLength(1)
},
)
it.each(poolsToTest.filter((pool) => pool.earningToken.symbol !== 'BNB'))(
'Pool %p has the correct earning token',
async (pool) => {
const contract = getSouschefContract(pool.sousId)
const rewardTokenAddress = await contract.methods.rewardToken().call()
expect(rewardTokenAddress.toLowerCase()).toBe(pool.earningToken.address[56].toLowerCase())
},
)
it.each(poolsToTest.filter((pool) => pool.stakingToken.symbol !== 'BNB'))(
'Pool %p has the correct staking token',
async (pool) => {
const contract = getSouschefContract(pool.sousId)
const stakingTokenAddress = await contract.methods.syrup().call()
expect(stakingTokenAddress.toLowerCase()).toBe(pool.stakingToken.address[56].toLowerCase())
},
)
})
283 changes: 91 additions & 192 deletions src/config/abi/sousChef.json
Original file line number Diff line number Diff line change
@@ -1,270 +1,169 @@
[
{
"inputs": [
{
"internalType": "contract IBEP20",
"name": "_syrup",
"type": "address"
},
{
"internalType": "uint256",
"name": "_rewardPerBlock",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_startBlock",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_endBlock",
"type": "uint256"
}
{ "internalType": "contract IBEP20", "name": "_syrup", "type": "address" },
{ "internalType": "contract IBEP20", "name": "_rewardToken", "type": "address" },
{ "internalType": "uint256", "name": "_rewardPerBlock", "type": "uint256" },
{ "internalType": "uint256", "name": "_startBlock", "type": "uint256" },
{ "internalType": "uint256", "name": "_bonusEndBlock", "type": "uint256" }
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
{ "indexed": true, "internalType": "address", "name": "user", "type": "address" },
{ "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" }
],
"name": "Deposit",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
{ "indexed": true, "internalType": "address", "name": "user", "type": "address" },
{ "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" }
],
"name": "EmergencyWithdraw",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
{ "indexed": true, "internalType": "address", "name": "previousOwner", "type": "address" },
{ "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" }
],
"name": "OwnershipTransferred",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "address", "name": "user", "type": "address" },
{ "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" }
],
"name": "Withdraw",
"type": "event"
},
{
"inputs": [],
"name": "bonusEndBlock",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function",
"constant": true
"type": "function"
},
{
"inputs": [],
"name": "poolInfo",
"outputs": [
{
"internalType": "uint256",
"name": "lastRewardBlock",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "accRewardPerShare",
"type": "uint256"
}
"inputs": [{ "internalType": "uint256", "name": "_amount", "type": "uint256" }],
"name": "deposit",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "_amount", "type": "uint256" }],
"name": "emergencyRewardWithdraw",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{ "inputs": [], "name": "emergencyWithdraw", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
{
"inputs": [
{ "internalType": "uint256", "name": "_from", "type": "uint256" },
{ "internalType": "uint256", "name": "_to", "type": "uint256" }
],
"name": "getMultiplier",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function",
"constant": true
"type": "function"
},
{ "inputs": [], "name": "massUpdatePools", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
{
"inputs": [],
"name": "rewardPerBlock",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "owner",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function",
"constant": true
"type": "function"
},
{
"inputs": [],
"name": "startBlock",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"inputs": [{ "internalType": "address", "name": "_user", "type": "address" }],
"name": "pendingReward",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function",
"constant": true
"type": "function"
},
{
"inputs": [],
"name": "syrup",
"inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"name": "poolInfo",
"outputs": [
{
"internalType": "contract IBEP20",
"name": "",
"type": "address"
}
{ "internalType": "contract IBEP20", "name": "lpToken", "type": "address" },
{ "internalType": "uint256", "name": "allocPoint", "type": "uint256" },
{ "internalType": "uint256", "name": "lastRewardBlock", "type": "uint256" },
{ "internalType": "uint256", "name": "accCakePerShare", "type": "uint256" }
],
"stateMutability": "view",
"type": "function",
"constant": true
"type": "function"
},
{ "inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "userInfo",
"outputs": [
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "rewardDebt",
"type": "uint256"
}
],
"inputs": [],
"name": "rewardPerBlock",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function",
"constant": true
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_from",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_to",
"type": "uint256"
}
],
"name": "getMultiplier",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"inputs": [],
"name": "rewardToken",
"outputs": [{ "internalType": "contract IBEP20", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function",
"constant": true
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_user",
"type": "address"
}
],
"name": "pendingReward",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"inputs": [],
"name": "startBlock",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function",
"constant": true
"type": "function"
},
{ "inputs": [], "name": "stopReward", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
{
"inputs": [],
"name": "updatePool",
"name": "syrup",
"outputs": [{ "internalType": "contract IBEP20", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
}
],
"name": "deposit",
"inputs": [{ "internalType": "uint256", "name": "_pid", "type": "uint256" }],
"name": "updatePool",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
}
"inputs": [{ "internalType": "address", "name": "", "type": "address" }],
"name": "userInfo",
"outputs": [
{ "internalType": "uint256", "name": "amount", "type": "uint256" },
{ "internalType": "uint256", "name": "rewardDebt", "type": "uint256" }
],
"name": "withdraw",
"outputs": [],
"stateMutability": "nonpayable",
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "emergencyWithdraw",
"inputs": [{ "internalType": "uint256", "name": "_amount", "type": "uint256" }],
"name": "withdraw",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
]

0 comments on commit 2000df1

Please sign in to comment.