mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
Adding tests to check if the number of decimals is correct for the publishMarketFee
This commit is contained in:
parent
ece4883743
commit
8699e4a8bb
@ -30,7 +30,6 @@
|
|||||||
"mocha": "TS_NODE_PROJECT='./test/tsconfig.json' mocha --config=test/.mocharc.json --node-env=test --exit",
|
"mocha": "TS_NODE_PROJECT='./test/tsconfig.json' mocha --config=test/.mocharc.json --node-env=test --exit",
|
||||||
"test": "npm run lint && npm run test:unit:cover && npm run test:integration:cover",
|
"test": "npm run lint && npm run test:unit:cover && npm run test:integration:cover",
|
||||||
"test:unit": "npm run mocha -- 'test/unit/**/*.test.ts'",
|
"test:unit": "npm run mocha -- 'test/unit/**/*.test.ts'",
|
||||||
"test:fixed": "npm run mocha -- 'test/unit/FixedRateExchange.test.ts'",
|
|
||||||
"test:integration": "npm run mocha -- 'test/integration/**/*.test.ts'",
|
"test:integration": "npm run mocha -- 'test/integration/**/*.test.ts'",
|
||||||
"test:unit:cover": "nyc --report-dir coverage/unit npm run test:unit",
|
"test:unit:cover": "nyc --report-dir coverage/unit npm run test:unit",
|
||||||
"test:integration:cover": "nyc --report-dir coverage/integration --no-clean npm run test:integration",
|
"test:integration:cover": "nyc --report-dir coverage/integration --no-clean npm run test:integration",
|
||||||
|
@ -64,7 +64,7 @@ describe('Fixed Rate unit test', () => {
|
|||||||
dtParams.mpFeeAddress = await factoryOwner.getAddress()
|
dtParams.mpFeeAddress = await factoryOwner.getAddress()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Test a Fixed Rate Exchange with DAI (18 Decimals)', () => {
|
describe('Test a Fixed Rate Exchange with DAI (18 Decimals) as Basetoken', () => {
|
||||||
it('#create an exchange', async () => {
|
it('#create an exchange', async () => {
|
||||||
// CREATE AN Exchange
|
// CREATE AN Exchange
|
||||||
// we prepare transaction parameters objects
|
// we prepare transaction parameters objects
|
||||||
@ -459,7 +459,7 @@ describe('Fixed Rate unit test', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Test a Fixed Rate Exchange with USDC (6 Decimals)', () => {
|
describe('Test a Fixed Rate Exchange with USDC (6 Decimals) as Basetoken', () => {
|
||||||
it('#create an exchange', async () => {
|
it('#create an exchange', async () => {
|
||||||
// CREATE AN Exchange
|
// CREATE AN Exchange
|
||||||
// we prepare transaction parameters objects
|
// we prepare transaction parameters objects
|
||||||
@ -811,4 +811,89 @@ describe('Fixed Rate unit test', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('Test a Fixed Rate Exchange With Different Fee Tokens', () => {
|
||||||
|
it('#create a fixed rate exchange with DAI as feetoken', async () => {
|
||||||
|
// CREATE AN Exchange
|
||||||
|
// we prepare transaction parameters objects
|
||||||
|
|
||||||
|
const nftFactory = new NftFactory(addresses.ERC721Factory, exchangeOwner)
|
||||||
|
|
||||||
|
const freParams: FreCreationParams = {
|
||||||
|
fixedRateAddress: addresses.FixedPrice,
|
||||||
|
baseTokenAddress: addresses.MockDAI,
|
||||||
|
owner: await exchangeOwner.getAddress(),
|
||||||
|
marketFeeCollector: await user2.getAddress(),
|
||||||
|
baseTokenDecimals: 18,
|
||||||
|
datatokenDecimals: 18,
|
||||||
|
fixedRate: '1',
|
||||||
|
marketFee: '0.001',
|
||||||
|
allowedConsumer: ZERO_ADDRESS,
|
||||||
|
withMint: false
|
||||||
|
}
|
||||||
|
|
||||||
|
dtParams.feeToken = addresses.MockDAI
|
||||||
|
dtParams.feeAmount = '0.123456789'
|
||||||
|
|
||||||
|
const tx = await nftFactory.createNftWithDatatokenWithFixedRate(
|
||||||
|
nftData,
|
||||||
|
dtParams,
|
||||||
|
freParams
|
||||||
|
)
|
||||||
|
const txReceipt = await tx.wait()
|
||||||
|
const tokenCreatedEvent = getEventFromTx(txReceipt, 'TokenCreated')
|
||||||
|
|
||||||
|
const datatokenAddress = tokenCreatedEvent.args.newTokenAddress
|
||||||
|
|
||||||
|
const datatoken = new Datatoken(exchangeOwner)
|
||||||
|
|
||||||
|
const publishingMarketFee = await datatoken.getPublishingMarketFee(datatokenAddress)
|
||||||
|
|
||||||
|
assert(
|
||||||
|
publishingMarketFee.publishMarketFeeAmount ===
|
||||||
|
ethers.utils.parseUnits('0.123456789').toString()
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('#create a fixed rate exchange with USDC as feetoken', async () => {
|
||||||
|
// CREATE AN Exchange
|
||||||
|
// we prepare transaction parameters objects
|
||||||
|
|
||||||
|
const nftFactory = new NftFactory(addresses.ERC721Factory, exchangeOwner)
|
||||||
|
|
||||||
|
const freParams: FreCreationParams = {
|
||||||
|
fixedRateAddress: addresses.FixedPrice,
|
||||||
|
baseTokenAddress: addresses.MockDAI,
|
||||||
|
owner: await exchangeOwner.getAddress(),
|
||||||
|
marketFeeCollector: await user2.getAddress(),
|
||||||
|
baseTokenDecimals: 18,
|
||||||
|
datatokenDecimals: 18,
|
||||||
|
fixedRate: '1',
|
||||||
|
marketFee: '0.001',
|
||||||
|
allowedConsumer: ZERO_ADDRESS,
|
||||||
|
withMint: false
|
||||||
|
}
|
||||||
|
|
||||||
|
dtParams.feeToken = addresses.MockUSDC
|
||||||
|
dtParams.feeAmount = '987654321'
|
||||||
|
|
||||||
|
const tx = await nftFactory.createNftWithDatatokenWithFixedRate(
|
||||||
|
nftData,
|
||||||
|
dtParams,
|
||||||
|
freParams
|
||||||
|
)
|
||||||
|
const txReceipt = await tx.wait()
|
||||||
|
const tokenCreatedEvent = getEventFromTx(txReceipt, 'TokenCreated')
|
||||||
|
|
||||||
|
const datatokenAddress = tokenCreatedEvent.args.newTokenAddress
|
||||||
|
|
||||||
|
const datatoken = new Datatoken(exchangeOwner)
|
||||||
|
|
||||||
|
const publishingMarketFee = await datatoken.getPublishingMarketFee(datatokenAddress)
|
||||||
|
assert(
|
||||||
|
publishingMarketFee.publishMarketFeeAmount ===
|
||||||
|
ethers.utils.parseUnits('987654321', 6).toString()
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user