pull/5558/head^2
yann300 4 weeks ago
parent 4dd3f34a34
commit 692f8933f0
  1. 69
      apps/remix-ide-e2e/src/tests/terminal.test.ts
  2. 16
      libs/remix-lib/src/execution/logsManager.ts
  3. 17
      libs/remix-simulator/test/events.ts

File diff suppressed because one or more lines are too long

@ -52,7 +52,21 @@ export class LogsManager {
}
eventMatchesFilter (changeEvent, queryType, queryFilter) {
if (queryFilter.topics.filter((logTopic) => changeEvent.log.topics.indexOf(logTopic) >= 0).length === 0) return false
// topics should match
let noMatch = false
for (let i = 0; i < queryFilter.topics.length; i++) {
if (!queryFilter.topics[i]) {
continue // if the topic isn't defined, we consider it a match.
}
if (Array.isArray(queryFilter.topics[i])) {
if (queryFilter.topics[i].indexOf(changeEvent.log.topics[i]) === -1) {
noMatch = true
}
continue
}
if (queryFilter.topics[i] !== changeEvent.log.topics[i]) noMatch = true
}
if (noMatch) return false
if (queryType === 'logs') {
const fromBlock = parseInt(queryFilter.fromBlock || '0x0')

@ -38,14 +38,14 @@ describe('Events', () => {
address: receiptTest.contractAddress,
fromBlock: 3,
toBlock: 'latest',
topics: ['0xdcd9c7fa0342f01013bd0bf2bec103a81936162dcebd1f0c38b1d4164c17e0fc', '0x342827c97908e5e2f71151c08502a66d44b6f758e3ac2f1de95f02eb95f0a735']
topics: ['0xdcd9c7fa0342f01013bd0bf2bec103a81936162dcebd1f0c38b1d4164c17e0fc']
})
let ownerLogs = await web3.eth.getPastLogs({
address: receiptOwner.contractAddress,
fromBlock: 3,
toBlock: 'latest',
topics: ['0x342827c97908e5e2f71151c08502a66d44b6f758e3ac2f1de95f02eb95f0a735', '0xdcd9c7fa0342f01013bd0bf2bec103a81936162dcebd1f0c38b1d4164c17e0fc']
topics: ['0x342827c97908e5e2f71151c08502a66d44b6f758e3ac2f1de95f02eb95f0a735']
})
// this should include the event triggered by the "set" transaction call.
@ -56,7 +56,7 @@ describe('Events', () => {
address: receiptOwner.contractAddress,
fromBlock: 2,
toBlock: 'latest',
topics: ['0x342827c97908e5e2f71151c08502a66d44b6f758e3ac2f1de95f02eb95f0a735', '0xdcd9c7fa0342f01013bd0bf2bec103a81936162dcebd1f0c38b1d4164c17e0fc']
topics: ['0x342827c97908e5e2f71151c08502a66d44b6f758e3ac2f1de95f02eb95f0a735']
})
// this should include the event triggered from the ctor.
assert.equal(ownerLogs.length, 2, '3) ownerLogs length should be equal to 2')
@ -65,10 +65,19 @@ describe('Events', () => {
address: receiptOwner.contractAddress,
fromBlock: 1,
toBlock: 2,
topics: ['0x342827c97908e5e2f71151c08502a66d44b6f758e3ac2f1de95f02eb95f0a735', '0xdcd9c7fa0342f01013bd0bf2bec103a81936162dcebd1f0c38b1d4164c17e0fc']
topics: ['0x342827c97908e5e2f71151c08502a66d44b6f758e3ac2f1de95f02eb95f0a735']
})
// this should only include the event triggered from the ctor.
assert.equal(ownerLogs.length, 1, '4) ownerLogs length should be equal to 1')
ownerLogs = await web3.eth.getPastLogs({
address: receiptOwner.contractAddress,
fromBlock: 1,
toBlock: 2,
topics: [['0x342827c97908e5e2f71151c08502a66d44b6f758e3ac2f1de95f02eb95f0a735', '0xdcd9c7fa0342f01013bd0bf2bec103a81936162dcebd1f0c38b1d4164c17e0fc']]
})
// 0xdcd9c7fa0342f01013b is a topic from a event emitted by the other contract and should not be take into account.
assert.equal(ownerLogs.length, 1, '5) ownerLogs length should be equal to 1')
})
})
})

Loading…
Cancel
Save