Generated ID with eventIndex in ficed rate. Added assert errors messages.
This commit is contained in:
parent
5f047fe93b
commit
dc674a345b
|
@ -64,8 +64,9 @@ export function handleRateChange(event: ExchangeRateChanged): void {
|
|||
event.address
|
||||
)
|
||||
const fixedRateExchange = getFixedRateExchange(fixedRateId)
|
||||
const eventIndex: number = event.logIndex.toI32()
|
||||
const newExchangeUpdate = new FixedRateExchangeUpdate(
|
||||
getUpdateOrSwapId(event.transaction.hash.toHex(), fixedRateId)
|
||||
getUpdateOrSwapId(event.transaction.hash.toHex(), fixedRateId, eventIndex)
|
||||
)
|
||||
newExchangeUpdate.oldPrice = fixedRateExchange.price
|
||||
newExchangeUpdate.createdTimestamp = event.block.timestamp.toI32()
|
||||
|
@ -101,8 +102,9 @@ export function handleActivated(event: ExchangeActivated): void {
|
|||
event.address
|
||||
)
|
||||
const fixedRateExchange = getFixedRateExchange(fixedRateId)
|
||||
const eventIndex: number = event.logIndex.toI32()
|
||||
const newExchangeUpdate = new FixedRateExchangeUpdate(
|
||||
getUpdateOrSwapId(event.transaction.hash.toHex(), fixedRateId)
|
||||
getUpdateOrSwapId(event.transaction.hash.toHex(), fixedRateId, eventIndex)
|
||||
)
|
||||
newExchangeUpdate.exchangeId = fixedRateId
|
||||
newExchangeUpdate.oldActive = fixedRateExchange.active
|
||||
|
@ -124,8 +126,9 @@ export function handleDeactivated(event: ExchangeDeactivated): void {
|
|||
event.address
|
||||
)
|
||||
const fixedRateExchange = getFixedRateExchange(fixedRateId)
|
||||
const eventIndex: number = event.logIndex.toI32()
|
||||
const newExchangeUpdate = new FixedRateExchangeUpdate(
|
||||
getUpdateOrSwapId(event.transaction.hash.toHex(), fixedRateId)
|
||||
getUpdateOrSwapId(event.transaction.hash.toHex(), fixedRateId, eventIndex)
|
||||
)
|
||||
newExchangeUpdate.oldActive = fixedRateExchange.active
|
||||
newExchangeUpdate.newActive = false
|
||||
|
@ -149,8 +152,9 @@ export function handleAllowedSwapperChanged(
|
|||
event.address
|
||||
)
|
||||
const fixedRateExchange = getFixedRateExchange(fixedRateId)
|
||||
const eventIndex: number = event.logIndex.toI32()
|
||||
const newExchangeUpdate = new FixedRateExchangeUpdate(
|
||||
getUpdateOrSwapId(event.transaction.hash.toHex(), fixedRateId)
|
||||
getUpdateOrSwapId(event.transaction.hash.toHex(), fixedRateId, eventIndex)
|
||||
)
|
||||
newExchangeUpdate.createdTimestamp = event.block.timestamp.toI32()
|
||||
newExchangeUpdate.tx = event.transaction.hash.toHex()
|
||||
|
@ -172,9 +176,9 @@ export function handleSwap(event: Swapped): void {
|
|||
event.address
|
||||
)
|
||||
const fixedRateExchange = getFixedRateExchange(fixedRateId)
|
||||
|
||||
const eventIndex: number = event.logIndex.toI32()
|
||||
const swap = new FixedRateExchangeSwap(
|
||||
getUpdateOrSwapId(event.transaction.hash.toHex(), fixedRateId)
|
||||
getUpdateOrSwapId(event.transaction.hash.toHex(), fixedRateId, eventIndex)
|
||||
)
|
||||
swap.createdTimestamp = event.block.timestamp.toI32()
|
||||
swap.tx = event.transaction.hash.toHex()
|
||||
|
|
|
@ -57,7 +57,8 @@ export function updateFixedRateExchangeSupply(
|
|||
|
||||
export function getUpdateOrSwapId(
|
||||
txAddress: string,
|
||||
exchangeId: string
|
||||
exchangeId: string,
|
||||
eventIndex: number
|
||||
): string {
|
||||
return `${txAddress}-${exchangeId}`
|
||||
return `${txAddress}-${exchangeId}-${eventIndex}`
|
||||
}
|
||||
|
|
|
@ -521,19 +521,31 @@ describe('Datatoken tests', async () => {
|
|||
await sleep(3000)
|
||||
const queryResult = await orderResponse.json()
|
||||
const order = queryResult.data.order
|
||||
assert(order.publishingMarket.id === erc20Params.mpFeeAddress.toLowerCase())
|
||||
assert(
|
||||
order.publishingMarketToken.id === erc20Params.feeToken.toLowerCase()
|
||||
order.publishingMarket.id === erc20Params.mpFeeAddress.toLowerCase(),
|
||||
'incorrect publish market fee address'
|
||||
)
|
||||
assert(
|
||||
order.publishingMarketToken.id === erc20Params.feeToken.toLowerCase(),
|
||||
'incorrect publish market fee token'
|
||||
)
|
||||
assert(
|
||||
order.publishingMarketAmmount === erc20Params.feeAmount,
|
||||
'incorrect publish market fee amount'
|
||||
)
|
||||
assert(order.publishingMarketAmmount === erc20Params.feeAmount)
|
||||
assert(
|
||||
order.consumerMarket.id ===
|
||||
consumeMarketFees.consumeMarketFeeAddress.toLowerCase()
|
||||
consumeMarketFees.consumeMarketFeeAddress.toLowerCase(),
|
||||
'incorrect consume market fee address'
|
||||
)
|
||||
assert(
|
||||
order.consumerMarketToken.id ===
|
||||
consumeMarketFees.consumeMarketFeeToken.toLowerCase()
|
||||
consumeMarketFees.consumeMarketFeeToken.toLowerCase(),
|
||||
'incorrect consume market fee token'
|
||||
)
|
||||
assert(
|
||||
order.consumerMarketAmmount === '0.00000000000002',
|
||||
'incorrect consume market fee amount'
|
||||
)
|
||||
assert(order.consumerMarketAmmount === '0.00000000000002')
|
||||
})
|
||||
})
|
||||
|
|
|
@ -692,7 +692,11 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||
const swappedAmount = web3.utils.fromWei(
|
||||
new BN(tx.returnValues.baseTokenSwappedAmount)
|
||||
)
|
||||
assert(swaps.id === `${tx.transactionHash}-${fixedRateId}`, 'incorrect: id')
|
||||
assert(
|
||||
swaps.id ===
|
||||
`${tx.transactionHash}-${fixedRateId}-${tx.logIndex.toFixed(1)}`,
|
||||
'incorrect: id'
|
||||
)
|
||||
assert(swaps.exchangeId.id === fixedRateId, 'incorrect: exchangeId')
|
||||
assert(swaps.by.id === user1, 'incorrect value for: id')
|
||||
assert(swaps.baseTokenAmount === swappedAmount, 'incorrect baseTokenAmount')
|
||||
|
@ -745,7 +749,11 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||
const swappedAmount = web3.utils.fromWei(
|
||||
new BN(tx.returnValues.baseTokenSwappedAmount)
|
||||
)
|
||||
assert(swaps.id === `${tx.transactionHash}-${fixedRateId}`, 'incorrect: id')
|
||||
assert(
|
||||
swaps.id ===
|
||||
`${tx.transactionHash}-${fixedRateId}-${tx.logIndex.toFixed(1)}`,
|
||||
'incorrect: id'
|
||||
)
|
||||
assert(swaps.exchangeId.id === fixedRateId, 'incorrect: exchangeId')
|
||||
assert(swaps.by.id === user1, 'incorrect value for: id')
|
||||
assert(swaps.baseTokenAmount === swappedAmount, 'incorrect baseTokenAmount')
|
||||
|
|
Loading…
Reference in New Issue