Skip to content

Commit

Permalink
Fix event.
Browse files Browse the repository at this point in the history
  • Loading branch information
mariacarmina committed Jan 20, 2025
1 parent f9c3e94 commit f5afad9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
12 changes: 3 additions & 9 deletions src/test/integration/pricing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Dispenser from '@oceanprotocol/contracts/artifacts/contracts/pools/dispen
import { Database } from '../../components/database/index.js'
import { OceanIndexer } from '../../components/Indexer/index.js'
import { RPCS } from '../../@types/blockchain.js'
import { getEventFromTx, getEventFromTxByHash } from '../../utils/util.js'
import { getEventFromTx } from '../../utils/util.js'
import { waitToIndex, expectedTimeoutFailure } from './testUtils.js'
import { genericDDO } from '../data/ddo.js'
import {
Expand Down Expand Up @@ -273,10 +273,7 @@ describe('Publish pricing scehmas and assert ddo stats - FRE & Dispenser', () =>
assert(tx, 'Cannot create dispenser')
const txReceipt = await tx.wait()
console.log('txReceipt for dipenser: ', JSON.stringify(txReceipt))
const dispenserEvent = getEventFromTxByHash(
txReceipt,
'0x7d0aa581e6eb87e15f58588ff20c39ff6622fc796ec9bb664df6ed3eb02442c9' // DispenserCreated
)
const dispenserEvent = getEventFromTx(txReceipt, 'NewDispenser')
console.log('dispenserEvent: ', JSON.stringify(dispenserEvent))
assert(
dispenserEvent.args[0] === datatokenAddress,
Expand All @@ -295,10 +292,7 @@ describe('Publish pricing scehmas and assert ddo stats - FRE & Dispenser', () =>
)
assert(tx, 'Cannot activate dispenser')
const activationReceipt = await activationTx.wait()
const activationEvent = getEventFromTxByHash(
activationReceipt,
'0xe9372084cb52c5392afee4b9d79d131e04b1e65676088d50a8f39fffb16a8745' // DispenserActivated
)
const activationEvent = getEventFromTx(activationReceipt, EVENTS.DISPENSER_ACTIVATED)
assert(
activationEvent.args[0] === datatokenAddress,
'Datatoken addresses do not match for dispenser event'
Expand Down
6 changes: 0 additions & 6 deletions src/utils/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ export function getEventFromTx(txReceipt: { logs: any[] }, eventName: any) {
})[0]
}

export function getEventFromTxByHash(txReceipt: { logs: any[] }, eventHash: string) {
return txReceipt?.logs?.filter((log) => {
return log?.topics[0] === eventHash
})[0]
}

export function fetchEventFromTransaction(
txReceipt: any,
eventName: string,
Expand Down

0 comments on commit f5afad9

Please sign in to comment.