1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

Merge pull request #267 from oceanprotocol/bug/fix_FixedRate_searchForDT

Fix/check in searchForDT
This commit is contained in:
Alex Coseru 2020-09-10 17:16:57 +03:00 committed by GitHub
commit 7373cff011
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -347,10 +347,10 @@ export class OceanFixedRateExchange {
for (let i = 0; i < events.length; i++) {
const constituents = await this.getExchange(events[i].returnValues[0])
constituents.exchangeID = events[i].returnValues[0]
if (constituents.active === true) {
const supply = new BigNumber(this.web3.utils.fromWei(constituents.supply))
if (constituents.active === true && constituents.dataToken === dataTokenAddress) {
const supply = new BigNumber(await this.getSupply(constituents.exchangeID))
const required = new BigNumber(minSupply)
if (supply >= required) {
if (supply.gte(required)) {
result.push(constituents)
}
}

View File

@ -173,6 +173,7 @@ describe('FixedRateExchange flow', () => {
it('Bob should find the exchange', async () => {
const exchangeDetails = await FixedRateClass.searchforDT(tokenAddress, '0')
assert(exchangeDetails[0].exchangeID === aliceExchangeId)
assert(exchangeDetails.length === 1)
})
it('Bob should get the exchange details', async () => {
const exchangeDetails = await FixedRateClass.getExchange(aliceExchangeId)
@ -221,4 +222,8 @@ describe('FixedRateExchange flow', () => {
const exchangeDetails = await FixedRateClass.getExchange(aliceExchangeId)
assert(exchangeDetails.active === true)
})
it('Bob should not find the exchange', async () => {
const exchangeDetails = await FixedRateClass.searchforDT(tokenAddress, tokenAmount)
assert(exchangeDetails.length === 0)
})
})