Skip to content
This repository has been archived by the owner on Oct 14, 2021. It is now read-only.

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
pancake-swap committed Sep 23, 2020
1 parent 6c0f9af commit e9832ea
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 21 deletions.
4 changes: 2 additions & 2 deletions contracts/PancakeERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import './libraries/SafeMath.sol';
contract PancakeERC20 is IPancakeERC20 {
using SafeMath for uint;

string public constant name = 'Uniswap V2';
string public constant symbol = 'UNI-V2';
string public constant name = 'Pancake LPs';
string public constant symbol = 'Cake-LP';
uint8 public constant decimals = 18;
uint public totalSupply;
mapping(address => uint) public balanceOf;
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{
"name": "pancake/core",
"name": "@pancakeswap/pancake-swap-core",
"description": "🎛 Core contracts for the pancake protocol",
"version": "1.0.1",
"version": "0.0.1",
"homepage": "https://pancakeswap.finance",
"repository": {
"type": "git",
"url": "https://github.com/pancakeswap/pancake-swap-core.git"
},
"publishConfig": {
"registry": "http://registry.npmjs.org"
},
"files": [
"contracts",
"build"
Expand Down
2 changes: 1 addition & 1 deletion test/UniswapV2ERC20.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ chai.use(solidity)
const TOTAL_SUPPLY = expandTo18Decimals(10000)
const TEST_AMOUNT = expandTo18Decimals(10)

describe('UniswapV2ERC20', () => {
describe('PancakeERC20', () => {
const provider = new MockProvider({
hardfork: 'istanbul',
mnemonic: 'horn horn horn horn horn horn horn horn horn horn horn horn',
Expand Down
18 changes: 9 additions & 9 deletions test/UniswapV2Factory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { solidity, MockProvider, createFixtureLoader } from 'ethereum-waffle'
import { getCreate2Address } from './shared/utilities'
import { factoryFixture } from './shared/fixtures'

import UniswapV2Pair from '../build/UniswapV2Pair.json'
import PancakePair from '../build/PancakePair.json'

chai.use(solidity)

Expand All @@ -16,7 +16,7 @@ const TEST_ADDRESSES: [string, string] = [
'0x2000000000000000000000000000000000000000'
]

describe('UniswapV2Factory', () => {
describe('PancakeFactory', () => {
const provider = new MockProvider({
hardfork: 'istanbul',
mnemonic: 'horn horn horn horn horn horn horn horn horn horn horn horn',
Expand All @@ -38,20 +38,20 @@ describe('UniswapV2Factory', () => {
})

async function createPair(tokens: [string, string]) {
const bytecode = `0x${UniswapV2Pair.evm.bytecode.object}`
const bytecode = `0x${PancakePair.evm.bytecode.object}`
const create2Address = getCreate2Address(factory.address, tokens, bytecode)
await expect(factory.createPair(...tokens))
.to.emit(factory, 'PairCreated')
.withArgs(TEST_ADDRESSES[0], TEST_ADDRESSES[1], create2Address, bigNumberify(1))

await expect(factory.createPair(...tokens)).to.be.reverted // UniswapV2: PAIR_EXISTS
await expect(factory.createPair(...tokens.slice().reverse())).to.be.reverted // UniswapV2: PAIR_EXISTS
await expect(factory.createPair(...tokens)).to.be.reverted // Pancake: PAIR_EXISTS
await expect(factory.createPair(...tokens.slice().reverse())).to.be.reverted // Pancake: PAIR_EXISTS
expect(await factory.getPair(...tokens)).to.eq(create2Address)
expect(await factory.getPair(...tokens.slice().reverse())).to.eq(create2Address)
expect(await factory.allPairs(0)).to.eq(create2Address)
expect(await factory.allPairsLength()).to.eq(1)

const pair = new Contract(create2Address, JSON.stringify(UniswapV2Pair.abi), provider)
const pair = new Contract(create2Address, JSON.stringify(PancakePair.abi), provider)
expect(await pair.factory()).to.eq(factory.address)
expect(await pair.token0()).to.eq(TEST_ADDRESSES[0])
expect(await pair.token1()).to.eq(TEST_ADDRESSES[1])
Expand All @@ -72,15 +72,15 @@ describe('UniswapV2Factory', () => {
})

it('setFeeTo', async () => {
await expect(factory.connect(other).setFeeTo(other.address)).to.be.revertedWith('UniswapV2: FORBIDDEN')
await expect(factory.connect(other).setFeeTo(other.address)).to.be.revertedWith('Pancake: FORBIDDEN')
await factory.setFeeTo(wallet.address)
expect(await factory.feeTo()).to.eq(wallet.address)
})

it('setFeeToSetter', async () => {
await expect(factory.connect(other).setFeeToSetter(other.address)).to.be.revertedWith('UniswapV2: FORBIDDEN')
await expect(factory.connect(other).setFeeToSetter(other.address)).to.be.revertedWith('Pancake: FORBIDDEN')
await factory.setFeeToSetter(other.address)
expect(await factory.feeToSetter()).to.eq(other.address)
await expect(factory.setFeeToSetter(wallet.address)).to.be.revertedWith('UniswapV2: FORBIDDEN')
await expect(factory.setFeeToSetter(wallet.address)).to.be.revertedWith('Pancake: FORBIDDEN')
})
})
6 changes: 3 additions & 3 deletions test/UniswapV2Pair.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const overrides = {
gasLimit: 9999999
}

describe('UniswapV2Pair', () => {
describe('PancakePair', () => {
const provider = new MockProvider({
hardfork: 'istanbul',
mnemonic: 'horn horn horn horn horn horn horn horn horn horn horn horn',
Expand Down Expand Up @@ -84,7 +84,7 @@ describe('UniswapV2Pair', () => {
await addLiquidity(token0Amount, token1Amount)
await token0.transfer(pair.address, swapAmount)
await expect(pair.swap(0, expectedOutputAmount.add(1), wallet.address, '0x', overrides)).to.be.revertedWith(
'UniswapV2: K'
'Pancake: K'
)
await pair.swap(0, expectedOutputAmount, wallet.address, '0x', overrides)
})
Expand All @@ -102,7 +102,7 @@ describe('UniswapV2Pair', () => {
await addLiquidity(token0Amount, token1Amount)
await token0.transfer(pair.address, inputAmount)
await expect(pair.swap(outputAmount.add(1), 0, wallet.address, '0x', overrides)).to.be.revertedWith(
'UniswapV2: K'
'Pancake: K'
)
await pair.swap(outputAmount, 0, wallet.address, '0x', overrides)
})
Expand Down
8 changes: 4 additions & 4 deletions test/shared/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { deployContract } from 'ethereum-waffle'
import { expandTo18Decimals } from './utilities'

import ERC20 from '../../build/ERC20.json'
import UniswapV2Factory from '../../build/UniswapV2Factory.json'
import UniswapV2Pair from '../../build/UniswapV2Pair.json'
import PancakeFactory from '../../build/PancakeFactory.json'
import PancakePair from '../../build/PancakePair.json'

interface FactoryFixture {
factory: Contract
Expand All @@ -17,7 +17,7 @@ const overrides = {
}

export async function factoryFixture(_: Web3Provider, [wallet]: Wallet[]): Promise<FactoryFixture> {
const factory = await deployContract(wallet, UniswapV2Factory, [wallet.address], overrides)
const factory = await deployContract(wallet, PancakeFactory, [wallet.address], overrides)
return { factory }
}

Expand All @@ -35,7 +35,7 @@ export async function pairFixture(provider: Web3Provider, [wallet]: Wallet[]): P

await factory.createPair(tokenA.address, tokenB.address, overrides)
const pairAddress = await factory.getPair(tokenA.address, tokenB.address)
const pair = new Contract(pairAddress, JSON.stringify(UniswapV2Pair.abi), provider).connect(wallet)
const pair = new Contract(pairAddress, JSON.stringify(PancakePair.abi), provider).connect(wallet)

const token0Address = (await pair.token0()).address
const token0 = tokenA.address === token0Address ? tokenA : tokenB
Expand Down

0 comments on commit e9832ea

Please sign in to comment.